When running Blender under Wayland, taking a screenshot doesn't work,
it just produces a black image.
----
Steps to reproduce:
- Open blender with factory settings.
- Window -> Save Screenshot
- Save the screenshot.
- View the image, it's entirely black.
NOTE: Calling `bpy.ops.screen.screenshot(filepath="/tmp/screen.png")` is also a quick way to test this.
{F13116515}
----
I looked into a fix but couldn't find a solution, opening this report.
Findings so far:
- Tested with `da9e14b0b91c81d29c4e44f40ac299ae847367de`.
- Tested with D12034 applied (no difference).
- `glReadPixels` works as expected for off-screen buffers, it only fails when reading from the front-buffer.
----
Screenshot fails under the following configurations:
- Gnome-Shell's Wayland Compositor.
- Sway Window Manger.
- River Window Manager (which I used for all other tests).
----
**These Configurations Fail**
- Default factory startup with `WITH_GHOST_WAYLAND` enabled and `WITH_GHOST_X11` disabled.
- Default factory startup with `WITH_GHOST_WAYLAND` enabled and `WITH_GHOST_X11` enabled.
- Software GL `LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe`,
when launching Blender with this environment as well as both
gnome-shell & Blender.
- Using `WITH_GHOST_SDL` in Wayland.
**These Configurations Work**
- Default factory startup in Wayland, inside `Xwayland` with `WITH_GHOST_X11` enabled.
- Default factory startup in Wayland, inside `Xwayland` with `WITH_GHOST_SDL` enabled.
----
**Other details**
- There are no errors reported by OpenGL after glReadPixels.
```
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format);
glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);
```
Return GL_UNSIGNED_BYTE & GL_RGBA, which is whats being used.
----
Since screenshot works in SDL+X11 but fails in SDL+Wayland,
it seems there may be some limitation in the Wayland OpenGL implementation.
- https://bugs.webkit.org/show_bug.cgi?id=161530
- https://forums.raspberrypi.com/viewtopic.php?t=109474
... from looking further online there seems to be issues with Wayland & glReadPixels but most of the information I found related to embedded devices.