-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(Worklets): runAsyncGuardedOnUI #7906
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
Conversation
…ts/runtime-async-queue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds asynchronous execution support to the UI Runtime by implementing an AsyncQueue
for the UIRuntime. Previously, the UI Runtime's AsyncQueue was always null, preventing the use of runAsyncGuarded
functionality needed for asynchronous promise resolution.
Key changes:
- Created
AsyncQueueUI
class that uses UIScheduler for async execution on UI thread - Modified RuntimeManager to accept an AsyncQueue parameter for UI runtime creation
- Refactored
runAsyncGuarded
implementation to move from header to implementation file
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
WorkletRuntime.h | Moved runAsyncGuarded method declaration from inline to separate implementation |
WorkletRuntime.cpp | Added implementation of runAsyncGuarded with improved error messaging |
RuntimeManager.h | Updated createUninitializedUIRuntime to accept AsyncQueue parameter |
RuntimeManager.cpp | Modified UI runtime creation to use provided AsyncQueue |
AsyncQueueImpl.h | Added AsyncQueueUI class declaration |
AsyncQueueImpl.cpp | Implemented AsyncQueueUI using UIScheduler for UI thread execution |
WorkletsModuleProxy.cpp | Updated to create UI runtime with new AsyncQueueUI instance |
packages/react-native-worklets/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp
Outdated
Show resolved
Hide resolved
…ts/runGuardedAsync-on-UI
Summary
Previously the AsyncQueue of UIRuntime was always set to nullptr, making it impossible to invoke
runGuardedAsync
on it. I created a simple implementation ofAsyncQueue
for UI Runtime to enable that invocation. It's needed for asynchronous promise resolution on the UI Runtime.Test plan
Apply the following diff and see that
runOnRuntime
with UIRuntime works properly.