chiark / gitweb /
wasm/js/emscripten: Fix page loading race for-sgt-race
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 22 Apr 2021 18:20:32 +0000 (19:20 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 22 Apr 2021 20:23:47 +0000 (21:23 +0100)
commite41b47a9a1ed058ed209b1b5a1f412b74ac4a99a
tree1f5d0dd32cc71e20d67c44033b23e38726af64d7
parent56ef86f92b77412bfe27d7206d25b323475e71fe
wasm/js/emscripten: Fix page loading race

Using a stunt webserver which artificially introduces a 3s delay just
before the last line of the HTML output, I have reproduced a
uwer-reported loading/startup race bug:

Previously the wasm loading was started by the <script> element,
synchronously. If the wasm loading is fast, and finishes before the
HTML loading, the onRuntimeInitialized event may occur before
initPuzzles.  But initPuzzles sets up the event handler.

Fix this bug, and introduce a new comment containing an argument for
the correctness of the new approach.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cmake/platforms/emscripten.cmake
emccpost.js [new file with mode: 0644]
emccpre.js
html/jspage.pl