Open HinTak opened 5 months ago
That sdl2 and opengl on osx works happily headless can been seen in the CI in https://github.com/FlorianRhiem/pyGLFW/issues/80#issuecomment-2143191281
Copying the output of the MacOS run of glfwinfo here for more information:
Error: NSGL: Failed to find a suitable pixel format
GLFW header version: 3.5.0
GLFW library version: 3.5.0
GLFW library version string: "3.5.0 Cocoa NSGL Null EGL OSMesa monotonic"
GLFW platform: Cocoa
GLFW supported platforms:
Cocoa
Null
Vulkan loader: missing
For a successful run (with either SDL2 or GLUT) within github CI's macos 14 runner, the GL context reports its vendor/renderer, version, shader version as:
b'Apple Inc.'
b'Apple Software Renderer'
b'4.1 APPLE-21.0.19'
b'4.10'
Glfw itself has an offscreen rendering example : https://github.com/glfw/glfw/blob/master/examples/offscreen.c . It probably should be run post-build to check that it can run!
In my fork's ci branch I have added the two lines from #2080, as well as running both glfwinfo and the offscreen example. Here is the result from github action:
Run ./build-cocoa-static/examples/offscreen
./build-cocoa-static/examples/offscreen
shell: /bin/bash -e {0}
env:
CFLAGS: -Werror
MACOSX_DEPLOYMENT_TARGET: 10.11
CMAKE_OSX_ARCHITECTURES: x86_64;arm64
0s
Run ./build-cocoa-static/tests/glfwinfo
GLFW header version: 3.5.0
GLFW library version: 3.5.0
GLFW library version string: "3.5.0 Cocoa NSGL Null EGL OSMesa monotonic"
GLFW platform: Cocoa
GLFW supported platforms:
Cocoa
Null
OpenGL context version string: "2.1 APPLE-21.0.19"
OpenGL context version parsed by GLFW: 2.1.0
OpenGL context renderer string: "Apple Software Renderer"
OpenGL context vendor string: "Apple Inc."
OpenGL context shading language version: "1.20"
OpenGL framebuffer:
red: 8 green: 8 blue: 8 alpha: 8 depth: 32 stencil: 8
samples: 0 sample buffers: 0
accum red: 0 accum green: 0 accum blue: 0 accum alpha: 0 aux buffers: 0
Vulkan loader: missing
In stock, running the offscreen example post-build gives:
Run ./build-cocoa-static/examples/offscreen
Error: NSGL: Failed to find a suitable pixel format
Error: NSGL: Failed to create OpenGL context
Error: OpenGL version string retrieval is broken
Error: Process completed with exit code 1.
Linked from https://github.com/glfw/glfw/issues/589 is https://github.com/glfw/glfw/commit/d79056fc27ff693ba0968d626574e421707845c0 on the software-context branch, which contains most of the knowledge. However, my goal is that glfw (and its dependent, pyglfw) should be usable within github's own CI system, preferably without client-side code change or addition. Adding a Xvfb line is not too painful, but no-client-side special hint is preferred.
Github CI has a mac os runner which is headless AFAIK, but it has a software renderer. However, glfw can't get to it - this can be illustrated by this pull (do not merge) which runs glfwinfo after build: https://github.com/glfw/glfw/pull/2569
Both OSX OpenGL (the GLUT part) and SDL2 can get at the apple software renderer within github CI, so this is a glfw specific problem. It would be useful to nake this work, to allow glfw to be used within github's own CI workflow for testing.
I came to be here after going down the rabbit hole of trying to look at a mac os specific problem in skia-python (which has CI testing for all three platforms, and been using glut for testing on mac os x for the above reasons, instead of glfw as in the case of linux with Xvfb): https://github.com/kyamagu/skia-python/issues/214 and downstream https://github.com/FlorianRhiem/pyGLFW/issues/80