nativescript-community / ui-lottie

NativeScript plugin to expose Airbnb Lottie
https://github.com/airbnb/lottie-android
Other
176 stars 58 forks source link

Android app crashes on back navigation (4.0.0) #49

Closed apsaros closed 3 years ago

apsaros commented 4 years ago

Hi,

First, thanks for a great plugin! :) However, I've been running into an issue with 4.0.0 that only occurs on Android. Error occurs on simulators and physical devices, tested locally and in Firebase tests.

When I press the Android back navigation button, the app crashes and throws the following error:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onDismiss failed
System.err: Error: java.lang.IllegalStateException: Cannot remove Fragment attached to a different FragmentManager. Fragment fragment8[5]<Page(727)> is already attached to a FragmentManager.
System.err:     androidx.fragment.app.BackStackRecord.remove(BackStackRecord.java:188)
System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err:     com.tns.gen.androidx.fragment.app.DialogFragment_vendor_70990_26_DialogFragmentImpl.onDismiss(DialogFragment_vendor_70990_26_DialogFragmentImpl.java:25)
System.err:     android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1361)
System.err:     android.os.Handler.dispatchMessage(Handler.java:106)
System.err:     android.os.Looper.loop(Looper.java:164)
System.err:     android.app.ActivityThread.main(ActivityThread.java:6494)
System.err:     java.lang.reflect.Method.invoke(Native Method)
System.err:     com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
System.err: 
System.err: StackTrace:
System.err:     Frame: function:'Frame.disposeCurrentFragment', file:'file:///node_modules/tns-core-modules/ui/frame/frame.js:181:20
System.err:     Frame: function:'Frame.onUnloaded', file:'file:///node_modules/tns-core-modules/ui/frame/frame.js:171:13
System.err:     Frame: function:'', file:'file:///node_modules/tns-core-modules/ui/core/view-base/view-base.js:315:91
System.err:     Frame: function:'ViewBase.callFunctionWithSuper', file:'file:///node_modules/tns-core-modules/ui/core/view-base/view-base.js:304:8
System.err:     Frame: function:'ViewBase.callUnloaded', file:'file:///node_modules/tns-core-modules/ui/core/view-base/view-base.js:315:13
System.err:     Frame: function:'DialogFragmentImpl.onDismiss', file:'file:///node_modules/tns-core-modules/ui/core/view/view.js:148:22
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err:     at com.tns.gen.androidx.fragment.app.DialogFragment_vendor_70990_26_DialogFragmentImpl.onDismiss(DialogFragment_vendor_70990_26_DialogFragmentImpl.java:25)
System.err:     at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1361)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
System.err:     at android.os.Looper.loop(Looper.java:164)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6494)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
System.err: Caused by: java.lang.IllegalStateException: Cannot remove Fragment attached to a different FragmentManager. Fragment fragment8[5]<Page(727)> is already attached to a FragmentManager.
System.err:     at androidx.fragment.app.BackStackRecord.remove(BackStackRecord.java:188)
System.err:     ... 14 more

My package.json

"nativescript": {
    "id": "com.averly.mindcode",
    "tns-android": {
      "version": "6.0.2"
    },
    "tns-ios": {
      "version": "6.0.2"
    }
  },
  "dependencies": {
    "nativescript-appversion": "^1.4.2",
    "nativescript-audio": "^5.0.4",
    "nativescript-carousel": "^6.1.0",
    "nativescript-datetimepicker": "^1.2.1",
    "nativescript-fonticon": "^2.0.0",
    "nativescript-image-cache-it": "^4.1.2",
    "nativescript-local-notifications": "^4.0.1",
    "nativescript-lottie": "^4.0.0",
    "nativescript-plugin-firebase": "^9.0.4",
    "nativescript-purchase": "^2.0.9",
    "nativescript-ratings": "^1.0.1",
    "nativescript-taptic-engine": "^2.1.0",
    "nativescript-theme-core": "^1.0.4",
    "nativescript-ui-gauge": "5.0.0",
    "nativescript-videoplayer": "^4.2.1",
    "nativescript-vue": "^2.4.0",
    "nativescript-vue-star-rating": "0.0.4",
    "tns-core-modules": "^6.0.7",
    "uglifyjs-webpack-plugin": "^2.1.3",
    "vuex": "^3.1.0"
  },

Let me know if you need further info!

bradmartin commented 4 years ago

Do you use a TabView in your app? Just dont see anything in the stack that indicates this plugin is responsible. The fragment manager is related to navigation or tabs with viewpager on android typically.

apsaros commented 4 years ago

Nope, not using tabview (made a custom one). I'm using nested frames in some views/pages, if that might be related.

I've narrowed it down to this plugin since the behavior starts when I upgrade to 4.0.0 from 3.02. And if I downgrade everything works again. I'm of course nuking (rm -rf platforms node_modules) the project between tests.

Let me see if I can isolate it somehow. Maybe it's due to some weird conjunction with other plugins, or the structure of the nav, frames, etc.

apsaros commented 3 years ago

Closing issue, out-of-date