Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement Transferable for OffscreenCanvas #24276
Open
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spec:
OffscreenCanvas: https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface:transferable-objectsA first implementation of
Transferableis currently being done as part of #23637, and that PR introduces a trait and some plumbing instructuredcloneto facilitate this.Implementing this for
OffscreenCanvasis likely to involve splitting up the DOM object from some transferable data backing it, as is being done for messageport in the form ofMessagePortandMessagePortImpl, with the latter being a non-DOM managed object that is serde serializable, making the transfer across realms basically involve sending theMessagePortImplinside an IPC message, with some minimal integration with theJS_ReadStructuredCloneandJS_WriteStructuredCloneSpiderMonkey operations.Note that the non-DOM managed object doesn't have to be serialiable, and in the case of
OffscreenCanvasit probably doesn't have to be since the use case is transferring into a dedicated worker, which will by definition be in the same-process as the window event-loop where the canvas is found. So in such case it would only have to beSend, and basically be moved into the worker realm via a threaded message(We implement the implicit port of dedicated worker as a "normal" threaded channel, not an actualMessagePort).