Skip to content

Commit

Permalink
fix(worker-plugin): transfer OffscreenCanvas (#2849)
Browse files Browse the repository at this point in the history
Co-authored-by: Arsen Pellumbi <apellumbi@screeningsolution.com>
  • Loading branch information
arsenpellumbi and Arsen Pellumbi committed Mar 25, 2021
1 parent 45388e9 commit 969da47
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/compiler/bundle/worker-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@ const workerMsgId = '${workerMsgId}';
const workerMsgCallbackId = workerMsgId + '.cb';
const getTransferables = (value) => {
if (!!value) {
if (value instanceof ArrayBuffer) {
if (value instanceof ArrayBuffer
|| value instanceof MessagePort
|| value instanceof ImageBitmap
|| value instanceof OffscreenCanvas) {
return [value];
}
if (value.constructor === Object) {
Expand Down Expand Up @@ -345,7 +348,10 @@ export const createWorkerProxy = (worker, workerMsgId, exportedMethod) => (
const postMessage = (w) => (
w.postMessage(
[workerMsgId, pendingId, exportedMethod, args],
args.filter(a => a instanceof ArrayBuffer)
args.filter(a => a instanceof ArrayBuffer
|| a instanceof MessagePort
|| a instanceof ImageBitmap
|| a instanceof OffscreenCanvas)
)
);
if (worker.then) {
Expand Down

0 comments on commit 969da47

Please sign in to comment.