Windows: an app freezes forever (not responding) if ContentScale/DevicePixelRatio is equal or great than 1.5
Describe the bug
Windows: an app freezes forever (not responding) if ContentScale/DevicePixelRatio is equal or great than 1.5
How to reproduce
- configure the Cogent Core for Windows 64 bit;
- try to apply custom scaling options in
Settingson Windows, for instance, use:150%factor; - or connect to Windows machine from macOS via a
Windows App(Microsoft Remote Desktop) with an optionOptimize for Retina displaysturned on; - try to run the
hello world; - open either
SettingsorInspector.
my environment:
- Go: go1.23.5 windows/amd64
- Zig: 0.14.0-dev.2851+b074fb7dd
- Windows 10 (22H2) 64 bit
useful commands:
- go install cogentcore.org/core/cmd/core@main
- core setup
- go env -w CGO_ENABLED=1 (by default this option is turned off on WIndows 10)
- go env -w CC="C:\zig0.14\zig cc"
- go env -w CXX="C:\zig0.14\zig c++"
- go env -w CGO_LDFLAGS="-O2 -g -lunwind" (this is important, on Windows 10 64 bit we must add -lunwind)
Example code
package main
import (
"cogentcore.org/core/core"
"cogentcore.org/core/events"
)
func main() {
b := core.NewBody()
btn := core.NewButton(b).SetText("Message")
btn.OnClick(func(e events.Event) {
core.MessageDialog(btn, "Hello, World!", "Message")
})
b.RunMainWindow()
}
Relevant output
An app title + (Not Responding)
Platform
Windows
Updates
20250129
Why it happens?
It happens when you connect to remote Windows machine from macOS via remote desktop client and then Windows OS sees Retina display. And then the Core gets into deadlock because of following functions:
- func (w *Window) ConstrainFrame(topOnly bool) styles.Sides[int]
- func (w *Window) SetGeometry(fullscreen bool, pos, size image.Point, screen *system.Screen)
- func (a *App) RunOnMain(f func())
- func (a *App) MainLoop() for desktop
this pr partially fixes an issue above (https://github.com/cogentcore/core/pull/1462), but new windows are big as twice as needed.
to reproduce this issue you also have to delete following directory C:\Users\<user_name>\AppData\Roaming\Cogent Core. An app might work if it could find some "appropriate" settings (1 of 100 chance, optimist).
20250131
this pr is not relevant (https://github.com/cogentcore/core/pull/1462).
i use custom install of Zig (0.14) because the Zig (0.13) has some troubles with runtime symbols.
Cogent Core is from master branch (future v0.3.9).
@AnyCPU Thank you for reporting this. A few questions:
- Does this also happen with gcc, or is this specific to zig?
- Does the settings window also hang?
- What about the trees tab under the collections tab?
- What about the inspector on the basic example? (with only a hello world button)
If none of those other ones hang, can you use a debugger to find where it is hanging? Thank you!
@kkoreilly
- it looks like it is true for both
- take a look at a screenshot
- no fun
- stay tuned
@kkoreilly while using Zig i had no issue with windows antivirus maybe coincidence, who knows :-)
@kkoreilly this hello world uses the core 0.3.8 and triggers windows antivirus too (funny).
package main
import (
"cogentcore.org/core/core"
)
func main() {
b := core.NewBody()
core.NewButton(b).SetText("Hello, World!")
b.RunMainWindow()
}
it has the same behavior as above.
@kkoreilly i disabled for awhile windows antivirus,
Zig&Gcc have the same behavior using the core 0.3.8 and the hello world.
@AnyCPU Thanks for the update. So it still hangs even with the antivirus disabled?
both windows are not usable.
@kkoreilly yes, it does ^^, no good news at the moment
i continue investigating the hello world app
if i open either the inspector or settings then the app hangs.
Windows OS reports a problem event name: AppHangB1 Hang Signature: c870 Hang Type: 134217728
it looks like some kind of deadlock in
func (a *App) RunOnMain(f func())
@kkoreilly
to be fair it should be mentioned that you should use some remote desktop software to reproduce this bug on a machine has never seen a Cogent Core app: a Window.ConstrainFrame method should be updated.
and i found additional bugs, a one of them is a nil reference panic while you are switching desktop sessions: len(TheApp.Screens) == 0.
stay tuned
@kkoreilly i added an update to this issue, please take a look at the top.
i have something to check, it is possible that some another pr will be added.
@AnyCPU Thank you for the update. I will review your PRs and look into this further.
@kkoreilly i updated description of this issue and added relevant pr.