diff --git a/Player/avc-worker.js b/Player/avc-worker.js index 6213b58..d412532 100644 --- a/Player/avc-worker.js +++ b/Player/avc-worker.js @@ -17,6 +17,11 @@ avc.onPictureDecoded = function (buffer, width, height) { if (config && config.sendBufferOnPictureDecoded !== undefined) { buffer = config.sendBufferOnPictureDecoded ? buffer : null; } + // 'buffer' is a view of a large ArrayBuffer. Only clone the portion in the + // view. + if (buffer) { + buffer = Uint8Array(buffer); + } socket.sendMessage("on-picture-decoded", {picture: buffer, width: width, height: height}); } diff --git a/Player/mp4.js b/Player/mp4.js index 79a5ef0..df4770c 100644 --- a/Player/mp4.js +++ b/Player/mp4.js @@ -866,7 +866,9 @@ var MP4Player = (function reader() { if (this.useWorkers) { var avcWorker = this.avcWorker; video.getSampleNALUnits(pic).forEach(function (nal) { - avcWorker.sendMessage("decode-sample", nal); + // Copy the sample so that we only do a structured clone of the + // region of interest + avcWorker.sendMessage("decode-sample", Uint8Array(nal)); }); } else { var avc = this.avc;