Blob/URL: identify Blobs by our own constructor; make URL's static methods writable (WebIDL) - #251
Open
matthargett wants to merge 5 commits into
Open
matthargett wants to merge 5 commits into
matthargett wants to merge 5 commits into
Conversation
…thods writable
Blob::TryGetData compared an object's prototype chain against whatever
the global `Blob` binding held at call time. A script that replaces the
global Blob with its own class (BabylonNative's validation harness does,
for image loading) made every instance of that class look like one of
ours, and Unwrap on an object that wraps nothing threw a bare "Invalid
argument" out of URL.createObjectURL -- while a real Blob was rejected
as "not a Blob". The constructor is now kept on the runtime's native
object at Initialize and identity is checked against that; a null
Unwrap yields "not a Blob" like any other foreign object.
The same harness assigns its own URL.createObjectURL. napi_default
makes static methods read-only, so that assignment failed silently and
the native method kept receiving the foreign Blob. WebIDL static
operations are writable, enumerable and configurable; declare the URL
statics that way.
Found by the SOG Gaussian-splat scenes of BabylonNative's Dawn
validation catalog ("Failed to parse SOG zip data", cause "Invalid
argument"); they pass again with this change. Regression tests cover
both halves.
matthargett
added a commit
to rebeckerspecialties/JsRuntimeHost
that referenced
this pull request
Sep 17, 2026
Author
|
Twin caught a test-only issue on Win32_x86_Chakra: ChakraCore has no |
…look-alike rejection by message
…ime native object (workers have no JsRuntime)
matthargett
added a commit
to rebeckerspecialties/JsRuntimeHost
that referenced
this pull request
Sep 17, 2026
…look-alike rejection by message (from BabylonJS#251)
Author
|
cc @CedricGuillemet since this is another issue blocking splats on WebGPU in BN |
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.
Problem
Blob::TryGetData(behindURL.createObjectURL) decided whether an object is one of our Blobs by walking its prototype chain against the current globalBlob. A page or harness that installs its ownBlobclass — BabylonNative's Dawn validation harness does, for image loading — then made every instance of that class pass the check, andObjectWrap::Unwrapon an object that wraps nothing threw a bareError: Invalid argumentout ofcreateObjectURL; meanwhile a genuine native Blob was rejected as "not a Blob".The same harness assigns its own
URL.createObjectURL. Node-API'snapi_defaultmakes static methods read-only, so that assignment failed silently and the native method kept receiving the foreign Blob. In browsers WebIDL static operations are writable/enumerable/configurable, so the override would have worked.Symptom in the wild: the three SOG Gaussian-splat scenes (and "Iridescence NME") of the Dawn validation catalog failing with
Unable to load … .sog: Failed to parse SOG zip data.whosecauseisInvalid argument.Change
Initializeand identify instances against that; a nullUnwrapyieldsnullopt(→ the existingTypeError: … argument is not a Blob).URLstatics (canParse,parse,createObjectURL,revokeObjectURL) withnapi_writable | napi_enumerable | napi_configurable, matching WebIDL.URL.createObjectURLsuite (both fail on main: the real Blob is rejected / the assignment is silently ignored).Verified on macOS (JavaScriptCore): JavaScript suite green,
UnitTests23/23; the four Playground scenes above pass again on the BabylonNative fork with this build. Fork twin: rebeckerspecialties#35.