gutenberg-mobile icon indicating copy to clipboard operation
gutenberg-mobile copied to clipboard

Android demo app crash on resume

Open hypest opened this issue 6 years ago • 2 comments

Describe the bug The Android demo app crashes when trying to get back into it after putting it in the background with a small text edit.

To Reproduce Steps to reproduce the behavior:

  1. Open the Android demo app against Metro
  2. Scroll to a paragraph block and make a small text edit
  3. Tap on the "Back" button to dismiss the virtual keyboard
  4. Tap on "Back" again to exit the app
  5. Open the app again via the launcher
  6. Boom 💥. See below for stacktrace
2019-11-18 17:42:32.010 21571-21571/com.gutenberg E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.gutenberg, PID: 21571
    java.lang.NullPointerException: Attempt to invoke virtual method 'int android.text.Layout.getLineForOffset(int)' on a null object reference
        at org.wordpress.mobile.ReactNativeAztec.ReactAztecText$4.run(ReactAztecText.java:177)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6718)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Expected behavior App should resume without a crash.

Smartphone (please complete the following information):

  • Device: Pixel 2 XL
  • OS: Android 9
  • on gutenberg-mobile hash: c6d095ed

hypest avatar Nov 18 '19 17:11 hypest

This issue exists only in our example app and the cause is that the reactNativeContext is not destroyed when the app is still running even if there is no activity (after back button click the last activity is destroyed but the app is not) So when we back to the app the react tree is created but JS context is the same so we still have the previous state (blocklist etc) but we pass the new initialHtml which generates new blocks with new ids. However, when we get back app tries to select the block which was selected before (now it doesn't exist because we have a new list with new ids) That's why we have a null reference here :)

In the client app, the issue doesn't exist.

dratwas avatar Dec 06 '19 11:12 dratwas

Still exists in block editor's v1.23.0.

hypest avatar Feb 28 '20 14:02 hypest

After reviewing this old issue, currently, the demo app does not crash when opening it again but it does refresh the initial content (since it is set up that way at the moment). I tried using Metro without the DEV flag and the editor opened with the content it had before without crashing.

Since this currently does not affect the developing process, we can close this issue but please feel free to open it again if needed. Thanks!

geriux avatar May 14 '24 14:05 geriux