diff --git a/wasm/app/app.js b/wasm/app/app.js index 2c61f8a..1f9d71e 100644 --- a/wasm/app/app.js +++ b/wasm/app/app.js @@ -263,7 +263,14 @@ function startLiveBlock(tierName) { outputEl.appendChild(block); return { append(chunk) { - pre.textContent += chunk; + // Append a TextNode rather than `pre.textContent += chunk` + // — the latter re-reads + restringifies + re-sets all + // existing children on every chunk, which under a fast + // C-tier loop (one chunk per (newline) printf) was + // dropping line breaks and rendering "tick 0tick 10000…" + // horizontally instead of stacking vertically. TextNode + // append preserves every byte verbatim. + pre.appendChild(document.createTextNode(chunk)); outputEl.scrollTop = outputEl.scrollHeight; }, finalize(elapsedMs, kind, fullOutput) { diff --git a/www/playground/app.js b/www/playground/app.js index 2c61f8a..1f9d71e 100644 --- a/www/playground/app.js +++ b/www/playground/app.js @@ -263,7 +263,14 @@ function startLiveBlock(tierName) { outputEl.appendChild(block); return { append(chunk) { - pre.textContent += chunk; + // Append a TextNode rather than `pre.textContent += chunk` + // — the latter re-reads + restringifies + re-sets all + // existing children on every chunk, which under a fast + // C-tier loop (one chunk per (newline) printf) was + // dropping line breaks and rendering "tick 0tick 10000…" + // horizontally instead of stacking vertically. TextNode + // append preserves every byte verbatim. + pre.appendChild(document.createTextNode(chunk)); outputEl.scrollTop = outputEl.scrollHeight; }, finalize(elapsedMs, kind, fullOutput) {