react-native-navigation
react-native-navigation copied to clipboard
Android:Tried to create view after it has already been destroyed
Error
java.lang.RuntimeException: Tried to create view after it has already been destroyed
at com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController.getView(ViewController.java:213)
at com.reactnativenavigation.viewcontrollers.child.ChildController.getView(ChildController.java:44)
at com.reactnativenavigation.viewcontrollers.stack.StackAnimator$pushWithoutElementTransitions$1.run(StackAnimator.kt:246)
at com.reactnativenavigation.viewcontrollers.viewcontroller.-$$Lambda$WyAR0JEWmTiz3cWwZS9qp-P3Ddg.on(lambda)
at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:133)
at com.reactnativenavigation.utils.CollectionUtils.forEach(CollectionUtils.java:127)
at com.reactnativenavigation.viewcontrollers.viewcontroller.ViewController.lambda$onViewWillAppear$3$ViewController(ViewController.java:265)
at com.reactnativenavigation.viewcontrollers.viewcontroller.-$$Lambda$ViewController$bfiHoKoA1KmT9QaA3BqT2KEB6CQ.run(lambda)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5856)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1026)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:887)
Environment
React Native Navigation version: 7.27.1、7.28.1、7.29.0 React Native version: "0.64.0" Platform(s): Android Device info: Version: Android 6.0 / vivo
The scenario where this problem occurs is that when Page A jumps to Page B, the view of page B has not been rendered, and then Navigation.pop is executed. This problem occurs. This problem usually does not appear on iOS or mobile phones with better performance. , because the page rendering is very fast.
So I tried to package with InteractionManager.runAfterInteractions, but it didn't solve it.
InteractionManager.runAfterInteractions(() => {
Navigation.pop(this.props.componentId)
});
After that, I tried to use setTimeout(()=>{Navigation.pop(this.props.componentId)},2000)
and found that it was working normally, there were no error reporting and flashback problems.setTimeout does not completely solve this problem, because the rendering speed of different mobile phones is different.
So I think you guys can try to reproduce this issue in low end phones
me to