Skip to content

fix(desktop): repair webview and raw backends on Windows (laufey v0.4.1) - #35566

Merged
littledivy merged 4 commits into
mainfrom
orch/divybot-610
Jun 27, 2026
Merged

littledivy merged 4 commits into
mainfrom
orch/divybot-610

Conversation

@divybot

@divybot divybot commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes deno desktop on Windows, where the webview and raw backends were broken (cef worked). The root cause was in the laufey native backend runtime (littledivy/laufey); this PR consumes the fixed laufey v0.4.1 and adds a Windows dev-workflow fix.

The two laufey bugs (fixed upstream in laufey v0.4.1)

  1. raw (winit) β€” the backend still declared LAUFEY_API_VERSION = 25 and its laufey_backend_api struct was missing the five custom-scheme vtable pointers added to the C ABI in v26. The deno-side capi (v26) rejects any backend whose version != 26, so it failed to load:

    API version mismatch: expected 26, got 25
    Runtime init failed with code: -2
    

    Fixed by adding the five trailing fields (null) so the struct matches the v26 layout, and bumping the constant to 26.

  2. webview β€” Failed to create WebView2 environment (CO_E_NOTINITIALIZED, blank window), or an immediate 0xc0000409 crash for some users. WebView2 is single-threaded-apartment; the message loop runs on WinMain's thread, but create_window ran WebView2 creation directly on the runtime's worker thread (no COM init, no message pump) β†’ environment creation fails and the controller callback never fires. Fixed by marshaling all WebView2/COM work to the UI thread (message-only dispatcher window + RunOnUiThread). Also hardens the app:// path that was suspected upstream (retry env creation without the custom scheme; try/catch around the resource handler).

deno-side changes here

  • Bump laufey 0.4.0 β†’ 0.4.1 and regenerate cli/laufey_sums.lock from the v0.4.1 SHA256SUMS (digests verified against the published archives out-of-band).
  • locate_dev_backend_binary only ever looked for extensionless binaries, so LAUFEY_DEV_DIR could never resolve a backend on Windows (laufey_winit.exe etc.). Append the host EXE_SUFFIX.

Verification (Windows 11, x86_64)

Reproduced both failures and verified the fix end-to-end through deno's real download/launch path with the published v0.4.1 backend archives. All three backends now open a working native window β€” before/after screenshots in the comment below.

Refs #35562

Closes denoland/divybot#610

locate_dev_backend_binary only ever looked for extensionless binaries
(target/release/laufey_winit, webview/build/laufey_webview, ...), so
LAUFEY_DEV_DIR could never resolve a backend on Windows, where cargo /
cmake emit laufey_winit.exe etc. Append the host EXE_SUFFIX to the bare
build-tree paths.

Co-Authored-By: Divy Srivastava <me@littledivy.com>
@divybot

divybot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Windows 11 verification β€” all three backends

Reproduced and fixed on a real Windows 11 box (x86_64), deno desktop --backend <b> --hmr app.ts serving a tiny HTML page.

raw (winit)

Before: no window β€”

API version mismatch: expected 26, got 25
Runtime init failed with code: -2

After: native window opens (blank content is expected β€” raw has no webview; apps render via the raw window handle).

raw after

webview (WebView2)

Before: no window β€”

Failed to create WebView2 environment

(CO_E_NOTINITIALIZED / 0x800401f0; some users saw an immediate 0xc0000409 crash instead.)
After: window renders the served page.

webview after

cef (control β€” already worked, unchanged)

cef

Backends were built from littledivy/laufey fix/windows-webview-raw-backends (released as v0.4.1) and run through the exact deno desktop download/launch path (cached backend exe swapped in place).

laufey v0.4.1 fixes the `webview` and `raw` (winit) desktop backends on
Windows (littledivy/laufey#... , released from littledivy/laufey main):

- raw/winit declared API v25 with a struct missing the v26 scheme vtable
  fields, so the capi rejected it ("API version mismatch: expected 26, got
  25" / "Runtime init failed -2").
- webview created the WebView2 environment off the UI thread, failing with
  CO_E_NOTINITIALIZED (blank window) or crashing (0xc0000409); WebView2 work
  is now marshaled to the UI thread.

Bump the dependency and regenerate cli/laufey_sums.lock from the v0.4.1
SHA256SUMS (digests verified against the published archives out-of-band).

Co-Authored-By: Divy Srivastava <me@littledivy.com>
@divybot
divybot marked this pull request as ready for review June 27, 2026 11:18
@divybot

divybot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Upstream: the backend fixes are in littledivy/laufey main and shipped in v0.4.1 (commits fix(winit): bump backend to API v26 … and fix(webview): drive WebView2 from the UI thread on Windows). laufey's own CI is green for those commits (lint / Windows winit+webview builds / capi tests).

The screenshots above were captured running the published v0.4.1 laufey-{webview,winit}-x86_64-pc-windows-msvc archives through deno desktop's real download/launch path on Windows 11 β€” cef unchanged (control), webview now renders the served page, raw now opens a native window (blank is expected β€” raw has no webview).

divybot and others added 2 commits June 27, 2026 16:59
Regression test for locate_dev_backend_binary finding the host-suffixed
dev backend (laufey_winit.exe on Windows).

Co-Authored-By: Divy Srivastava <me@littledivy.com>
locate_dev_backend_winit_target_paths created the extensionless
'laufey_winit' and asserted it resolves, but locate_dev_backend_binary
now looks for the host EXE_SUFFIX ('laufey_winit.exe' on Windows). Build
the fixture path with the same suffix so the test holds on all hosts.
(This is the test that 'test libs debug windows-x86_64' caught β€” it is
skipped on draft runs, so it only surfaced after marking the PR ready.)

Co-Authored-By: Divy Srivastava <me@littledivy.com>
@littledivy
littledivy merged commit 3d3dbb4 into main Jun 27, 2026
136 checks passed
@littledivy
littledivy deleted the orch/divybot-610 branch June 27, 2026 12:44
@bartlomieju bartlomieju mentioned this pull request Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants