aquaarboraurum: on Windows the window that comes back after every
auto-update restart is white. Its title bar and status bar are there,
and its page is alive. A restart by hand or a reload draws it.
AutoRestart only restarts once nothing is going through magpie and the
window has sat unused, which is when the user is away, often with the
screen locked or the display off. A WebView2 window first shown then
can keep a white surface: Chromium's native occlusion tracking takes
every window as covered while the screen is locked, and a surface first
drawn in that state may not be drawn again. Closing the window to the
tray and opening it again, which the reporter did by hand, draws it.
- windowsOptions starts WebView2 with CalculateNativeWinOcclusion
disabled (occlusionOff), after the user's own features. A user who
enables it in WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS keeps it on.
Wails still tells a hidden or minimised window so (put_IsVisible).
- Wails' main-thread window registers for session and display-state
notifications (watchScreenBack). The app's WndProcInterceptor
(appWndProc, which still calls screensWndProc) draws each open window
again (redrawShown) when the session is unlocked or the display comes
on after being off, as mendOnWake already did on wake.
Not reproduced: the white window never showed on xiaomi-gpu (Windows
11, WebView2 157.0.4341.46). The tries:
- quiet and asked restarts, behind other windows, maximised, under a
full-screen cover, cloaked, minimised then restored;
- the real sandboxed AutoRestart update path (v0.1.9000 to v0.1.9001
from a local feed).
The box's screen can't be locked for a test, so the locked-screen case
the fix is aimed at wasn't tried.
Run:
- Windows (xiaomi-gpu, signed-in session):
- TestRestartedWindowIsDrawn: all 13 modes pass on the fix. The test
is new and plays the update restart (old process, markQuietRestart,
AwaitPredecessor, openMain). Each mode now also posts an unlock to
the app's own main-thread window, checks that the window is drawn
again and stays drawn, and checks that the msedgewebview2 browser's
command line has CalculateNativeWinOcclusion disabled.
- Broken by hand (the interceptor ignoring the unlock, occlusionOff
returning the list unchanged): red on both checks.
- go vet ./internal/gui; TestScreenBackFrom,
TestAppWndProcSaysTheScreenIsBack, TestWebView2* pass.
- The real update path with exes built from this tree: the new
process's window came up drawn (10 of 360 sampled points white,
the same as the old window) over 22s of samples.
- mote:
- gofmt -l;
- go vet ./internal/gui/..., GOOS=linux -tags nogui, GOOS=windows;
- GOOS=windows go build ./..., GOOS=linux go build -tags nogui ./...;
- go test ./internal/gui (142s) and -tags nogui (95s): ok.
Not run: the full ./... suite. mote and mica were both over their load
(mote's suite.lock had four suites queued). The change is in
internal/gui only.
57 lines
2.2 KiB
Go
57 lines
2.2 KiB
Go
//go:build windows && !nogui
|
|
|
|
package gui
|
|
|
|
import (
|
|
"testing"
|
|
"unsafe"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
// The screen coming back, and only that, draws magpie's windows again: an
|
|
// unlock, or the display on after it was off. Windows says the display is
|
|
// on when the watch is registered; that is no change.
|
|
func TestScreenBackFrom(t *testing.T) {
|
|
displayOff.Store(false)
|
|
t.Cleanup(func() { displayOff.Store(false) })
|
|
display := func(state uint32, guid windows.GUID) string {
|
|
s := powerBroadcastSetting{PowerSetting: guid, DataLength: 4, Data: state}
|
|
return screenBackFrom(wmPowerBroadcast, pbtPowerSettingChange, uintptr(unsafe.Pointer(&s)))
|
|
}
|
|
other := windows.GUID{Data1: 1}
|
|
for _, c := range []struct {
|
|
name, want string
|
|
got func() string
|
|
}{
|
|
{"unlocked", "the session was unlocked", func() string { return screenBackFrom(wmWTSSessionChange, wtsSessionUnlock, 0) }},
|
|
{"locked", "", func() string { return screenBackFrom(wmWTSSessionChange, 0x7, 0) }},
|
|
{"on when registered", "", func() string { return display(1, guidConsoleDisplayState) }},
|
|
{"off", "", func() string { return display(0, guidConsoleDisplayState) }},
|
|
{"another setting's on", "", func() string { return display(1, other) }},
|
|
{"dimmed", "", func() string { return display(2, guidConsoleDisplayState) }},
|
|
{"on after off", "the display came on", func() string { return display(1, guidConsoleDisplayState) }},
|
|
{"on again", "", func() string { return display(1, guidConsoleDisplayState) }},
|
|
{"another power event", "", func() string { return screenBackFrom(wmPowerBroadcast, 0x7, 0) }},
|
|
} {
|
|
if got := c.got(); got != c.want {
|
|
t.Errorf("%s: %q, want %q", c.name, got, c.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The app's interceptor hands an unlock on and still lets the screens'
|
|
// own handling see every message.
|
|
func TestAppWndProcSaysTheScreenIsBack(t *testing.T) {
|
|
var said []string
|
|
back := func(why string) { said = append(said, why) }
|
|
was := screenBack.Load()
|
|
screenBack.Store(&back)
|
|
t.Cleanup(func() { screenBack.Store(was) })
|
|
appWndProc(0, wmWTSSessionChange, wtsSessionUnlock, 0)
|
|
appWndProc(0, wmWTSSessionChange, 0x7, 0)
|
|
if len(said) != 1 || said[0] != "the session was unlocked" {
|
|
t.Fatalf("said %q, want one unlock", said)
|
|
}
|
|
}
|