Skip to content

TextDecoder sometimes fails when used through an iframe #15217

Open
@wffurr

Description

@wffurr

String types via embind sometimes fail with:

Failed to execute 'decode' on 'TextDecoder': The provided ArrayBufferView value must not be shared."

When the embind functions are called through an iframe. The instanceof check in TextDecoderWrapper fails when the object is from an iframe, which is a separate JavaScript realm.

This is a known problem with instanceof checks and iframes:

https://www.oreilly.com/library/view/speaking-javascript/9781449365028/ch17.html#cross-realm_instanceof
https://jakearchibald.com/2017/arrays-symbols-realms/#multiple-realms
https://esdiscuss.org/topic/cross-global-instanceof

For built-ins, the only real workaround is checking foo.constructor.name -> ArrayBuffer or Object.getPrototypeOf(foo).toString() -> [object ArrayBuffer].

This should work in all WebAssembly-supporting browsers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions