-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Android: After the app reloads, we're stuck with a dead thread because of SingleThreadAsserter #18413
Comments
Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.54.0? Thank you for your contributions. |
Same exact issue on 0.54.0 yes. |
same this question |
Since I don't see anyone responding to this, I'll try to use reflection to change the
|
Anyone? What is even the purpose of the |
I've been integrating ReactNative into an existing project that is mainly built on Fragments. I'm experiencing this using the react-native-android-fragment library. Yes, any kind of reload kicks the fragment off the thread. I guess, I can just try to listen for this failure then call the ReactFragment hosting my material again? |
@SudoPlz The goal of this class is to validate that some code is always run from the same thread. I guess a proper fix would be to add a reset method and call it when the native modules that use it gets invalidated ( If you'd like to open up a PR to fix it that would be great. |
I'm not sure I know how to do that @janicduplessis do you mind elaborating a bit more? I'd be grateful. |
I had a quick look at the code and is it possible that you are holding on to an old instance of You could override
ReactInstanceManager since it is private in ReactRootView sadly.
|
Got it, always requesting the current react application context fixed the issue, thank you so much @janicduplessis ! |
Environment
Environment:
OS: macOS Sierra 10.12.6
Node: 8.4.0
Yarn: 1.5.1
npm: 5.3.0
Watchman: 4.7.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.53.0 => 0.53.0
Expected Behavior
I would expect the
SingleThreadAsserter
to clear themThread
value after the app reloads, so that a new thread can be used on every assertion from that point in.react-native/ReactAndroid/src/main/java/com/facebook/react/common/SingleThreadAsserter.java
Line 23 in 26684cf
Actual Behavior
Instead, the
SingleThreadAsserter
locks to the thread it was created with, so when the app reloads, and that thread dies we're stuck with a dead thread, which causes all subsequent assertions to fail.Almost every
uiManager
method requires that assertion, so that's a big issue.Steps to Reproduce
Here's a repo that suffers from that issue.
https://github.com/SudoPlz/react-native-synchronous-list
All works well until you reload. After the reload we get:
The text was updated successfully, but these errors were encountered: