From bd9e1c1f346bc80f898fe43fa23986af8a1a0acf Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Fri, 15 May 2026 22:49:29 +1000 Subject: [PATCH] fix(v3/webview2): use log instead of fmt for error and stack trace output On Windows, especially in production applications started outside of a terminal, fmt.Println / fmt.Printf output is often not visible because there is no attached console, so error messages and stack traces from the WebView2 global error handler are lost. Routing them through the log package ensures they reach the standard logger destination. Ports wailsapp/go-webview2#35 to the vendored webview2 package. Co-Authored-By: Andrey Pshenkin --- v3/UNRELEASED_CHANGELOG.md | 1 + webview2/pkg/edge/chromium.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/v3/UNRELEASED_CHANGELOG.md b/v3/UNRELEASED_CHANGELOG.md index 8a0849e33b7..900975339fe 100644 --- a/v3/UNRELEASED_CHANGELOG.md +++ b/v3/UNRELEASED_CHANGELOG.md @@ -25,6 +25,7 @@ After processing, the content will be moved to the main changelog and this file ## Fixed - Fix `concurrent map read and map write` runtime fatal in `linuxSystemTray` when the tray menu is updated while the panel reads it. +- Use `log` instead of `fmt` for WebView2 error and stack trace output so messages aren't lost when the app runs without an attached console on Windows. ## Deprecated diff --git a/webview2/pkg/edge/chromium.go b/webview2/pkg/edge/chromium.go index 81387725df8..2d6a9ceb10b 100644 --- a/webview2/pkg/edge/chromium.go +++ b/webview2/pkg/edge/chromium.go @@ -28,13 +28,13 @@ func globalErrorHandler(err error) { return } - fmt.Printf("[WebView2 Error] %v\n", err) + log.Printf("[WebView2 Error] %v\n", err) stackBuf := make([]uintptr, 64) stackSize := runtime.Callers(2, stackBuf) frames := runtime.CallersFrames(stackBuf[:stackSize]) - fmt.Println("\nStack trace:") + log.Printf("\nStack trace:") stackIndex := 1 for { frame, more := frames.Next()