Skip to content

refactor: move Worklets JS core from Reanimated #6973

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

Merged
merged 16 commits into from
Feb 6, 2025

Conversation

tjzel
Copy link
Collaborator

@tjzel tjzel commented Feb 3, 2025

Summary

Currently JS core of Worklets sits in Reanimated package. This PR moves it to Worklets. It's a bit messy but we'll get there eventually.

  • Added createCustomError that creates WorkletsError and ReanimatedError used in respective packages.
  • Added ESLint rule use-worklets-error, a copypaste of use-reanimated-error.
  • Moved shareables.ts to react-native-worklets.
  • Moved threads.ts to react-native-worklets.
  • Moved initializers.ts to react-native-worklets
  • Moved runtimes.ts to react-native-worklets
  • JS version checking in worklets is disabled for the time being, as it would clutter this PR even more. We'll circle back to it once we set version checking between Reanimated and Worklets.

Test plan

CI, run the example app.

@tjzel tjzel added this pull request to the merge queue Feb 6, 2025
Merged via the queue into main with commit 455d94a Feb 6, 2025
18 checks passed
@tjzel tjzel deleted the @tjzel/worklets/move-js-core branch February 6, 2025 10:58
github-merge-queue bot pushed a commit that referenced this pull request Feb 6, 2025
## Summary

I introduced a regression in #6973 by moving JS implementation of
`requestAnimationFrame` to Worklets. Native version of
`requestAnimationFrame` is injected in Reanimated's
`UIRuntimeDecorator.cpp` so `requestAnimationFrame` must be overwritten
in Reanimated, not in Worklets.

Since all the native implementation is in Reanimated and it would be a
hard task to extract it right now, I decided to keep it for the time
being unless we decide where it should land eventually.

## Test plan

The only difference is the lack of batching with my regression
introduced. You can `console.log(currentCallbacks.length)` to see that
the batching is restored.
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