GeezerVison is showing github.com — checkZFT probes every marker with a synchronous GET: console 404s, main-thread block, double download · Issue #676 · webarkit/jsartoolkitNFT
checkZFT probes every marker with a synchronous GET: console 404s, main-thread block, double download #676DescriptionProblem
addNFTMarkers() probes every marker for a compressed .zft descriptor before loading it
(src/ARToolkitNFT.ts,
introduced with #403):
let type = Utils.checkZFT(element + ".zft");
and Utils.checkZFT is a synchronous full GET
(src/Utils.ts):
static checkZFT(url: string): boolean {
const request = new XMLHttpRequest();
request.open("GET", url, false); // `false` makes the request synchronous
request.send(null);
...
}
This has three costs:
- A console error per marker without a
.zft, which is the common case. The browser logs
every failed request as an error, so an app loading two ordinary descriptor sets starts with
two red Failed to load resource: 404 (Not Found) lines, even though both markers load fine.
Users report these as bugs; Aframe-nft now has to explain them in its README.
- It blocks the main thread. A synchronous XHR stops rendering and input for a full round
trip, once per marker. Browsers also deprecate synchronous XHR on the main thread. It hurts
most when markers are loaded at runtime, which is now common since loading across calls
landed in 1.13.0 (addNFTMarkers cannot be called more than once — duplicate ids, surfaceSet overwrite, KPM dataset replaced #612, fix: let addNFTMarkers load markers across calls #666).
- A
.zft is downloaded twice. When it exists, the probe downloads the whole file, then
ajax() downloads it again to actually load it.
Suggested fix
In order of preference:
- Let the URL decide, no probe. Treat a URL that ends in
.zft as a compressed descriptor
and load it directly. Otherwise load .fset / .iset / .fset3 as today. This is explicit,
costs no extra request and logs no 404. Apps that currently rely on auto-detection would pass
"…/pinball.zft" instead of "…/pinball", so this is a behaviour change worth a note in the
release.
- Keep auto-detection, but probe asynchronously with
HEAD. Use
fetch(url, { method: "HEAD" }), continue in its promise and fall back on 404. This removes
the main-thread block and the double download. One 404 per marker without a .zft would still
be logged.
- Make the probe opt-out. For example, an option on
loadNFTMarker / loadNFTMarkers to
skip it when the caller knows no .zft exists.
Option 1 could also accept option 2's auto-detection as a fallback for URLs without an
extension, keeping backward compatibility while new code gets the explicit path.
Seen in
Aframe-nft loads two targets (pinball, kuva) with
1.13.0. The console shows two 404s from checkZFT, then both markers load:
ARToolkitNFT.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
checkZFT @ ARToolkitNFT.js:1
ARToolkitNFT.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
checkZFT @ ARToolkitNFT.js:1
ℹ️[webarkit-info:]add NFT marker-> '/markerNFT_0'
Activitykalwalt commented on Oct 5, 2026 Tracked/addressed as part of #685 kalwalt commented on Oct 27, 2026 One more case for the .zft probe, raised by the Qodo review of #748 and moved here since it is in the shared loader, not the tracker facade:
An HTTP 200 that is not a .zft is taken for one. In ARToolkitNFTBase.loadMarkerSource, the probe's res.ok goes straight to storeZFT. A server with an SPA fallback (Vite preview, Netlify / Vercel rewrites, historyApiFallback) answers GET <marker>.zft with 200 and its index.html. The decompression then fails and the marker is reported as format, instead of falling back to the .fset / .iset / .fset3 files that exist.
Suggested fix, in the probe branch only (an explicit .zft URL should keep failing as format):
- before
storeZFT, check the first bytes of the body against the header the zft writer produces (to be confirmed in WebARKitLib's zft compression code);
- on a mismatch, treat the response as "no
.zft" and fall back to the three files, as for an HTTP error status (D6).
The Content-Type is not a reliable check: many servers send application/octet-stream, or nothing, for a real .zft.
Meanwhile #748 adds probeZFT to the tracker's addNFTTargets options (default true, as addNFTMarkers), so the facade can skip the probe as well.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|