Open Bug 1956441 Opened 1 month ago Updated 1 month ago

Investigate using structuredClone in worker-transport.js

Categories

(DevTools :: Framework, task)

task

Tracking

(Not tracked)

People

(Reporter: nchevobbe, Unassigned)

References

Details

In worker transport, we're using JSON serialization to pass packets, which can potentially cause trouble if said packet isn't serializable (see Bug 1956197).

https://searchfox.org/mozilla-release/rev/62f34235d373482fc8c3c6a07f3a60c3e224d642/devtools/shared/transport/worker-transport.js#38-46,52-53,59

send(packet) {
  this._dbg.postMessage(
    JSON.stringify({
      type: "message",
      id: this._id,
      message: packet,
    })
  );
}
...
_onMessage(message) {
  const packet = JSON.parse(message);
...
}

We should investigate if we could switch to structuredClone instead, so it would be more robust (and performant)

We're actually using WorkerDebugger#postMessage , not the regular worker global one, which means passing an actual object isn't supported: https://searchfox.org/mozilla-release/rev/8363c885d2a47e07f741e89d1bc12066b4b751a6/dom/workers/nsIWorkerDebugger.idl#57

You need to log in before you can comment on or make changes to this bug.