Skip to content

feat: RN TurboModule -- threading + Fabric integration, rebuilt (supersedes #46) - #72

Open
DjDeveloperr wants to merge 1 commit into
refactorfrom
rn-turbomodule
Open

feat: RN TurboModule -- threading + Fabric integration, rebuilt (supersedes #46)#72
DjDeveloperr wants to merge 1 commit into
refactorfrom
rn-turbomodule

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Collaborator

What this is

Threading + Fabric integration for the RN TurboModule, rebuilt from scratch after the owner rejected #46's architecture (see DECISIONS.md/ARCHITECTURE.md). installWorkletRuntime puts the real NativeScript interop bridge on the worklets UI runtime, so a "worklet" hook calls UIKit directly with zero JSON/RPC round-trip. The UI runtime is main-queue-scheduled but not thread-affine — runOnUISync is banned, only async crossings allowed — so the UI/JS-thread deadlock is unconstructible rather than merely gated.

API shape

One call whose hook names ARE the Fabric ObjC lifecycle names; bodies are worklets:

export const Screen = defineNativeComponent<ScreenProps, ScreenEvents, ScreenInstance>({
  name: "NSScreen",
  props: { activityState: 2, stackPresentation: "push", title: "" },
  events: ["onAppear", "onDisappear", "onDismissed"],
  create(ctx) {
    "worklet";
    const vc = (globalThis as any).UIViewController.alloc().init();
    vc.view = ctx.view;
    ctx.instance.controller = vc;
  },
  updateProps(ctx, next) {
    "worklet";
    if (next.title) ctx.instance.controller.navigationItem.title = next.title;
  },
});

Proof + line counts

packages/react-native-screens/src/index.ts is a full UINavigationController native stack (push/pop/modal, header config, transitionCoordinator-gated reconciliation) in 458 lines, zero native code — vs. a 16,029-line NativeScriptScreenStack.tsx for the same surface in the rejected #46.

  • Module (TS surface + native Fabric glue): 2,329 + 2,058 = 4,387 lines.
  • Net diff vs refactor across both packages: 44 files, +3,366/-4,553.
  • Whole-branch diff vs refactor: 55 files, +4,698/-4,561.
  • feat: add React Native UIKit runtime primitives #46 for comparison: +16,263 insertions over 46 files.

What was deleted

The process-wide UIView/RCTViewComponentView method swizzle (NativeScriptUIView.mm), NativeScriptUIViewManager.mm, NativeScriptUIViewComponentView.{mm,h}, NativeScriptUIKitHost.h, installIdleAwareWorkletsFrameLoop, BatchOps.mm and its walkers, nativeCommitObservations/nativeHandleAuthority, the point-fix RPCs, and the old defineUIKitView/defineUIKitContainer/defineUIViewController surface with its registries. Grepped clean — nothing references any of it.

Known caveat

UIViewControllerTransitionCoordinator's completion block is declared solely on a protocol; the metadata resolver only walks the concrete class hierarchy, so that one call site needs interop.Block(fn, "v@?@") instead of a bare closure (see reconcileStack in the screens consumer). Class-declared completions (presentViewController:animated:completion:) already work with a bare closure. #71 fixes this at the runtime level; until it lands, protocol-declared completion params need interop.Block.

Supersedes #46.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 66cc7feb-b44e-4089-8e27-ab7f89f40faa

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

DjDeveloperr added a commit that referenced this pull request Aug 20, 2026
Matches @nativescript/react-native's existing peerDependenciesMeta
convention. Without it, npm's auto-peer-install for
@nativescript/react-native-screens pulled in react-native-worklets@0.11.4
(peer react-native 0.83-0.86), conflicting with the workspace's real
react-native@0.79.5 (pinned transitively via react-native-node-api) and
breaking `npm install` at the repo root -- this is what CI's build job
runs, and it failed on PR #72 for exactly this reason.
DjDeveloperr added a commit that referenced this pull request Aug 20, 2026
Matches @nativescript/react-native's existing peerDependenciesMeta
convention. Without it, npm's auto-peer-install for
@nativescript/react-native-screens pulled in react-native-worklets@0.11.4
(peer react-native 0.83-0.86), conflicting with the workspace's real
react-native@0.79.5 (pinned transitively via react-native-node-api) and
breaking `npm install` at the repo root -- this is what CI's build job
runs, and it failed on PR #72 for exactly this reason.
@DjDeveloperr
DjDeveloperr force-pushed the rn-turbomodule branch 2 times, most recently from c2edfcc to 39d1565 Compare August 20, 2026 04:43
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.

1 participant