Save Screenshot (glReadPixels) fails under Wayland #98462
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#98462
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When running Blender under Wayland, taking a screenshot doesn't work,
it just produces a black image.
Steps to reproduce:
NOTE: Calling
bpy.ops.screen.screenshot(filepath="/tmp/screen.png")
is also a quick way to test this.system-info.txt
I looked into a fix but couldn't find a solution, opening this report.
Findings so far:
da9e14b0b91c81d29c4e44f40ac299ae847367de
.glReadPixels
works as expected for off-screen buffers, it only fails when reading from the front-buffer.Screenshot fails under the following configurations:
These Configurations Fail
WITH_GHOST_WAYLAND
enabled andWITH_GHOST_X11
disabled.WITH_GHOST_WAYLAND
enabled andWITH_GHOST_X11
enabled.LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
,WITH_GHOST_SDL
in Wayland.These Configurations Work
Xwayland
withWITH_GHOST_X11
enabled.Xwayland
withWITH_GHOST_SDL
enabled.Other details
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.
... from looking further online there seems to be issues with Wayland & glReadPixels but most of the information I found related to embedded devices.
Added subscriber: @ideasman42
Added subscriber: @HooglyBoogly
Changed status from 'Needs Triage' to: 'Confirmed'
I have no idea about this area, but this also crashes Blender with a use-after-free ASAN report for me, so I can "confirm" this.
Added subscriber: @christian.rauch
Does this also appear with EGL on X11 (
WITH_GL_EGL=ON
butWITH_GHOST_WAYLAND=OFF
)?Which driver are you using? Your log says "
AMD Radeon RX 5700 XT (navi10, LLVM 13.0.1, DRM 3.44, 5.17.9-arch1-1)
" which sounds like software rendering through LLVMpipe.@christian.rauch yes,
WITH_GL_EGL
in X11 works.The driver being used is AMDgpu: https://en.wikipedia.org/wiki/AMDgpu_(Linux_kernel_module) I don't think I can use alternative drivers, besides software rendering (the closed source AMD drivers only seem to work for Xorg).
Some things worth checking:
If this is intentional & can't be worked around on our side. we could avoid using
glReadPixels
which is only used screen-shot and as a fallback forUI_OT_eyedropper_color
(when accessing image pixels directly isn't possible).Possible ways to avoid could be to access the textures used to draw the area/region (in the case of sampling).
In the case of screen-shot it may also be possible to access the textures used for drawing the window. Or, use the wayland API to access this info (check on how wayland screen-shot tools such as grim work https://git.sr.ht/~emersion/grim ), then access screenshot as part of ghost.
As I don't think this is all that high priority, we could even disable screenshot for wayland until a solution is found. (or disable for AMD if this only impacts AMD).
@HooglyBoogly what hardware are you using and what was the ASAN crash?
Hmm, I actually can't reproduce this anymore. I think I was using the built-in gnome screenshot tool, but that does sound a bit weird.
Now Blender's screenshot operator seems to work fine too.
Just in case:
@HooglyBoogly does it work with
WITH_GHOST_X11=OFF
andWITH_GHOST_WAYLAND=ON
? (As X11 under Xwayland works for me too).Yeah, everything seems to work fine for me with those build options. I'm using Fedora 36 with Wayland. I wish I took more detailed notes of the problem before. Just in case, I checked
WITH_GL_EGL
and it also worked.This issue was referenced by
48da8c4040
Changed status from 'Confirmed' to: 'Resolved'
This bug was caused by the behavior of
eglSwapBuffer
, On my systemEGL_BUFFER_PRESERVED
is not supported, so accessing the front-buffer isn't a reliable way of reading the image. Although it does work under some conditions, for example - removing the redraw before reading the front-buffer works as expected. There is an issue with drawing into the back-buffer, callingeglSwapBuffer
then immediately accessing the front-buffer. Given some time for wayland to draw the window this should work, but when these commands run without time for the egl-surface to draw it fails.It's possible to redraw then read from the back-buffer, or tweak buffer swapping to make it work but this seems too fragile and likely to break (since drawing doesn't always call buffer-swap).
So I've committed off-screen buffer drawing instead, while this is a workaround I don't see any down-sides as this is more likely to give correct output in some corner cases (minimized window, partially off-screen windows ... etc).