react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Tried to create view after it has already been destroyed

Open tellodaniel opened this issue 6 years ago • 56 comments

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

tellodaniel avatar Mar 23 '20 22:03 tellodaniel

Hey @ayouidaniel Any more insights you can give on how to reproduce this crash?

guyca avatar Mar 24 '20 05:03 guyca

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)

tellodaniel avatar Mar 25 '20 18:03 tellodaniel

How to reproduce

Scenario A

  1. We use a bottom tab configuration
  2. We open up a modal.
  3. We push and pop (hardware back) in that modal stack.

Video https://streamable.com/555mly

Scenario B

  1. 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

tellodaniel avatar Apr 03 '20 22:04 tellodaniel

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.

stale[bot] avatar May 06 '20 16:05 stale[bot]

Bug already documented and still alive @guyca :)

tellodaniel avatar May 07 '20 00:05 tellodaniel

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.

stale[bot] avatar Jun 06 '20 08:06 stale[bot]

The issue has been closed for inactivity.

stale[bot] avatar Jun 13 '20 09:06 stale[bot]

@guyca maybe this should be reopened

tellodaniel avatar Jun 21 '20 19:06 tellodaniel

this issue still happens @guyca

truongduyng avatar Jun 28 '20 01:06 truongduyng

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 avatar Aug 07 '20 15:08 alexandrasmith00

@alexandrasmith00 Can you please include a stack trace?

guyca avatar Aug 07 '20 16:08 guyca

@guyca Added two stack traces above

alexandrasmith00 avatar Aug 11 '20 13:08 alexandrasmith00

Thanks @alexandrasmith00 I've prioritised it internally.

guyca avatar Aug 12 '20 06:08 guyca

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

Rishabh-Streak avatar Aug 24 '20 15:08 Rishabh-Streak

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"

Adegeminas avatar Nov 08 '20 11:11 Adegeminas

I wasn't able to reproduce this issue on RNN 7.3.0. I'll revisit when someone adds a reproduction 👍

guyca avatar Nov 09 '20 11:11 guyca

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 avatar Nov 17 '20 08:11 Adegeminas

@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)

cp-rf avatar Dec 01 '20 08:12 cp-rf

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.

image

Adegeminas avatar Dec 01 '20 12:12 Adegeminas

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

mrousavy avatar Dec 09 '20 09:12 mrousavy