fix(ffi): honor derived receivers in native class static allocators - #61
Merged
Conversation
@nativescript/core allocates TypeScript-derived native classes via '_super.new.call(this)' (e.g. NotificationObserver extends NSObject with ObjCExposedMethods). The base wrapper's 'new' and 'alloc' ignored the receiver and always allocated the base Objective-C class, so observers were plain NSObject instances and NSNotificationCenter callouts crashed with '-[NSObject onReceive]: unrecognized selector'. Redirect to the receiver's materialized class wrapper when the receiver is a TypeScript-derived native class constructor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
NathanWalker
marked this pull request as ready for review
August 9, 2026 17:01
DjDeveloperr
approved these changes
Aug 10, 2026
DjDeveloperr
added a commit
that referenced
this pull request
Aug 14, 2026
…regressions Rebase repair for two bugs introduced while re-stacking refactor onto main's upstream fixes: - shared/bridge/Install.mm: the zero-arg branch of the native-class constructable() referenced an undeclared `instance` (ReferenceError at runtime) — the alloc()+init() fallback block was dropped while merging the derived-receiver static-allocator fix (#61) into the constructor path. Restored it. - The Generated Signature Dispatch (GSD) fast paths and the V8/QuickJS/JSC Marshalling.mm fast paths are refactor-only infrastructure that never existed on main, so upstream's "unsigned short returns are always numbers" fix (#55) never reached them: setUInt16/mdTypeUShort still projected printable-ASCII values (32-126) to single-character strings. Made them always return numeric, and added mdTypeUnichar handling (UTF-8 encoded single-character string projection) to the Marshalling.mm slow-ish path used for calls GSD declines to fast-path (mdTypeUnichar is intentionally excluded from GSD's fast-scalar allowlist, so this is the path unichar returns actually take). Found via the macOS TestRunner suite (previously green build masked the regression — check:ffi-boundaries and the build itself don't execute JS).
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.
@nativescript/core allocates TypeScript-derived native classes via
'_super.new.call(this)' (e.g. NotificationObserver extends NSObject with
ObjCExposedMethods). The base wrapper's 'new' and 'alloc' ignored the
receiver and always allocated the base Objective-C class, so observers were
plain NSObject instances and NSNotificationCenter callouts crashed with
'-[NSObject onReceive]: unrecognized selector'. Redirect to the receiver's
materialized class wrapper when the receiver is a TypeScript-derived native
class constructor.
Found while bringing @nativescript/core up on the ios-quickjs runtime flavor. All fixes in this series were validated together on the iOS 26.5 simulator using a SolidJS + dominative app boots, renders, and runs stably with all of them applied.
🤖 Generated with Claude Code