Repository navigation
feat(ffi/objc): add __releaseNativeCounterpart to the Node-API bridge - #113
Open
NathanWalker wants to merge 1 commit into
Open
NathanWalker wants to merge 1 commit into
NathanWalker wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
ammarahm-ed
force-pushed
the
android-react-native
branch
2 times, most recently
from
November 8, 2026 12:59
4f87f05 to
9633aba
Compare
Expose the global __releaseNativeCounterpart(obj) used by the Android runtimes so plugins can release a native object eagerly with the same call on both platforms. It is registered from nativescript_init, so both the engine builds using the napi FFI backend and the plain Node-API runtime get it. Behaviour: - exactly one argument, otherwise throws 'Actual arguments count: "N". Expected: "1".' - anything that is not a live native object wrapper throws '<value> is an object which is not a native wrapper.' - releasing an already released wrapper is a no-op - returns undefined The wrapper is detached from the bridge caches, its wrap (and the wrap of the array proxy target) and native pointer are removed so later use throws instead of reaching freed memory, and the bridge's retain is dropped. The unwrapped pointer is only treated as an id once objectRefs maps it to this exact wrapper, so pointers, references and class constructors are rejected without being dereferenced.
NathanWalker
force-pushed
the
feat/napi-release-native-counterpart
branch
from
November 20, 2026 21:24
ab8965e to
4592e4c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #103 (part 4), renamed and aligned with Android as requested in review.
Summary
Adds the global
__releaseNativeCounterpart(obj)to the Objective-C Node-API bridge, matching Android's name and behavior, so plugins can call one thing on both platforms. It replaces #103'sinterop.releaseNativeObject, so there's only one public name.undefined, like Android.ApiTests.jscases (from the old iOS runtime) expect. Android uses different wording for the same cases.nativescript_init, so both the plain Node-API runtime and engine builds that use the napi bridge get it. Typings inpackages/objc-node-api/index.d.ts.Evidence
MACOS_TEST_FFI_BACKEND=napi npm run test:macos: tests=719, failures=0, errors=0, skipped=12. All 8__releaseNativeCounterparttests run and pass (5 existing, now no longerpending, plus 3 new: use after release throws, a second release is a no-op, a JS-defined instance held by anNSMutableArraykeeps working).npm run test:macos(V8 bridge): tests=719, failures=0, errors=0, skipped=13. The V8 bridge doesn't define the global yet, so the release tests staypendingthere.NSMutableArray/NSObjectthrows, every invalid input throws, and 2000 allocate/release cycles followed bygc()finish without a crash.Merge Danger
Door: one-way (new public API)
Blast Radius: Objective-C napi bridge, new global only. Existing code paths are unchanged.