Skip to content

Commit 969da47

Browse files
arsenpellumbiArsen Pellumbi
and
Arsen Pellumbi
authored
fix(worker-plugin): transfer OffscreenCanvas (#2849)
Co-authored-by: Arsen Pellumbi <apellumbi@screeningsolution.com>
1 parent 45388e9 commit 969da47

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/compiler/bundle/worker-plugin.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ const workerMsgId = '${workerMsgId}';
201201
const workerMsgCallbackId = workerMsgId + '.cb';
202202
const getTransferables = (value) => {
203203
if (!!value) {
204-
if (value instanceof ArrayBuffer) {
204+
if (value instanceof ArrayBuffer
205+
|| value instanceof MessagePort
206+
|| value instanceof ImageBitmap
207+
|| value instanceof OffscreenCanvas) {
205208
return [value];
206209
}
207210
if (value.constructor === Object) {
@@ -345,7 +348,10 @@ export const createWorkerProxy = (worker, workerMsgId, exportedMethod) => (
345348
const postMessage = (w) => (
346349
w.postMessage(
347350
[workerMsgId, pendingId, exportedMethod, args],
348-
args.filter(a => a instanceof ArrayBuffer)
351+
args.filter(a => a instanceof ArrayBuffer
352+
|| a instanceof MessagePort
353+
|| a instanceof ImageBitmap
354+
|| a instanceof OffscreenCanvas)
349355
)
350356
);
351357
if (worker.then) {

0 commit comments

Comments
 (0)