Repository navigation
fix(ffi/objc): map metadata classes from frameworks loaded after init - #114
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
Metadata classes whose image is not loaded when the class globals are registered (e.g. ScreenCaptureKit's SCWindow in a plain Node process) never entered mdClassesByPointer, so their instances were wrapped as NSObject. Keep those classes in a pending list and bump a process-wide generation counter from an objc_addLoadImageFunc callback. On a mdClassesByPointer miss, the pending list is re-resolved on the JS thread only if an image has loaded since the last pass, so hits stay a single map lookup and misses add one atomic load.
NathanWalker
force-pushed
the
fix/objc-lazy-framework-class-lookup
branch
from
November 20, 2026 21:24
e4167f7 to
7649802
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 5), reworked to keep lookups off the hot path as requested in review.
Summary
When class globals are registered,
objc_getClassreturns nil for classes in frameworks that aren't loaded yet (e.g. ScreenCaptureKit'sSCWindowin a plain Node process). Those classes never enteredmdClassesByPointer, so anSCWindowinstance wrapped asNSObjectwith every propertyundefined.mdClassesByPointer.find(cls).__NSCFStringat each superclass level) cost an empty check plus one atomic load and compare. No string allocation and no name lookup, unlike fix(ffi/objc): forward off-thread method and function callbacks to the JS thread #103's version.SCWindows.objc_addLoadImageFuncis available from macOS 10.15 / iOS 13, at or below the deployment targets.Evidence
Node v26.10.0, plain Node-API build, macOS 26.6.2 (arm64):
SCShareableContentwindows,SCWindowtouched only viawindows.objectAtIndex(0)NSObject,windowID/title/owningApplicationallundefinedSCWindow, realwindowIDandowningApplicationobjc.importafter init;valueForKey("defaultConfiguration")on the shared picker (untypedid)NSObject, propertiesundefinedSCContentSharingPickerConfiguration, real property valuesMACOS_TEST_FFI_BACKEND=napi npm run test:macos: tests=716, failures=0, errors=0, skipped=17npm run test:macos: tests=716, failures=0, errors=0, skipped=10Merge Danger
Door: two-way
Blast Radius: object wrapping in the Objective-C napi bridge. Instances of classes from frameworks loaded after init now wrap as their real class instead of a superclass.