From dcc3274727454e192151fd7e7c4cd8b9ad410f13 Mon Sep 17 00:00:00 2001 From: SlothScript <106759481+SlothScript@users.noreply.github.com> Date: Mon, 10 Aug 2026 15:02:27 -0500 Subject: [PATCH] Fix deadlock when loading --- index.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 45d3b94..190f1f3 100644 --- a/index.html +++ b/index.html @@ -167,13 +167,11 @@ if (entry.comp === 0) { imgData = new Blob([compressed]); } else if (entry.comp === 8) { - const ds = new DecompressionStream('deflate-raw'), writer = ds.writable.getWriter(); + const ds = new DecompressionStream('deflate-raw'), writer = ds.writable.getWriter(), reader = ds.readable.getReader(), chunks = []; + const drain = (async () => { while (true) { const {value, done} = await reader.read(); if (done) break; chunks.push(value); } })(); await writer.write(compressed); await writer.close(); - const reader = ds.readable.getReader(), chunks = []; - while (true) { const {value, done} = await reader.read(); if (done) break; chunks.push(value); } - const result = new Uint8Array(entry.usize); let pos = 0; - for (const chunk of chunks) { result.set(chunk, pos); pos += chunk.length; } - imgData = new Blob([result]); + await drain; + imgData = new Blob(chunks); } else continue; const imgUrl = URL.createObjectURL(imgData); const img = document.createElement('img');