Windows packaged app shows only `Asset not found`: bundled frontend assets resolve against the process cwd, not the artifact
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- zig
- Ambito
- desktop
Direzione di ricerca
Read src/platform/windows/webview2_host.cpp around assetFilePath and compare its asset resolution with the root_path handling described for macOS and Linux in platform/macos/root.zig and platform/linux/root.zig. Then trace how the packaged artifact sets the asset root in src/tooling/package.zig. Done means a Windows package finds and renders its bundled frontend when launched from bin/, with the existing package layout intact.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
@native-sdk/cli0.11.1, Windows 11, Zig 0.16.0app.jsonhas"frontend": { "dist": "frontend/dist", "entry": "index.html", "spa_fallback": true },"capabilities": ["webview"],"web_engine": "system"
Steps
native build shelltest --yes
native package --target windows --manifest app.json --assets frontend/dist \
--output zig-out/package/win --binary zig-out/bin/shelltest.exe \
--web-engine system --web-layer include
Packaging reports success:
info[package.created]: created windows artifact at zig-out/package/win
web layer: webview2 (declared: .frontend)
subsystem: gui
The artifact is laid out as:
win/
bin/shelltest.exe
bin/WebView2Loader.dll
resources/frontend/dist/index.html
resources/frontend/dist/asset-manifest.zon
Expected — per /docs/packaging: "Production packages serve these through zero://app/, so paths like /assets/app.js work without file:// URLs", and native build + native package is described as "the complete path from source to distributable". Double-clicking bin/shelltest.exe should render index.html.
Actual — the window opens with a single line of body text:
Asset not found
That string comes from the Windows scheme handler's 404 branch
(src/platform/windows/webview2_host.cpp:5244,
return textWebResourceResponse(environment, 404, L"Not Found", "Asset not found")),
i.e. the file lookup failed rather than the document being empty. There is no console
error, no dialog, and no hint about which path was tried. Note that the runtime log line
webview.load ... kind="assets" bytes=10 is printed on both the working and the
failing run (it reports the asset id length, not the payload), so it is not a signal.
Why
The packaged assets live at <output>/resources/<frontend.dist>:
// src/tooling/package.zig:503,765
const assets_output = try assetOutputPath(allocator, options.output_path, "resources", options);
// -> <output>/resources/<frontend.dist>
But on Windows the webview resolves an asset URL by concatenating the manifest's
dist string onto the process working directory:
// src/platform/windows/webview2_host.cpp:1128
static std::wstring assetFilePath(const ChildWebView &webview, const std::string &relative) {
std::string path = webview.asset_root.empty() ? std::string(".") : webview.asset_root;
...
path += native_relative; // "frontend/dist" + relative, relative to cwd
asset_root is the literal frontend/dist baked in by
frontend.productionSource(.{ .dist = "frontend/dist" }) — it is never rebased onto the
artifact directory. On macOS and Linux the platform layer receives root_path
(platform/macos/root.zig:1388, platform/linux/root.zig:770) and is described in the
docs as resolving "against Contents/Resources", so the package layout and the resolver
agree there. On Windows they do not: when the app is launched by double-click, the cwd is
bin/, so <cwd>/frontend/dist/index.html does not exist.
Controlled experiment (same binary, no rebuild)
| setup | cwd | result |
|---|---|---|
as packaged (resources/frontend/dist) |
bin/ |
body text Asset not found (404 from the scheme handler) |
resources/frontend/dist copied to bin/frontend/dist |
bin/ |
renders normally |
Same binary, same working directory, same command — only the asset location changed.
Nothing else changed, so the missing piece is the app-relative resolution.
Note on the obvious workaround
Computing an absolute asset_root from the executable directory in Zig is not a one-liner
on 0.16: std.fs.selfExePath* no longer exists (grep -rn selfExe zig/lib/std returns
nothing; path handling moved to std.Io.Dir). Users have no supported way to fix this
from application code, which is why the cwd-relative lookup matters.
Expected fix
Resolve asset_root against the artifact/executable directory on Windows (mirroring
macOS/Linux), so the default build + package output works when double-clicked.
- Lingua principale
- Zig
- Stelle
- 7.9k
- Fork
- 335
- Merge medio
- 10h 33m
- PR unite (30g)
- 147
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/native
-
Per-view widget layout budget (1024 nodes) drops whole frames on real multi-pane app viewsForse già presa @slicenferqin l’ha presa 100 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
vercel-labs/native#408 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
vercel-labs/native#387 ·
I maintainer di solito rispondono entro 1 giorno
-
macOS: the window frame event reports the frame size where everything else expects the content sizeAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
vercel-labs/native#355 ·
I maintainer di solito rispondono entro 1 giorno
-
cef.zig: InstallResult.archive_path leaks on successForse già presa @versecafe l’ha presa 206 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
vercel-labs/native#32 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
vercel-labs/native#957 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/native
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
GUI: the space panel stays stale after a run stops with no spaceForse già presa @nikkexe0-del l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
xevrion/hatchzip#237 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
flathub/org.ardour.Ardour#89 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Javis603/token-monitor#1861 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno