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

Crash: [RNScreens] Attempt to use context detached from activity #2285

Closed
janicduplessis opened this issue Aug 6, 2024 · 9 comments
Closed
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android

Comments

@janicduplessis
Copy link
Contributor

Description

I am currently getting this crash in production on the new arch. Sorry I do not currently have a way to repro. It seems to happen on app start.

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:29)
    at com.facebook.react.ReactInstanceManager.getOrCreateViewManagers(ReactInstanceManager.java:933)
    at com.facebook.react.defaults.DefaultReactNativeHost.getUIManagerProvider$lambda$0(DefaultReactNativeHost.kt:62)
    at com.facebook.react.defaults.DefaultReactNativeHost.$r8$lambda$2VfogkR5HlwUbg2OQzsEtshFrKA(DefaultReactNativeHost.kt:0)
    at com.facebook.react.defaults.DefaultReactNativeHost$$InternalSyntheticLambda$1$05c7a5c5118f25e9dd8c1b0729e68cb11b3df9ba66f627d4df4560081540c992$0.createUIManager(DefaultReactNativeHost:0)
    at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1403)
    at com.facebook.react.ReactInstanceManager.lambda$runCreateReactContextOnNewThread$2(ReactInstanceManager.java:1121)
    at com.facebook.react.ReactInstanceManager.$r8$lambda$AwGS8CysOZmWJw3kRVARHQvw9Ew(ReactInstanceManager.java:0)
    at com.facebook.react.ReactInstanceManager$$InternalSyntheticLambda$1$7efc1e0f266dedd61d7461df5a9648f2c6db67d8501038129fda49f62b619150$0.run(ReactInstanceManager:0)
    at java.lang.Thread.run(Thread.java:1012)

Just opening this in case you have an idea what could cause this, will try to find how to repro.

Steps to reproduce

N/A

Snack or a link to a repository

N/A

Screens version

3.33.0

React Native version

0.74.3

Platforms

Android

JavaScript runtime

Hermes

Workflow

React Native (without Expo)

Architecture

Fabric (New Architecture)

Build type

Release mode

Device

Real device

Device model

SM-S711W Android 14

Acknowledgements

Yes

@github-actions github-actions bot added the Missing repro This issue need minimum repro scenario label Aug 6, 2024
Copy link

github-actions bot commented Aug 6, 2024

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@github-actions github-actions bot added the Platform: Android This issue is specific to Android label Aug 6, 2024
@kkafar
Copy link
Member

kkafar commented Aug 7, 2024

@janicduplessis, do you mind checking out 3.34.0?

@kkafar
Copy link
Member

kkafar commented Aug 7, 2024

I released it specifically to patch this error: https://github.com/software-mansion/react-native-screens/releases/tag/3.34.0.

Also I'm surprised that the code even builds - 3.33.0 should fail to build on RN 0.74.x, but hey, if it works it works.

@janicduplessis
Copy link
Contributor Author

I made a patch to make it build on 0.74. Just needs a few change to some method signature and in CMake config.

@kkafar
Copy link
Member

kkafar commented Aug 7, 2024

But have you had opportunity to test 3.34.0 (another version of screens, which I've released just this Monday? It should fix the issue. I'm aware that there can be still some problem when hot-reloading react native, but this should not be problem in production

@kkafar
Copy link
Member

kkafar commented Aug 7, 2024

If 3.34.0 does not work for you I'll try to debug this urgently & release new version on Friday, cause I'm off next 2 weeks.

This crash could happen on Android + Fabric + "bridgeful" combination in the very start of application due to race condition in the code. I've described the issue here: #2276

@janicduplessis
Copy link
Contributor Author

I have not, I will test it today.

@janicduplessis
Copy link
Contributor Author

Just deployed an update with rn-screens@3.34.0 will monitor crashes for the next day or so to make sure it doesn't happen anymore.

@janicduplessis
Copy link
Contributor Author

I can confirm that updating to 3.34.0 fixes this. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: Android This issue is specific to Android
Projects
None yet
Development

No branches or pull requests

2 participants