Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes when reloading app quickly on Android #5958

Merged
merged 2 commits into from
May 1, 2024

Conversation

lukmccall
Copy link
Member

Summary

Fixes:
https://github.com/software-mansion/react-native-reanimated/assets/9578601/949756a7-fb89-4bbd-89a6-52d1ba759083

Stack trace:

FATAL EXCEPTION: main
Process: com.lukaszkosmaty.myapp, PID: 17336
java.lang.AssertionError
	at com.swmansion.reanimated.NodesManager.<init>(NodesManager.java:157)
	at com.swmansion.reanimated.ReanimatedModule.getNodesManager(ReanimatedModule.java:133)
	at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.maybeInit(ReanimatedNativeHierarchyManager.java:47)
	at com.swmansion.reanimated.layoutReanimation.ReaLayoutAnimator.isLayoutAnimationEnabled(ReanimatedNativeHierarchyManager.java:193)
	at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.isLayoutAnimationDisabled(ReanimatedNativeHierarchyManager.java:269)
	at com.swmansion.reanimated.layoutReanimation.ReanimatedNativeHierarchyManager.dropView(ReanimatedNativeHierarchyManager.java:416)
	at com.facebook.react.uimanager.NativeViewHierarchyManager.removeRootView(NativeViewHierarchyManager.java:665)
	at com.facebook.react.uimanager.UIViewOperationQueue$RemoveRootViewOperation.execute(UIViewOperationQueue.java:79)
	at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:910)
	at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1023)
	at com.facebook.react.uimanager.UIViewOperationQueue.-$$Nest$mflushPendingBatches(Unknown Source:0)
	at com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded(UIViewOperationQueue.java:979)
	at com.facebook.react.bridge.GuardedRunnable.run(GuardedRunnable.java:29)
	at android.os.Handler.handleCallback(Handler.java:938)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loopOnce(Looper.java:201)
	at android.os.Looper.loop(Looper.java:288)
	at android.app.ActivityThread.main(ActivityThread.java:7839)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

It seems that the code is attempting to trigger the layout animation for views that are going to be removed, but due to the app being in a reloading state, the native side is not fully initialized. I believe that in such cases, it would be best to temporarily disable the layout animation.

Screenshot 2024-04-30 at 16 07 33

⚠️ Note: I'm not 100% sure if that is a correct fix, however, I don't have any other ideas.

Test plan

The crash also happens without the dev-client, but it isn't that often. So it's easier to reproduce it like this.

yarn create expo-app --template default@sdk-51
cd my-app
yarn expo install expo-dev-client
yarn expo run:android
# reload the app multiple times 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants