hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
10.41k stars 635 forks source link

fatalpanic when ebitengine application is re-awakened by Mac OS from sleep #2554

Open memmaker opened 1 year ago

memmaker commented 1 year ago

Ebitengine Version

2.5.0-alpha.11

Operating System

Go Version (go version)

go1.19.4 darwin/amd64

What steps will reproduce the problem?

Start the ebitengine main loop on MacBook with Retina Display. Let the Mac go to sleep while the application is running and the awaken the Mac again.

What is the expected result?

No crash.

What happens instead?

A crash, presumably because the devicescalefactor is reported wrong.

Anything else you feel useful to add?

Yes, here is a screenshot of the stacktrace and debug session that opened up in my IDE after resuming work.

Screenshot 2023-01-24 at 21 13 22
hajimehoshi commented 1 year ago

Thanks. I'll take a look.

hajimehoshi commented 1 year ago

I couldn't reproduce this. Do you use an external retina display?

memmaker commented 1 year ago

No, a built-in laptop display. However I also have an external low-dpi display connected via HDMI as a second screen. Maybe that's part of the issue? I also have only experienced this issue once after wake-up (since I don't usually leave my application running) so this was only my best guess. I will do further tests and report back.

memmaker commented 1 year ago

Ok, I am sorry. You are right. That's not the trigger. I just tried closing my Macbook and it even disconnecting the second screen. All working fine. It's a mystery then, to me.

It first appeared when I got back to my machine after it went to sleep. That's why I thought it would be that. Obviously I am wrong. If it happens again, I will try to provide a way to reproduce it for real.

memmaker commented 1 year ago

I am still experiencing this on v.2.6.0-alpha

Runtime throws: "unexpected signal during runtime execution"

Stack Trace

runtime.throw (panic.go:1040) runtime
runtime.sigpanic (signal_unix.go:821) runtime
?:0
C.glfwGetMonitorContentScale (monitor.c:388)
/tmp/go-build/cgo-gcc-prolog:146
runtime.asmcgocall (asm_amd64.s:848) runtime
/tmp/go-build/cgo-gcc-prolog:139
_cgo_gotypes.go:1036
glfw.(*Monitor).GetContentScale.func1 (monitor.go:118) github.com/go-gl/glfw/v3.3/glfw
glfw.(*Monitor).GetContentScale (monitor.go:118) github.com/go-gl/glfw/v3.3/glfw
glfw.(*Monitor).GetContentScale (glfw_notwindows.go:74) github.com/hajimehoshi/ebiten/v2/internal/glfw
devicescale.impl (impl_desktop.go:41) github.com/hajimehoshi/ebiten/v2/internal/devicescale
devicescale.GetAt (devicescale.go:38) github.com/hajimehoshi/ebiten/v2/internal/devicescale
ui.(*userInterfaceImpl).deviceScaleFactor (ui_glfw.go:658) github.com/hajimehoshi/ebiten/v2/internal/ui
ui.(*userInterfaceImpl).updateInputState (input_glfw.go:64) github.com/hajimehoshi/ebiten/v2/internal/ui
ui.(*userInterfaceImpl).update (ui_glfw.go:1018) github.com/hajimehoshi/ebiten/v2/internal/ui
ui.(*userInterfaceImpl).updateGame.func1 (ui_glfw.go:1069) github.com/hajimehoshi/ebiten/v2/internal/ui
thread.(*NoopThread).Call (thread.go:83) github.com/hajimehoshi/ebiten/v2/internal/thread
ui.(*userInterfaceImpl).updateGame (ui_glfw.go:1068) github.com/hajimehoshi/ebiten/v2/internal/ui
ui.(*userInterfaceImpl).loopGame (ui_glfw.go:1043) github.com/hajimehoshi/ebiten/v2/internal/ui
ui.(*userInterfaceImpl).Run (run_glfw_singlethread.go:39) github.com/hajimehoshi/ebiten/v2/internal/ui
ebiten.RunGameWithOptions (run.go:305) github.com/hajimehoshi/ebiten/v2
main.main (main.go:182) main
runtime.main (proc.go:250) runtime
runtime.goexit (asm_amd64.s:1598) runtime
 - Async Stack Trace
<autogenerated>:2
hajimehoshi commented 1 year ago

So how can we reproduce this?