The crash occurs on a page with a navigation button that goes to a previous page using navigation.navigate, when hitting the button consecutively and continue producing touch events on the new loaded screen the application crashes.
This crash does not occur when the enableScreens is not activated.
Versions used
react-native-screens : 2.0.0-alpha.29
@react-navigation/native: 5.0.0-alpha.27
@react-navigation/stack: 5.0.0-alpha.61
Java exception launched.
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:3562)
at android.view.ViewGroup.addView(ViewGroup.java:3415)
at android.view.ViewGroup.addView(ViewGroup.java:3360)
at android.view.ViewGroup.addView(ViewGroup.java:3336)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:887)
at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2100)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1874)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1830)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:752)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:586)
at dalvik.system.NativeStart.main(NativeStart.java)
There is a workaround by disabling the button after the first call to the onPress event, but the crash can be still a problem and does not occur without enableScreens.
Receiving this issue as well on the latest versions of rn screens & rn native stack
Thanks you @Kyberius for reporting this. Would be great if you could provide a simple app that we can use to reproduce this problem.
@codecog can you provide a repo with minimal configuration needed to reproduce the bug?
@WoLewicki No problem, i'll put something together today.
I apologize for the delayed response, for me the problem went away with an update to one of the stable versions.
Hmm, i've tried starting a new project and setting listeners up for AppState and NetInfo. Can't reproduce the issue so perhaps it's something else that doesn't play nicely. I'll create a new issue if i end up reproducing it again.
It was definetly happening when i was asking for permissions based on connectivity / location change and then swapping from settings to application. I also swapped between stacks based on the outcome of the permissions check
Ok, thanks! So I am closing this issue. Feel free to comment here if you need anything.