core icon indicating copy to clipboard operation
core copied to clipboard

Windows: an app freezes forever (not responding) if ContentScale/DevicePixelRatio is equal or great than 1.5

Open AnyCPU opened this issue 10 months ago • 15 comments

Describe the bug

Windows: an app freezes forever (not responding) if ContentScale/DevicePixelRatio is equal or great than 1.5

How to reproduce

  1. configure the Cogent Core for Windows 64 bit;
  2. try to apply custom scaling options in Settings on Windows, for instance, use: 150% factor;
  3. or connect to Windows machine from macOS via a Windows App (Microsoft Remote Desktop) with an option Optimize for Retina displays turned on;
  4. try to run the hello world;
  5. open either Settings or Inspector.

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).

AnyCPU avatar Jan 26 '25 22:01 AnyCPU

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 avatar Jan 26 '25 22:01 AnyCPU

@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 avatar Jan 26 '25 22:01 kkoreilly

@kkoreilly

  1. it looks like it is true for both
  2. take a look at a screenshot
  3. no fun
  4. stay tuned
Image

AnyCPU avatar Jan 26 '25 23:01 AnyCPU

@kkoreilly while using Zig i had no issue with windows antivirus maybe coincidence, who knows :-)

AnyCPU avatar Jan 26 '25 23:01 AnyCPU

@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.

AnyCPU avatar Jan 26 '25 23:01 AnyCPU

@kkoreilly i disabled for awhile windows antivirus,

Zig&Gcc have the same behavior using the core 0.3.8 and the hello world.

AnyCPU avatar Jan 26 '25 23:01 AnyCPU

@AnyCPU Thanks for the update. So it still hangs even with the antivirus disabled?

kkoreilly avatar Jan 26 '25 23:01 kkoreilly

Image

both windows are not usable.

AnyCPU avatar Jan 26 '25 23:01 AnyCPU

@kkoreilly yes, it does ^^, no good news at the moment

AnyCPU avatar Jan 26 '25 23:01 AnyCPU

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

AnyCPU avatar Jan 27 '25 17:01 AnyCPU

it looks like some kind of deadlock in func (a *App) RunOnMain(f func())

AnyCPU avatar Jan 27 '25 19:01 AnyCPU

@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

AnyCPU avatar Jan 27 '25 23:01 AnyCPU

@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 avatar Jan 29 '25 22:01 AnyCPU

@AnyCPU Thank you for the update. I will review your PRs and look into this further.

kkoreilly avatar Jan 30 '25 20:01 kkoreilly

@kkoreilly i updated description of this issue and added relevant pr.

AnyCPU avatar Jan 31 '25 22:01 AnyCPU