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

Flush RN task queue with invokeAsync #4389

Merged
merged 6 commits into from Apr 27, 2022

Commits on Apr 19, 2022

  1. Flush the React Native UI task queue whenever we call from C++ to JS …

    …by calling jsCallInvoker->invokeAsync.
    
    React Native has its own JS "microtask" queue, implemented in https://github.com/facebook/react-native/blob/main/Libraries/Core/Timers/JSTimers.js. Any asynchronous work, e.g. `setTimeout` or `setImmediate`, is added to this queue, and the queue is flushed whenever a message is sent from React Native's native core to JS: https://github.com/facebook/react-native/blob/main/Libraries/BatchedBridge/MessageQueue.js#L108.
    
    However, our native to JS messages are not being passed via this abstraction - instead, we hook directly into the JS engine. This means that React Native is not aware that when Realm has done some async work, we might need to update the UI (and therefore flush the task queue), and this can result in Realm-related UI updates not showing until some action is taken which causes React Native to send a message from the core to JS (e.g. touching the screen), which flushes this task queue, resolving pending promises and updating the UI.
    
    This commit calls the React Native jsCallInvoker->invokeAsync method, which internally flushes the task queue. As this method is async, we wait for any current pending invocation to complete before triggering another one (using a flag, so the call is "debounced")
    Tom Duncalf committed Apr 19, 2022
    Configuration menu
    Copy the full SHA
    c7dccf5 View commit details
    Browse the repository at this point in the history

Commits on Apr 25, 2022

  1. WIP

    Tom Duncalf committed Apr 25, 2022
    Configuration menu
    Copy the full SHA
    3cd2bb4 View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2022

  1. Configuration menu
    Copy the full SHA
    b647138 View commit details
    Browse the repository at this point in the history
  2. Tidy up PR

    Tom Duncalf committed Apr 26, 2022
    Configuration menu
    Copy the full SHA
    1a1b6e3 View commit details
    Browse the repository at this point in the history
  3. Add changelog

    Tom Duncalf committed Apr 26, 2022
    Configuration menu
    Copy the full SHA
    e61a58a View commit details
    Browse the repository at this point in the history
  4. Remove unnecessary second call to invokeAsync

    Tom Duncalf committed Apr 26, 2022
    Configuration menu
    Copy the full SHA
    9180061 View commit details
    Browse the repository at this point in the history