Tried to create view after it has already been destroyed
Issue Description
Tried to create view after it has already been destroyed
Stack trace
java.lang.RuntimeException: Tried to create view after it has already been destroyed
at com.reactnativenavigation.viewcontrollers.ViewController.getView(ViewController.java:195)
at com.reactnativenavigation.viewcontrollers.ChildController.getView(ChildController.java:35)
at com.reactnativenavigation.anim.NavigationAnimator$1.onAnimationEnd(NavigationAnimator.java:60)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:552)
at android.animation.AnimatorSet.endAnimation(AnimatorSet.java:1294)
at android.animation.AnimatorSet.doAnimationFrame(AnimatorSet.java:1079)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1090)
at android.view.Choreographer.doCallbacks(Choreographer.java:893)
at android.view.Choreographer.doFrame(Choreographer.java:809)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1078)
at android.os.Handler.handleCallback(Handler.java:907)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7625)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
Environment
- React Native Navigation version: "6.0.1"
- React Native version: "0.61.4"
- Platform(s): Android
- Device info: Version: 9 - Release - Device Huawei ALP-L09
Hey @ayouidaniel Any more insights you can give on how to reproduce this crash?
Hey @ayouidaniel Any more insights you can give on how to reproduce this crash?
I need more time to investigate since I found isn't so easy to replicate. I got that stack trace from my production app (sentry). Today I got a new related error. Here is the trace.
java.lang.RuntimeException: Tried to create view after it has already been destroyed
at com.reactnativenavigation.viewcontrollers.ViewController.getView(ViewController.java:195)
at com.reactnativenavigation.viewcontrollers.ChildController.getView(ChildController.java:35)
at com.reactnativenavigation.viewcontrollers.modal.ModalPresenter.animateShow(ModalPresenter.java:68)
at com.reactnativenavigation.viewcontrollers.modal.ModalPresenter.lambda$showModal$0$ModalPresenter(ModalPresenter.java:54)
at com.reactnativenavigation.viewcontrollers.modal.-$$Lambda$ModalPresenter$sRqckO-p7gCNSzuCMIQlErs-cxM.run
at com.reactnativenavigation.viewcontrollers.-$$Lambda$P7xe27l85RASi5iJcSC7JIxgcA8.on
at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:93)
at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:87)
at com.reactnativenavigation.viewcontrollers.ViewController.lambda$onViewAppeared$3$ViewController(ViewController.java:251)
at com.reactnativenavigation.viewcontrollers.-$$Lambda$ViewController$JVA-JlcndtvdOg7249fa_WTZvHQ.run
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:216)
at android.app.ActivityThread.main(ActivityThread.java:7258)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
How to reproduce
Scenario A
- We use a bottom tab configuration
- We open up a modal.
- We push and pop (hardware back) in that modal stack.
Video https://streamable.com/555mly
Scenario B
- Push and pop (hardware back) diferent views fast.
This one gives the following trace:
04-03 16:11:02.537 5384 5595 V WindowManager: Remove Window{49fdb33 u0 com.app.app/com.app.app.MainActivity}: mSurfaceController=Surface(name=com.app.app/com.app.app.MainActivity[28229])/@0x771279b mAnimatingExit=false mRemoveOnExit=false mHasSurface=true surfaceShowing=true isAnimationSet=true app-animation=true mWillReplaceWindow=false inPendingTransaction=true mDisplayFrozen=false callers=com.android.server.wm.WindowState.access$300:281 com.android.server.wm.WindowState$DeathRecipient.binderDied:3359 android.os.BinderProxy.sendDeathNotice:1211 <bottom of call stack> <bottom of call stack> <bottom of call stack>
04-03 16:11:02.538 5384 5595 V WindowManager: Changing focus from Window{49fdb33 u0 com.app.app/com.app.app.MainActivity EXITING} to null Callers=com.android.server.wm.WindowState.setupWindowForRemoveOnExit:2896 com.android.server.wm.WindowState.removeIfPossible:2867 com.android.server.wm.WindowState.access$300:281 com.android.server.wm.WindowState$DeathRecipient.binderDied:3359
04-03 16:11:02.538 5384 5683 D InputTransport: Input channel destroyed: fd=367
04-03 16:11:02.538 7311 7311 D InputTransport: Input channel destroyed: fd=68
04-03 16:11:02.539 5989 23984 D ForegroundUtils: could not check pending caller
04-03 16:11:02.539 5384 5424 W libprocessgroup: kill(-28229, 9) failed: No such process
04-03 16:11:02.539 5384 5595 D InputDispatcher: Focus left window (28229): 49fdb33 0
04-03 16:11:02.539 5384 5595 D InputTransport: Input channel destroyed: fd=399
04-03 16:11:02.539 5384 5544 I InputDispatcher: focusedWindowHandle is null.
04-03 16:11:02.539 5384 5544 I InputDispatcher: size of windows with focusCandidate is 0 -
04-03 16:11:02.541 5384 5544 I InputDispatcher: focusedWindowHandle is null.
04-03 16:11:02.541 5384 5544 I InputDispatcher: size of windows with focusCandidate is 0 -
04-03 16:11:02.541 5384 5431 D WindowManager: reportFocusChangedSerialized, focused=false, inTouchMode=true, win=Window{49fdb33 u0 com.app.app/com.app.app.MainActivity EXITING}
04-03 16:11:02.541 5384 5431 E WindowManager: RemoteException occurs on reporting focusChanged, w=Window{49fdb33 u0 04-03 16:11:02.537 5384 5595 V WindowManager: Remove Window{49fdb33 u0 com.app.app/com.app.app.MainActivity}: mSurfaceController=Surface(name=com.app.app/com.app.app.MainActivity[28229])/@0x771279b mAnimatingExit=false mRemoveOnExit=false mHasSurface=true surfaceShowing=true isAnimationSet=true app-animation=true mWillReplaceWindow=false inPendingTransaction=true mDisplayFrozen=false callers=com.android.server.wm.WindowState.access$300:281 com.android.server.wm.WindowState$DeathRecipient.binderDied:3359 android.os.BinderProxy.sendDeathNotice:1211 <bottom of call stack> <bottom of call stack> <bottom of call stack>
04-03 16:11:02.538 5384 5595 V WindowManager: Changing focus from Window{49fdb33 u0 com.app.app/com.app.app.MainActivity EXITING} to null Callers=com.android.server.wm.WindowState.setupWindowForRemoveOnExit:2896 com.android.server.wm.WindowState.removeIfPossible:2867 com.android.server.wm.WindowState.access$300:281 com.android.server.wm.WindowState$DeathRecipient.binderDied:3359
04-03 16:11:02.538 5384 5683 D InputTransport: Input channel destroyed: fd=367
04-03 16:11:02.538 7311 7311 D InputTransport: Input channel destroyed: fd=68
04-03 16:11:02.539 5989 23984 D ForegroundUtils: could not check pending caller
04-03 16:11:02.539 5384 5424 W libprocessgroup: kill(-28229, 9) failed: No such process
04-03 16:11:02.539 5384 5595 D InputDispatcher: Focus left window (28229): 49fdb33 0
04-03 16:11:02.539 5384 5595 D InputTransport: Input channel destroyed: fd=399
04-03 16:11:02.539 5384 5544 I InputDispatcher: focusedWindowHandle is null.
04-03 16:11:02.539 5384 5544 I InputDispatcher: size of windows with focusCandidate is 0 -
04-03 16:11:02.541 5384 5544 I InputDispatcher: focusedWindowHandle is null.
04-03 16:11:02.541 5384 5544 I InputDispatcher: size of windows with focusCandidate is 0 -
04-03 16:11:02.541 5384 5431 D WindowManager: reportFocusChangedSerialized, focused=false, inTouchMode=true, win=Window{49fdb33 u0 com.app.app/com.app.app.MainActivity EXITING}
04-03 16:11:02.541 5384 5431 E WindowManager: RemoteException occurs on reporting focusChanged, w=Window{49fdb33 u0 com.app.app/com.app.app.MainActivity EXITING}
04-03 16:11:02.541 5384 5431 E WindowManager: android.os.DeadObjectException
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.BinderProxy.transactNative(Native Method)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.BinderProxy.transact(Binder.java:1145)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.view.IWindow$Stub$Proxy.windowFocusChanged(IWindow.java:500)
04-03 16:11:02.541 5384 5431 E WindowManager: at com.android.server.wm.WindowState.reportFocusChangedSerialized(WindowState.java:3920)
04-03 16:11:02.541 5384 5431 E WindowManager: at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:5456)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.Handler.dispatchMessage(Handler.java:106)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.Looper.loop(Looper.java:214)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.HandlerThread.run(HandlerThread.java:65)
04-03 16:11:02.541 5384 5431 E WindowManager: at com.android.server.ServiceThread.run(ServiceThread.java:44)
04-03 16:11:02.542 5384 5544 I InputDispatcher: focusedWindowHandle is null.
04-03 16:11:02.542 5384 5544 I InputDispatcher: size of windows with focusCandidate is 0 -/com.app.app.MainActivity EXITING}
04-03 16:11:02.541 5384 5431 E WindowManager: android.os.DeadObjectException
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.BinderProxy.transactNative(Native Method)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.BinderProxy.transact(Binder.java:1145)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.view.IWindow$Stub$Proxy.windowFocusChanged(IWindow.java:500)
04-03 16:11:02.541 5384 5431 E WindowManager: at com.android.server.wm.WindowState.reportFocusChangedSerialized(WindowState.java:3920)
04-03 16:11:02.541 5384 5431 E WindowManager: at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:5456)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.Handler.dispatchMessage(Handler.java:106)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.Looper.loop(Looper.java:214)
04-03 16:11:02.541 5384 5431 E WindowManager: at android.os.HandlerThread.run(HandlerThread.java:65)
04-03 16:11:02.541 5384 5431 E WindowManager: at com.android.server.ServiceThread.run(ServiceThread.java:44)
04-03 16:11:02.542 5384 5544 I InputDispatcher: focusedWindowHandle is null.
04-03 16:11:02.542 5384 5544 I InputDispatcher: size of windows with focusCandidate is 0 -
Some of our configs are: https://gist.github.com/tellodaniel/1957038b20be5b6b076e730c030c3f2b
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.
Bug already documented and still alive @guyca :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.
The issue has been closed for inactivity.
@guyca maybe this should be reopened
this issue still happens @guyca
This is happening for us in production on v6.9.1 still.
Stack Trace
java.lang.RuntimeException:
at com.reactnativenavigation.viewcontrollers.ViewController.getView (ViewController.java:193)
at com.reactnativenavigation.viewcontrollers.ChildController.getView (ChildController.java:35)
at com.reactnativenavigation.anim.StackAnimator$1.onAnimationEnd (StackAnimator.java:60)
at android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
at android.animation.AnimatorSet.endAnimation (AnimatorSet.java:1301)
at android.animation.AnimatorSet.doAnimationFrame (AnimatorSet.java:1086)
at android.animation.AnimationHandler.doAnimationFrame (AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100 (AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame (AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1040)
at android.view.Choreographer.doCallbacks (Choreographer.java:865)
at android.view.Choreographer.doFrame (Choreographer.java:796)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1027)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7557)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:937)
java.lang.RuntimeException:
at com.reactnativenavigation.viewcontrollers.ViewController.getView (ViewController.java:193)
at com.reactnativenavigation.viewcontrollers.ChildController.getView (ChildController.java:35)
at com.reactnativenavigation.anim.StackAnimator$1.onAnimationEnd (StackAnimator.java:60)
at android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:552)
at android.animation.AnimatorSet.endAnimation (AnimatorSet.java:1294)
at android.animation.AnimatorSet.doAnimationFrame (AnimatorSet.java:1079)
at android.animation.AnimationHandler.doAnimationFrame (AnimationHandler.java:146)
at android.animation.AnimationHandler.-wrap2 (Unknown Source)
at android.animation.AnimationHandler$1.doFrame (AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:977)
at android.view.Choreographer.doCallbacks (Choreographer.java:791)
at android.view.Choreographer.doFrame (Choreographer.java:723)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:965)
at android.os.Handler.handleCallback (Handler.java:790)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6651)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:810)
@alexandrasmith00 Can you please include a stack trace?
@guyca Added two stack traces above
Thanks @alexandrasmith00 I've prioritised it internally.
This is also happening for us in production we are using react-native-navigation v6.4.0
Stack Trace
java.lang.RuntimeException:
at com.reactnativenavigation.viewcontrollers.ViewController.getView (ViewController.java:196)
at com.reactnativenavigation.viewcontrollers.ChildController.getView (ChildController.java:35)
at com.reactnativenavigation.anim.NavigationAnimator$1.onAnimationEnd (NavigationAnimator.java:60)
at android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:554)
at android.animation.AnimatorSet.endAnimation (AnimatorSet.java:1301)
at android.animation.AnimatorSet.doAnimationFrame (AnimatorSet.java:1086)
at android.animation.AnimationHandler.doAnimationFrame (AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100 (AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame (AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run (Choreographer.java:1161)
at android.view.Choreographer.doCallbacks (Choreographer.java:986)
at android.view.Choreographer.doFrame (Choreographer.java:894)
at android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:1148)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7710)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)
Please suggest a solution or temporary workaround if any. In this part of code .. seems to me it is related to runtimeException inside getView when isDestroyed is true
I'm having same bug as above (only at real Android 10+ devices in production) "react-native-navigation": "^6.4.0" "react-native": "0.62.1"
I wasn't able to reproduce this issue on RNN 7.3.0. I'll revisit when someone adds a reproduction 👍
I have a reproduction of this error with exactly same first nine lines of the trace on RN 0.63.3 + RNN 7.3.0. Android 9, 10 and 11. Samsungs, Pixels, OnePluses.
@Adegeminas Could you provide the stack trace for the same, so that @guyca can pick it up. We are also having this issue on production but we are using RNN=6.12.2 and RN = 61.5.
com.reactnativenavigation.viewcontrollers.ViewController.getView (ViewController.java:33) com.reactnativenavigation.viewcontrollers.ChildController.getView (ChildController.java:4) com.reactnativenavigation.anim.NavigationAnimator$1.onAnimationEnd (NavigationAnimator.java:12) android.animation.Animator$AnimatorListener.onAnimationEnd (Animator.java:552) android.animation.AnimatorSet.endAnimation (AnimatorSet.java:1294) android.animation.AnimatorSet.doAnimationFrame (AnimatorSet.java:1079) android.animation.AnimationHandler.doAnimationFrame (AnimationHandler.java:146) android.animation.AnimationHandler.access$100 (AnimationHandler.java:37) android.animation.AnimationHandler$1.doFrame (AnimationHandler.java:54) android.view.Choreographer$CallbackRecord.run (Choreographer.java:986) android.view.Choreographer.doCallbacks (Choreographer.java:765) android.view.Choreographer.doFrame (Choreographer.java:697) android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:967) android.os.Handler.handleCallback (Handler.java:873) android.os.Handler.dispatchMessage (Handler.java:99) android.os.Looper.loop (Looper.java:214) android.app.ActivityThread.main (ActivityThread.java:7156) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:975)
I will update to 7.4.0 soon, but now on 0.63.3 + 7.3.0 i'm still having the same bug. Moreover, i can say that the bug affects like 5 percent of users. Sometimes it just need to reload app 2-3 times for it to pass but sometimes it remains for the very end.

@alexandrasmith00 @Adegeminas @cp-rf @Rishabh-Streak @tellodaniel @truongduyng Could you please create a reproducible code example?