diff --git a/html5/js/DecodeWorker.js b/html5/js/DecodeWorker.js index 2ee30fd9..62ace68e 100644 --- a/html5/js/DecodeWorker.js +++ b/html5/js/DecodeWorker.js @@ -138,13 +138,59 @@ function decode_draw_packet(packet) { self.postMessage({'error': msg, 'packet' : packet}); } + function hold() { + //we're loading asynchronously + //so ensure that any packet sequence arriving after this one will be put on hold + //until we have finished decoding this one: + let wid_hold = on_hold.get(wid); + if (!wid_hold) { + wid_hold = new Map(); + on_hold.set(wid, wid_hold); + } + //console.log("holding=", packet_sequence); + wid_hold.set(packet_sequence, []); + return wid_hold; + } + + function release() { + let wid_hold = on_hold.get(wid); + if (!wid_hold) { + //could have been cancelled by EOS + return; + } + //release any packets held back by this image: + const held = wid_hold.get(packet_sequence); + //console.log("release held=", held); + if (!held) { + //could have been cancelled by EOS + return; + } + let i; + for (i=0; i