hajimehoshi / ebiten

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

Drag window onto original monitor after plugging in a monitor causes a crash #3121

Open venning opened 1 month ago

venning commented 1 month ago

Ebitengine Version

v2.8.0

Operating System

Go Version (go version)

go version go1.23.0 darwin/arm64

What steps will reproduce the problem?

This may be a little specific to my case, but it is 100% reproducible for me:

What is the expected result?

Successfully moving the game window.

What happens instead?

The following crash output:

glfw: Cocoa: Cannot query content scale without screen: a platform-specific error occurred
panic: ebiten: width at NewImage must be positive but 0

goroutine 4 [running]:
github.com/hajimehoshi/ebiten/v2.newImage({{0x0?, 0x10097c9e8?}, {0x1400055bc78?, 0x1007a0878?}}, 0x14000401e30?)
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/image.go:1221 +0x2b0
github.com/hajimehoshi/ebiten/v2.(*gameForUI).NewScreenImage(0x1400038eb60, 0x0?, 0x0?)
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/gameforui.go:83 +0x88
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).layoutGame(0x140006dc580, 0x4084000000000000, 0x407e000000000000, 0x7ff8000000000000)
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/internal/ui/context.go:288 +0x12c
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).updateFrameImpl(0x140006dc580, {0x100984d78, 0x140006e2300}, 0x1, 0x4084000000000000, 0x407e000000000000, 0x7ff8000000000000, 0x14000312308, 0x0)
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/internal/ui/context.go:128 +0xe8
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).updateFrame(0x140006dc580, {0x100984d78, 0x140006e2300}, 0x4084000000000000, 0x407e000000000000, 0x7ff8000000000000, 0x14000312308)
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/internal/ui/context.go:73 +0x60
github.com/hajimehoshi/ebiten/v2/internal/ui.(*UserInterface).updateGame(0x14000312308)
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/internal/ui/ui_glfw.go:1491 +0x178
github.com/hajimehoshi/ebiten/v2/internal/ui.(*UserInterface).loopGame(0x14000312308)
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/internal/ui/ui_glfw.go:1448 +0x94
github.com/hajimehoshi/ebiten/v2/internal/ui.(*UserInterface).runMultiThread.func2()
    /Users/chris/go/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.8.0/internal/ui/run.go:71 +0x134
golang.org/x/sync/errgroup.(*Group).Go.func1()
    /Users/chris/go/pkg/mod/golang.org/x/sync@v0.8.0/errgroup/errgroup.go:78 +0x54
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
    /Users/chris/go/pkg/mod/golang.org/x/sync@v0.8.0/errgroup/errgroup.go:75 +0x98
exit status 2

Anything else you feel useful to add?

I did use ebiten.Monitor() to determine that Ebitengine does successfully list the correct monitor when the external monitor is plugged in.


MacBook Pro, 14-inch, 2021 Apple M1 Pro Ventura 13.1