-
-
Notifications
You must be signed in to change notification settings - Fork 521
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(Android, Paper): apps soft crash on exception due to detached context #2199
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So this exception is thrown always on Paper? Does it mean we did not test if the previous PR works correctly with old arch? |
Yep, the #2169 wasn't supposed to impact Paper in any way, so I only builded the TestsExample w/o testing the runtime. |
Ok so it's another example that we need the e2e tests to work correctly 😅 |
WoLewicki
approved these changes
Jun 21, 2024
Yeah, +1. There is this possible fix in works: but we'll see whether it works out. |
alduzy
pushed a commit
that referenced
this pull request
Jun 28, 2024
…text (#2199) ## Description My recent PR: * #2169 introduced creation of dummy layout, which requires react context to be attached to activity, as we need access to the activity. Unfortunately when running on Paper the context is not attached to the activity yet, resulting in exception being thrown. <details> <summary>Exception</summary> ``` Failed to create NativeModule 'UIManager' java.lang.IllegalArgumentException: [RNScreens] Attempt to use context detached from activity at com.swmansion.rnscreens.utils.ScreenDummyLayoutHelper.ensureDummyLayoutWithHeader(ScreenDummyLayoutHelper.kt:68) at com.swmansion.rnscreens.utils.ScreenDummyLayoutHelper.<init>(ScreenDummyLayoutHelper.kt:53) at com.swmansion.rnscreens.RNScreensPackage.createViewManagers(RNScreensPackage.kt:28) at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:933) at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:78) at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:38) at com.facebook.react.BaseReactPackage$ModuleHolderProvider.get(BaseReactPackage.java:156) at com.facebook.react.BaseReactPackage$ModuleHolderProvider.get(BaseReactPackage.java:144) at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:186) at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:151) at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:148) at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469) at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:445) at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:88) at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:46) at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1231) at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1180) at com.facebook.react.ReactInstanceManager.lambda$runCreateReactContextOnNewThread$1(ReactInstanceManager.java:1143) at com.facebook.react.ReactInstanceManager.$r8$lambda$FD-H2RG7CdgXPtYJUBikxLbd8MA(Unknown Source:0) at com.facebook.react.ReactInstanceManager$$ExternalSyntheticLambda4.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:233) ``` </details> I'll need to sort that out when working on fix for jumping content on Android + Paper combination, however right now it is more important for examples to work correctly. ## Changes Creating `ScreenDummyLayoutHelper` now only when running on new architecture. ## Test code and steps to reproduce Run `TestsExample` w/o this change, you will see the exception being thrown -> resulting in freeze on whitescreen. With this change the example runs normally. ## Checklist - [x] Ensured that CI passes
This was referenced Aug 23, 2024
This was referenced Aug 27, 2024
This was referenced Sep 24, 2024
ja1ns
pushed a commit
to WiseOwlTech/react-native-screens
that referenced
this pull request
Oct 9, 2024
…text (software-mansion#2199) ## Description My recent PR: * software-mansion#2169 introduced creation of dummy layout, which requires react context to be attached to activity, as we need access to the activity. Unfortunately when running on Paper the context is not attached to the activity yet, resulting in exception being thrown. <details> <summary>Exception</summary> ``` Failed to create NativeModule 'UIManager' java.lang.IllegalArgumentException: [RNScreens] Attempt to use context detached from activity at com.swmansion.rnscreens.utils.ScreenDummyLayoutHelper.ensureDummyLayoutWithHeader(ScreenDummyLayoutHelper.kt:68) at com.swmansion.rnscreens.utils.ScreenDummyLayoutHelper.<init>(ScreenDummyLayoutHelper.kt:53) at com.swmansion.rnscreens.RNScreensPackage.createViewManagers(RNScreensPackage.kt:28) at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:933) at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:78) at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:38) at com.facebook.react.BaseReactPackage$ModuleHolderProvider.get(BaseReactPackage.java:156) at com.facebook.react.BaseReactPackage$ModuleHolderProvider.get(BaseReactPackage.java:144) at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:186) at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:151) at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:148) at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469) at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:445) at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:88) at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:46) at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1231) at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1180) at com.facebook.react.ReactInstanceManager.lambda$runCreateReactContextOnNewThread$1(ReactInstanceManager.java:1143) at com.facebook.react.ReactInstanceManager.$r8$lambda$FD-H2RG7CdgXPtYJUBikxLbd8MA(Unknown Source:0) at com.facebook.react.ReactInstanceManager$$ExternalSyntheticLambda4.run(Unknown Source:4) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:233) ``` </details> I'll need to sort that out when working on fix for jumping content on Android + Paper combination, however right now it is more important for examples to work correctly. ## Changes Creating `ScreenDummyLayoutHelper` now only when running on new architecture. ## Test code and steps to reproduce Run `TestsExample` w/o this change, you will see the exception being thrown -> resulting in freeze on whitescreen. With this change the example runs normally. ## Checklist - [x] Ensured that CI passes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
My recent PR:
introduced creation of dummy layout, which requires react context to be attached to activity, as we need access
to the activity. Unfortunately when running on Paper the context is not attached to the activity yet, resulting
in exception being thrown.
Exception
I'll need to sort that out when working on fix for jumping content on Android + Paper combination, however right now
it is more important for examples to work correctly.
Changes
Creating
ScreenDummyLayoutHelper
now only when running on new architecture.Test code and steps to reproduce
Run
TestsExample
w/o this change, you will see the exception being thrown -> resulting in freeze on whitescreen.With this change the example runs normally.
Checklist