-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Labels
Description
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.