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

Default JS Dispatcher for React Native is wrong #2843

Closed
Legion2 opened this issue Jul 25, 2021 · 5 comments · Fixed by #2846
Closed

Default JS Dispatcher for React Native is wrong #2843

Legion2 opened this issue Jul 25, 2021 · 5 comments · Fixed by #2846
Labels

Comments

@Legion2
Copy link
Contributor

Legion2 commented Jul 25, 2021

As part of ecc68f1 the Default dispatcher for React Native was set to NodeDispatcher. However, there is no process.nextTick in React Native environments. There is only a fake process.env object but nothing else. As a result the Default dispatcher does not work in React Native.

So I tested the other dispatchers. In React Native environments the SetTimeoutDispatcher works well. If React Native is executed with a Debugger (Chrome) the JS code is executed in a Chrome worker. In this mode SetTimeoutDispatcher and window.asCoroutineDispatcher() can be used as dispatchers, NodeDispatcher does not work.

To resolve this issue, createDefaultDispatcher must be adapted, so it properly detects the fake process object without the nextTick function.

If needed I can provide a PR and test changes.

@qwwdfsad qwwdfsad added the js label Jul 27, 2021
@qwwdfsad
Copy link
Member

Thanks for the detailed explanation! The PR is very welcome

Legion2 added a commit to Legion2/kotlinx.coroutines that referenced this issue Jul 29, 2021
@andylamax
Copy link

Wooow, when will this change be released!?

@andylamax
Copy link

Is there any current work around?

@Legion2
Copy link
Contributor Author

Legion2 commented Aug 26, 2021

you can create your own dispatcher based on the one in the fix and then use it explicitly when launching coroutines

@andylamax
Copy link

Already did. Just thought maybe there would be one which would require me not to state explicitly which dispatcher

pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants