T47 Ship: a gallery whose wasm fetch fails retries, then tells the host; the host shows it at once and waits a minute for a slow start
This commit is contained in:
4 files changed
+42
-4
No files matched your search
@@ -45,7 +45,20 @@
|
||||
addEventListener("message", ({ data }) => {
|
||||
if (data && data.ely === "theme") setTheme(data.theme);
|
||||
});
|
||||
await init();
|
||||
// Frames that fetch the wasm at once can fail one; the next try finds it cached.
|
||||
for (let attempt = 1; ; attempt++) {
|
||||
try {
|
||||
await init();
|
||||
break;
|
||||
} catch (error) {
|
||||
console.warn(`gallery: start failed, try ${attempt}`, error);
|
||||
if (attempt === 3) {
|
||||
window.parent.postMessage({ ely: "failed", error: String(error) }, "*");
|
||||
throw error;
|
||||
}
|
||||
await new Promise((wake) => setTimeout(wake, 1000 * attempt));
|
||||
}
|
||||
}
|
||||
apply = set_theme;
|
||||
if (early) set_theme(early);
|
||||
// Tells the host that a mode it sends now lands.
|
||||
|
||||
Reference in new issue
Block a user