Sandbox: Exclude transferable objects from near membrane proxy unboxing (#115016)
* Fixing so geomap works with sandbox * Will not try to unbox transferable instances.
This commit is contained in:
@@ -78,11 +78,36 @@ export function unboxNearMembraneProxies(structure: unknown): unknown {
|
||||
if (Array.isArray(structure)) {
|
||||
return structure.map(unboxNearMembraneProxies);
|
||||
}
|
||||
|
||||
if (isTransferable(structure)) {
|
||||
return structure;
|
||||
}
|
||||
|
||||
if (typeof structure === 'object') {
|
||||
return Object.keys(structure).reduce((acc, key) => {
|
||||
Reflect.set(acc, key, unboxNearMembraneProxies(Reflect.get(structure, key)));
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
return structure;
|
||||
}
|
||||
|
||||
function isTransferable(structure: unknown): structure is Transferable {
|
||||
// We should probably add all of the transferable types here.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects
|
||||
return (
|
||||
structure instanceof ArrayBuffer ||
|
||||
structure instanceof OffscreenCanvas ||
|
||||
structure instanceof ImageBitmap ||
|
||||
structure instanceof MessagePort ||
|
||||
structure instanceof MediaSourceHandle ||
|
||||
structure instanceof ReadableStream ||
|
||||
structure instanceof WritableStream ||
|
||||
structure instanceof TransformStream ||
|
||||
structure instanceof AudioData ||
|
||||
structure instanceof VideoFrame ||
|
||||
structure instanceof RTCDataChannel ||
|
||||
structure instanceof ArrayBuffer
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user