hajimehoshi / ebiten

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

.github/workflows: enable tests on macOS #1305

Open hajimehoshi opened 4 years ago

hajimehoshi commented 4 years ago
hajimehoshi commented 4 years ago

On macOS:

Unable to create basic Accelerated OpenGL renderer.
Unable to create basic Accelerated OpenGL renderer.
Core Image is now using the software OpenGL renderer. This will be slow.
GLFW: An invalid error was not accepted by the caller: FormatUnavailable: NSGL: Failed to find a suitable pixel format
GLFW: Please report this bug in the Go package immediately.
panic: FormatUnavailable: NSGL: Failed to find a suitable pixel format

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.acceptError(0xc0000cbb58, 0x2, 0x2, 0x0, 0x0)
    /Users/runner/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/error.go:178 +0x201
github.com/go-gl/glfw/v3.3/glfw.CreateWindow(0x10, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/runner/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/window.go:350 +0x1c1
github.com/hajimehoshi/ebiten/internal/glfw.CreateWindow(0x10, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /Users/runner/work/ebiten/ebiten/internal/glfw/glfw_notwindows.go:243 +0x7c
hajimehoshi commented 4 years ago

On Windows:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x133d2c2]

goroutine 1 [running, locked to thread]:
github.com/hajimehoshi/ebiten/internal/glfw.(*Window).MakeContextCurrent(0x0)
    D:/a/ebiten/ebiten/internal/glfw/glfw_windows.go:175 +0x42
github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).createWindow(0x15b50e0, 0xf, 0x0)
    D:/a/ebiten/ebiten/internal/uidriver/glfw/ui.go:626 +0x1f7
github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).run.func1(0xc0000b9d10, 0xc0000b9ce8)
    D:/a/ebiten/ebiten/internal/uidriver/glfw/ui.go:701 +0x1a5
github.com/hajimehoshi/ebiten/internal/thread.(*Thread).Loop(0xc00001a160, 0x1427e00, 0xc00003c800)
    D:/a/ebiten/ebiten/internal/thread/thread.go:47 +0x42
github.com/hajimehoshi/ebiten/internal/uidriver/glfw.(*UserInterface).Run(0x15b50e0, 0x1427f00, 0x15b9180, 0x0, 0x13ae580)
    D:/a/ebiten/ebiten/internal/uidriver/glfw/ui.go:599 +0x1c5
github.com/hajimehoshi/ebiten.runGame(0x1426300, 0xc0000441e0, 0x0, 0x21ac3810028, 0xc00001a150)
    D:/a/ebiten/ebiten/run.go:322 +0x89
github.com/hajimehoshi/ebiten.RunGame(0x1426380, 0xc00001a150, 0xc000000002, 0x0)
    D:/a/ebiten/ebiten/run.go:313 +0xaa
github.com/hajimehoshi/ebiten/internal/testing.MainWithRunLoop(0xc000064000)
    D:/a/ebiten/ebiten/internal/testing/testing.go:53 +0xc8
github.com/hajimehoshi/ebiten_test.TestMain(...)
    D:/a/ebiten/ebiten/image_test.go:36
main.main()
    _testmain.go:197 +0x167
FAIL    github.com/hajimehoshi/ebiten   0.499s

My guess is that DirectX might solve this.

hajimehoshi commented 1 year ago

The rest environment is macOS.

hajimehoshi commented 1 year ago

On macOS again:

GLFW: An invalid error was not accepted by the caller: FormatUnavailable: NSGL: Failed to find a suitable pixel format
GLFW: Please report this bug in the Go package immediately.
panic: FormatUnavailable: NSGL: Failed to find a suitable pixel format

goroutine 1 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.acceptError({0xc000571bb[8](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:9), 0x2, 0x0?})
    /Users/runner/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20221017161538-[9](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:10)3cebf72946b/error.go:178 +0x1c5
github.com/go-gl/glfw/v3.3/glfw.CreateWindow(0x[10](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:11)0078746?, 0xc000571c48?, {0x0?, 0x1000785f4?}, 0x0, 0x0)
    /Users/runner/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20221017161538-93cebf72946b/window.go:350 +0x172
github.com/hajimehoshi/ebiten/v2/internal/glfw.CreateWindow(0xc000571c70?, 0x0?, {0x0?, 0x100078720?}, 0xc000571c98?, 0x1002afc96?)
    /Users/runner/work/ebiten/ebiten/internal/glfw/glfw_notwindows.go:268 +0x3d
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).createWindow(0x100686100, 0xf?, 0x0?)
    /Users/runner/work/ebiten/ebiten/internal/ui/ui_glfw.go:704 +0x3f
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).init(0x100686100)
    /Users/runner/work/ebiten/ebiten/internal/ui/ui_glfw.go:942 +0x1e5
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).Run.func1.1()
    /Users/runner/work/ebiten/ebiten/internal/ui/run_notsinglethread.go:39 +0x26
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop.func1(0xc000571da0?, 0xc000571d90?)
    /Users/runner/work/ebiten/ebiten/internal/thread/thread.go:54 +0x53
github.com/hajimehoshi/ebiten/v2/internal/thread.(*OSThread).Loop(0xc0000ac7e0)
    /Users/runner/work/ebiten/ebiten/internal/thread/thread.go:55 +0x2e
github.com/hajimehoshi/ebiten/v2/internal/ui.(*userInterfaceImpl).Run(0x100686100, {0x1004[11](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:12)6b0?, 0xc000[13](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:14)8000})
    /Users/runner/work/ebiten/ebiten/internal/ui/run_notsinglethread.go:52 +0x231
github.com/hajimehoshi/ebiten/v2.RunGame({0x10040ff90, 0xc000[18](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:19)a270})
    /Users/runner/work/ebiten/ebiten/run.go:[23](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:24)3 +0x9d
github.com/hajimehoshi/ebiten/v2/internal/testing.MainWithRunLoop(0xc0000c00a0)
    /Users/runner/work/ebiten/ebiten/internal/testing/testing.go:47 +0x65
github.com/hajimehoshi/ebiten/v2_test.TestMain(...)
    /Users/runner/work/ebiten/ebiten/image_test.go:63
main.main()
    _testmain.go:[31](https://github.com/hajimehoshi/ebiten/actions/runs/3464137817/jobs/5785295182#step:16:32)1 +0x1dc
hajimehoshi commented 1 year ago

Related

https://github.com/glfw/glfw/issues/2080

So if we rewrite GLFW, it's possible to fix this issue maybe.

hajimehoshi commented 1 year ago
diff --git a/internal/cglfw/nsgl_context_darwin.m b/internal/cglfw/nsgl_context_darwin.m
index 78d688c49..a6d761aca 100644
--- a/internal/cglfw/nsgl_context_darwin.m
+++ b/internal/cglfw/nsgl_context_darwin.m
@@ -205,7 +205,8 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
     NSOpenGLPixelFormatAttribute attribs[40];
     int index = 0;

-    addAttrib(NSOpenGLPFAAccelerated);
+    //addAttrib(NSOpenGLPFAAccelerated);
+    setAttrib(NSOpenGLPFARendererID, kCGLRendererGenericFloatID);
     addAttrib(NSOpenGLPFAClosestPolicy);

     if (ctxconfig->nsgl.offline)

This seems to always use a software renderer unfortunately.

divVerent commented 10 months ago

I had a workaround for this in AAAAXY:

https://github.com/divVerent/aaaaxy/blob/main/scripts/macos_gl_allow_software.sh

However this stopped working, as apparently the software renderer only supports up to OpenGL 2.1 and Ebitengine now demands OpenGL 3.2:

2023/12/25 22:59:50.206166 [FATAL] RunGame exited abnormally: VersionUnavailable: Requested OpenGL version 3.2, got version 2.1
hajimehoshi commented 10 months ago

Thanks for the info.

(I realized your comment now as there was no notification. I was wondering why...)