Skip to content

refactor(Worklets): extract SynchronizableDynamic from Synchronizable - #10293

Draft
tjzel wants to merge 3 commits into
@tjzel/worklets/synchronizable-atomic-valuefrom
@tjzel/worklets/synchronizable-dynamic
Draft

refactor(Worklets): extract SynchronizableDynamic from Synchronizable#10293
tjzel wants to merge 3 commits into
@tjzel/worklets/synchronizable-atomic-valuefrom
@tjzel/worklets/synchronizable-dynamic

Conversation

@tjzel

@tjzel tjzel commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Note

This PR description is AI-generated.

Summary

Depends on #10292.

I made Synchronizable a pure virtual class and moved its shared_ptr<Serializable> storage into a new SynchronizableDynamic subclass. The base class keeps the shared unpacking logic in toJSValue and became header-only. The accessors keep their previous Serializable signatures and dispatch virtually - the proxy still converts values at the JSI boundary. There are no behavior or API changes - this prepares the class hierarchy for a fixed-type Synchronizable implementation.

I also dropped the commented out setDirty and its TODO. The TODO said setDirty makes little sense while the member isn't atomic, and #10287 made it atomic.

Test plan

Existing memory/synchronizable.test runtime tests cover the refactor.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@tjzel, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 33 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 24992981-976f-4c88-8b22-8975b301e72b

📥 Commits

Reviewing files that changed from the base of the PR and between fee802e and 8eb1292.

📒 Files selected for processing (1)
  • packages/react-native-worklets/CHANGELOG.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 7131ecc0-486b-41ed-a159-4e6e9a5699b5

📥 Commits

Reviewing files that changed from the base of the PR and between 1e2d38a and fee802e.

📒 Files selected for processing (5)
  • packages/react-native-worklets/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp
  • packages/react-native-worklets/Common/cpp/worklets/SharedItems/Synchronizable.cpp
  • packages/react-native-worklets/Common/cpp/worklets/SharedItems/Synchronizable.h
  • packages/react-native-worklets/Common/cpp/worklets/SharedItems/SynchronizableDynamic.cpp
  • packages/react-native-worklets/Common/cpp/worklets/SharedItems/SynchronizableDynamic.h
💤 Files with no reviewable changes (1)
  • packages/react-native-worklets/Common/cpp/worklets/SharedItems/Synchronizable.cpp

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when reading, updating, locking, and unlocking synchronizable values.
    • Added more consistent validation for synchronizable data passed through JavaScript bindings.
    • Preserved existing value checks and synchronization behavior while improving handling of dynamic values.

Walkthrough

Changes

The PR separates the abstract Synchronizable interface from value storage. SynchronizableDynamic now owns the stored Serializable, and JSI bindings create and extract these objects through the updated API.

Synchronizable refactor

Layer / File(s) Summary
Synchronizable contract and dynamic implementation
packages/react-native-worklets/Common/cpp/worklets/SharedItems/Synchronizable.h, packages/react-native-worklets/Common/cpp/worklets/SharedItems/SynchronizableDynamic.*
Synchronizable now defines pure virtual synchronization methods and shared JSI extraction logic. SynchronizableDynamic implements value storage and dirty/blocking access.
JSI proxy integration
packages/react-native-worklets/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp
JSI bindings construct SynchronizableDynamic instances and use Synchronizable::extractSynchronizableOrThrow for synchronizable operations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to fee80

This localized class refactor introduces no evidenced user-facing regression or actionable merge-blocking risk, so it is merge-ready after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant JSIWorkletsModuleProxy
  participant Synchronizable
  participant SynchronizableDynamic
  JSIWorkletsModuleProxy->>SynchronizableDynamic: Create synchronizable value
  JSIWorkletsModuleProxy->>Synchronizable: Extract synchronizable object
  Synchronizable->>SynchronizableDynamic: Dispatch read, write, lock, or unlock
  SynchronizableDynamic-->>JSIWorkletsModuleProxy: Return or update value
Loading

Possibly related PRs

Suggested labels: lib: Worklets

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main refactor: moving shared-pointer storage into a new SynchronizableDynamic subclass.
Description check ✅ Passed The description accurately explains the Synchronizable refactor, the new subclass, preserved behavior, and test coverage.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch @tjzel/worklets/synchronizable-dynamic

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants