-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Async JS "stacking up" when MainActivity is in the background #50327
Comments
Warning Could not parse version: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.76.2. |
Warning Could not parse version: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.76.2. |
Hi @descorp thanks for the issue. I highly doubt that the problem is related to the It is more likely that we changed something in the execution model and we "pause" the JS thread if we see that the activity is not active. I need to ask around as I don't have context about it. Perhaps @cortinico or @rubennorte knows more about it. Does it happens on Android only or also on iOS? |
Only on Android. Before you ask, rewriting the native library too use Fragments instead of Activity is not a feasible option 😅
I have noticed similar behaviour on Android when app is dismisses (which make sense). Could be that at some point App's lifecycle was changed to MainActivity lifecycle f? |
It could be. I don't have a lot of details on the Android side, unfortunately. @cortinico can you have a look at this? |
Thanks @cipolleschi
What grinds my gears is the fact, that disabling New Arch does not resolve it for me locally, and yet not stoping some library consumers with latest SDK to use it..
I understand the intent. |
I don't have an answer right now, unfortunately. I think we have to discuss this more thoroughly internally, to understand what will be the right execution model for this use case, and that's not a decision a can make myself. I'll keep this issue updated as soon as I learn more about this. |
Thanks!
Just to emphasise, sync JS code works perfectly on background (you can see that on my reproducer repo). Async code is the problem. I am not a JS core expert, but my assumption is that something is off with the way how |
Description
Hi everyone,
I'm encountering a really strange issue and hoping someone here might have some insight.
Here's the problem: In any new React Native app generated using @react-native-community/cli, when a secondary Activity is presented (and the main Activity is in the background), asynchronous JavaScript code seems to stop functioning correctly. It appears to "stack up" and only executes after the secondary Activity is dismissed.
For context, I'm developing a React Native package that has worked without this issue for the past two years. My local test app also works fine, and many users are using it successfully on modern React Native versions (I know of at least one on 0.76.7). This issue seems specific to freshly created apps.
I've created a minimal repo to reproduce the problem: https://github.com/descorp/RNAlertTest.
Interestingly, one user reported that turning off the "new Architecture" resolved this "thread freezing" problem for them, but I haven't been able to reproduce this fix locally.
My suspicion is that something has changed in the project generation process with
@react-native-community/cli
compared to the oldernpx react-native init
, but I'm not sure what it could be.Has anyone else experienced anything similar or have any ideas on what might be causing this? Any help would be greatly appreciated!
Steps to reproduce
yarn && yarn android
Abstract:
await sleep(100)
orfetch('www.google.com')
)React Native Version
0.74.7
Affected Platforms
Runtime - Android
Output of
npx @react-native-community/cli info
Stacktrace or Logs
Reproducer
https://github.com/descorp/RNAlertTest
Screenshots and Videos
The text was updated successfully, but these errors were encountered: