hajimehoshi / ebiten

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

warnings are shown when running a test on macOS #2425

Open hajimehoshi opened 1 year ago

hajimehoshi commented 1 year ago

Ebitengine Version

b966190b3472a88b2d7c0e1b6fa58daabe56be08

Operating System

Go Version (go version)

go version go1.19.2 darwin/amd64

What steps will reproduce the problem?

go test . -run=ANY_TEST_YOU_LIKE

What is the expected result?

No warnings

What happens instead?

This warnings was shown when running a test

ebiten.test[13791:35929170] [CAMetalLayer nextDrawable] returning nil because allocation failed.

Anything else you feel useful to add?

No response

TotallyGamerJet commented 1 year ago

I did start to notice this. I think it's a regression caused by updating macOS to Ventura. Does this happen on Monterey (v12)?

hajimehoshi commented 1 year ago

Yes.

hajimehoshi commented 1 year ago

The situation is flaky and now I cannot see this error.

sergeypdev commented 1 year ago

I'm seeing this error when I try to load an image during the Draw() call.

TotallyGamerJet commented 1 year ago

Do you have a reproducible case?

sergeypdev commented 1 year ago

@TotallyGamerJet It happens in my project, it would be too much code to post here. Basically I'm calling ebitenutil.NewImageFromFile(path) in the Draw() callback on the first frame and it crashes with the same error.

sergeypdev commented 1 year ago

I tried to write a minimum reproduction program and it doesn't crash...

This is the stack trace I get in my main codebase:

2023/07/08 04:22:03 Loaded image 2 assets/test.png
2023-07-08 04:22:03.561 app[75192:1967755] [CAMetalLayer nextDrawable] returning nil because allocation failed.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x104b8226c]

goroutine 4 [running]:
github.com/hajimehoshi/ebiten/v2.(*Image).isDisposed(...)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/image.go:66
github.com/hajimehoshi/ebiten/v2.(*Image).DrawImage(0x104c0f782?, 0x14000432591?, 0x1400042fb28?)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/image.go:221 +0x2c
main.(*Game).Draw(0x1400037e000, 0x140001bd260?)
    /Users/sergey/work/games/ebitengine-puzzle/cmd/app/main.go:73 +0x154
github.com/hajimehoshi/ebiten/v2.(*gameForUI).DrawOffscreen(0x140001b0310)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/gameforui.go:165 +0x34
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).drawGame(0x1400028bd50, {0x104d449a8, 0x140002ce360}, 0x0)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/internal/ui/context.go:185 +0x110
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).updateFrameImpl(0x1400028bd50, {0x104d449a8, 0x140002ce360}, 0x1, 0x4084000000000000, 0x407e000000000000, 0x10140000cc8a0?, 0x104fc2700, 0x60?)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/internal/ui/context.go:153 +0x32c
github.com/hajimehoshi/ebiten/v2/internal/ui.(*context).updateFrame(0x14000091920?, {0x104d449a8, 0x140002ce360}, 0x0?, 0x0?, 0x0?, 0x0?)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/internal/ui/context.go:73 +0x60
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).updateGame(0x104fc2700)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/internal/ui/ui_glfw.go:1084 +0x1c8
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).loopGame(0x104fc2700)
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/internal/ui/ui_glfw.go:1044 +0x7c
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).Run.func2()
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/github.com/hajimehoshi/ebiten/v2@v2.5.5/internal/ui/run_glfw_notsinglethread.go:57 +0x3c
golang.org/x/sync/errgroup.(*Group).Go.func1()
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/golang.org/x/sync@v0.1.0/errgroup/errgroup.go:75 +0x5c
created by golang.org/x/sync/errgroup.(*Group).Go
    /Users/sergey/.asdf/installs/golang/1.20.5/packages/pkg/mod/golang.org/x/sync@v0.1.0/errgroup/errgroup.go:72 +0xa0