fix(pointcloud): stop polling /api/splats on Pages after first 404

When the viewer is hosted on a static origin (GitHub Pages, S3) it has
no backend at /api/splats. The default ?backend=auto path was issuing
a fetch every 100 ms, getting a 404, falling back to the demo, and
flooding the console with one 404 per tick. Cosmetic on the surface
but real network/CPU waste over time.

After the first 404 in auto mode, set networkDisabled=true and skip
fetch on subsequent ticks — the interval still fires but goes straight
to pickDemoFrame() so the face mesh / synthetic render path keeps
animating. Remote (?backend=<url>) and live (?live=1) modes keep
retrying so a transient outage doesn't permanently downgrade them.

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
ruv 2026-04-29 20:24:38 -04:00
parent aea9892aed
commit b4c2f7d20b
1 changed files with 10 additions and 1 deletions

View File

@ -461,9 +461,15 @@
return faceMeshFrame() || syntheticFrame();
}
// Once auto mode confirms there is no /api/splats backend on this origin,
// set this flag so we stop hammering the network with 404 fetches every
// tick. Remote (?backend=<url>) and live (?live=1) modes keep retrying so
// a transient outage doesn't permanently downgrade them.
var networkDisabled = false;
async function fetchCloud() {
// Demo-only mode: never hit the network.
if (backendArg === "demo") {
if (backendArg === "demo" || networkDisabled) {
transportMode = "demo";
handleData(pickDemoFrame());
return;
@ -480,6 +486,9 @@
'<span class="demo">&#9679; OFFLINE</span><br>Live backend required (?live=1) but unreachable.<br><span class="label">' + (err && err.message ? err.message : err) + '</span>';
return;
}
// Auto mode + first failure → assume this is a static host (Pages)
// and stop polling. Console stays clean; demo renders locally.
if (backendArg === "auto") networkDisabled = true;
transportMode = "demo";
handleData(pickDemoFrame());
}