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

fix(DTXReactNativeSupport): JS and Content can load in any order #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TimotheeIsnard
Copy link

Hello, submitting a fix for a DetoxSync issue I'm running into with React Native.

This is my first PR to DetoxSync, so please let me know if I got anything wrong =)


Previously waitForReactNativeLoadWithCompletionHandler would add an observer for "RCTJavaScriptDidLoadNotification", then when notified would add a second observer for "RCTContentDidAppearNotification", and after getting a notification for both it would call the completion handler.

However, with the React Native new architecture the loading of the JS and Content can happen in a different order (content first). This would cause DetoxSync to get stuck when enabling synchronization.

Instead, we register all observers (JS, content, failure) one after the other, and we use a race-free C11 atomic to count when we receive a successful JS or Content notification.
After we receive both (or fail), we call the handler as before.

Previously waitForReactNativeLoadWithCompletionHandler would
add an observer for "RCTJavaScriptDidLoadNotification",
then when notified would add a second observer for
"RCTContentDidAppearNotification", and after getting a notification
for both it would call the completion handler.

However, with the React Native new architecture the loading of
the JS and Content can happen in a different order (content first).
This would cause DetoxSync to get stuck when enabling synchronization.

Instead, we register all observers (JS, content, failure) one after
the other, and we use a race-free C11 atomic to count when we
receive a successful JS or Content notification.
After we receive both (or fail), we call the handler as before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants