Skip to content

Commit

Permalink
fix(worker-plugin): transfer OffscreenCanvas (ionic-team#2849)
Browse files Browse the repository at this point in the history
Co-authored-by: Arsen Pellumbi <[email protected]>
  • Loading branch information
2 people authored and John Jenkins committed Apr 8, 2021
1 parent ce8fce6 commit 52cc611
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 52cc611

Please sign in to comment.