Launcher: fix broken app and widget icons

The WebView requests a screenful of icons at once on several threads,
and loading and drawing icon drawables concurrently failed for that first
batch (and for every widget icon). Icons are now drawn one at a time
under a lock from a mutated drawable, widget icons fall back to the app
icon, and failures are logged under the "ultra" tag. The page retries a
failed icon twice and then shows a blank disc instead of a broken image.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EEjkJVV72Lu8ndDVWg5BT
This commit is contained in:
Claude committed 2026-10-21 18:43:08 +00:00
1 parent 3ed5afbafc
commit 70fc005e90
3 files changed
+68 -11

No files matched your search

+15
View File
@@ -81,6 +81,21 @@
widgetMenu: (id) => app.dispatch(WIDGET_MENU, id),
place: () => { placed = ""; place(); },
};
// An icon that fails to load is retried twice with backoff, then drawn as a blank
// disc instead of the browser's broken-image box.
document.addEventListener("error", (e) => {
const img = e.target;
if (!(img instanceof HTMLImageElement) || !img.classList.contains("icon")) return;
const n = (img.__retries = (img.__retries || 0) + 1);
if (n > 2) { img.classList.add("missing"); return; }
setTimeout(() => {
const base = img.getAttribute("src").replace(/[?&]retry=\d+$/, "");
img.src = base + (base.includes("?") ? "&" : "?") + "retry=" + n;
}, 300 * n);
}, true);
document.addEventListener("load", (e) => {
if (e.target instanceof HTMLImageElement) e.target.classList.remove("missing");
}, true);
document.addEventListener("visibilitychange", () => { if (!document.hidden) window.ultraHome.tick(); });
addEventListener("scroll", () => requestAnimationFrame(place), { passive: true });
addEventListener("resize", () => requestAnimationFrame(place));
+1
View File
@@ -34,6 +34,7 @@ body { margin: 0; min-height: 100vh; color: #fff; -webkit-tap-highlight-color: t
.tile:active { background: rgb(255 255 255 / .12); }
.icon { width: 3.25rem; height: 3.25rem; object-fit: contain; pointer-events: none;
filter: drop-shadow(0 2px 4px rgb(0 0 0 / .3)); }
.icon.missing { border-radius: 999px; background: rgb(255 255 255 / .18); object-position: -999px 0; }
.name { max-width: 100%; font-size: .75rem; line-height: 1.2; text-align: center;
text-shadow: var(--shadow-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }