[v3][Windows] Keep abandoned WebView2 callback handlers alive until native release
Native validation update (2026-09-28): the GA readiness report for #6184 at 39fbbdec1b695217e5bda1876e04ed29c959657f reports successful CLI/example builds on macOS arm64 and Windows amd64, all 51 macOS package tests passing, and Windows results of 50 passing packages plus two environment failures reproduced on master (internal/wake, internal/wake/exec, missing sh). The Windows edge suite, including the lifetime tests, passed according to that report, but it ran over non-interactive SSH and its live WebView2 coverage was not confirmed. Linux was offline and app launch was not tested. These are results reported by the separate native run, not tests rerun by this monitor; they do not cover the unpublished #6167 changes or the combined tree. Review/landing and the stated native coverage limits remain pending.
Implementation update (2026-09-27): #6184 now implements this lifetime fix at 39fbbdec1b695217e5bda1876e04ed29c959657f and is tracked in v3.0.0 GA. Its PR description records native Windows reproduction and validation. The separate integration check confirms Windows amd64/arm64 test-binary compilation and a conflict-free merge analysis with the unpublished #6167 tip. Combined native behavior remains unverified; this issue stays open while review and landing are pending. No duplicate lifetime implementation is planned.
Follow-up from reviewing the code merged by #6002 (075dded01, master 7e95d89bd), separate from the configuration/retry fixes in #6167.
Evidence and reproduction
Chromium owns Go-allocated environment/controller/event handler objects. Native WebView2 receives their addresses through uintptr values, while Chromium.AddRef and Release both return 1 without keeping a Go reference. After replacement, the window drops the previous Chromium; after a failed/timed-out replacement, it can also drop that replacement. A pending native callback is therefore not sufficient to keep its Go handler graph reachable.
The especially relevant case is a controller/environment creation callback arriving after the initialization timeout. Closing a failed Chromium cannot close a controller/environment that has not arrived yet. The existing late-callback tests retain a Go pointer themselves, so they do not exercise collection between abandonment and Invoke.
This is a source-confirmed ownership gap, not a reproduced native crash. A deterministic Windows reproducer should delay an initialization callback beyond the timeout, abandon the instance, force GC/allocation churn, then deliver the delayed callback through its native handler address. Repeat across successful replacement and window teardown.
Go explicitly documents that uintptr does not keep an object alive: https://pkg.go.dev/unsafe. The repository's pkg/combridge already uses native-reference ownership and a Go registry; that is the existing mechanism to evaluate. A window-owned list alone does not establish callback lifetime after the window is collected and can accumulate objects after repeated successful recoveries.
Acceptance
- Native callback ownership keeps the Go handler and implementation alive through the final native Release.
- Late callbacks after failure/timeout/close remain safe without retaining abandoned windows indefinitely.
- Tests cover forced GC, delayed Invoke, final Release, successful replacement, and teardown.
- Validate on native Windows; cross-compilation alone cannot verify the lifetime behavior.
No duplicate runtime fix was found. #5768 only changes dormant generated bindings and explicitly leaves the production pkg/edge runtime untouched.
Native verification is currently blocked in this workspace by SSH authentication to win-node1. No lifetime fix is claimed or published. Keep this Windows runtime bug in v3.0.0 GA/nightly patch scope, outside v3.1.0 features.
Source: wailsapp/wails