1111_13879 on Discord: on Windows the app died after a few hours with
"fatal error: too many callback functions", taking the gateway with it
(clients got connection refused). Five dumps all ended in
w32.GetAllScreens -> syscall.NewCallback -> runtime.compileCallback,
from Wails' WM_DISPLAYCHANGE handling.
Wails (v3.0.0-beta.24 here; v3.1.0 and v3.2.0-nightly.20261101 are the
same) reads the screens again on every WM_DISPLAYCHANGE, and on
WM_SETTINGCHANGE for SPI_SETWORKAREA, through w32.GetAllScreens, which
passes a fresh closure to syscall.NewCallback each call. Go never frees
a callback and throws past about 2000, unrecoverably.
magpie now sets WndProcInterceptor (screensWndProc): on Wails' hidden
main-thread window ("__wails_hidden_mainthread") it takes those two
messages before Wails does, enumerates the monitors with one callback
made once at package level (allScreens), builds the screens exactly as
Wails' processAndCacheScreens does (wailsScreen) and hands them to
Screen.LayoutScreens, then answers as Wails would (DefWindowProc for
WM_DISPLAYCHANGE, 0 for WM_SETTINGCHANGE). Other windows and messages go
on to Wails. Wails' one read at start-up is the only per-call callback
left. No go.mod change: no newer Wails fixes it, and magpie has no fork.
Other per-call NewCallbacks in Wails' Windows code: w32.EnumChildWindows
and w32.SetWindowsHookEx, neither called by Wails or magpie. WndProc
classes are registered once; the WebView2 COM vtables are package-level.
magpie's own (internal/agent apprestart) is already made once.
Run at this tree (base e156fdd03; origin/main since adds only
2251ca1ce, providers, no shared file):
- Windows (win-run, xiaomi-gpu): the three new tests pass;
TestScreensReadFarPastTheCallbackLimit reads 5000 times and matches
Wails' own read field for field. go test ./internal/gui: 5 reds,
TestGatewayHeldByAContainer, TestLodyImportHandoff,
TestImportStatusUnreadableIsUnknown, TestAionUiImportRow,
TestUpdateThatWontStart, the same 5 at e156fdd03 without this change
(#4115, #2107). internal/proc, agentenv, pluginrt ok; sqlitedb's
TestSQLiteSurvivesMalformedEnv red, the same at the base (#4115).
- mote: gofmt -l clean; go vet ./internal/gui ./internal/cli .;
GOOS=windows go vet ./...; GOOS=linux go vet -tags nogui ./...;
go build, GOOS=windows go build, GOOS=linux go build -tags nogui;
go test ./internal/gui: ok but TestMainWindowCorners (#3949, macOS 27).
- Linux (wsl-run): go test -tags nogui ./... was still running at push (the nogui build leaves these files out), so it had no result to record here.
Broken by hand:
- allScreens with a NewCallback per call (as Wails does):
TestScreensReadFarPastTheCallbackLimit dies with the reporter's
"fatal error: too many callback functions" from
syscall.compileCallback.
- A throwaway test calling Wails' w32.GetAllScreens 5000 times dies the
same way at w32/screen.go:145.
- WndProcInterceptor left out of windowsOptions:
TestAppReadsDisplayChangesItself fails.
- wailsMainThread misspelt: TestWailsScreensAreReadOnTheMainThreadWindow
fails.
Not tried: the real app through real display changes on a desktop
session (win-run has no interactive desktop; the test creates a window
titled as Wails' own and sends it the messages); a multi-monitor or
rotated-display layout (the box has one screen). No upstream Wails issue
filed yet; text drafted.
11 lines
424 B
Go
11 lines
424 B
Go
//go:build !nogui
|
|
|
|
package gui
|
|
|
|
// wailsMainThread is the title Wails gives the hidden window its Windows
|
|
// message loop runs on. That window is the one whose WM_DISPLAYCHANGE
|
|
// Wails answers by reading the screens again (see screens_windows.go);
|
|
// TestWailsScreensAreReadOnTheMainThreadWindow fails when an upgrade
|
|
// renames it or stops asking the interceptor first.
|
|
const wailsMainThread = "__wails_hidden_mainthread"
|