obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
58.79k stars 7.83k forks source link

OBS crashes with explicit sync on wayland #11022

Open mahkoh opened 1 month ago

mahkoh commented 1 month ago

Operating System Info

Other

Other OS

Arch Linux

OBS Studio Version

30.1.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/WQGyYH2S1OMk7op4

OBS Studio Crash Log URL

No response

Expected Behavior

OBS does not crash.

Current Behavior

OBS crashes.

Steps to Reproduce

Start OBS under a wayland compositor that supports explicit sync and with graphics drivers that support explicit sync. With up-to-date nvidia drivers, that should always be the case. With mesa, you will also have to set the environment variable MESA_LOADER_DRIVER_OVERRIDE=zink to ensure that vulkan is being used under the hood.

After starting OBS, right click on the preview and select Windowed Projector (Preview). You might have to repeat this several times.

OBS crashes.

Anything else we should know?

I am reasonably certain that this is caused by the following series of events:

  1. OBS creates a QT window.
  2. OBS extracts the underlying wl_surface.
  3. OBS uses that wl_surface to create an OpenGL context.
  4. Later, QT tries to commit a SHM buffer to that wl_surface. Possibly due to a resize event. Since QT does not know anything about the OpenGL context, this crashes.

The last step is unsound. QT must not not manipulate the surface buffer while the surface is owned by an OpenGL or Vulkan context. I believe that that much is required by the OpenGL and Vulkan specifications.

The question is if QT is in the wrong here (although I don't see how, QT seems to know nothing about OBS creating on OpenGL context) or if this is an OBS bug because OBS creates an OpenGL context without properly informing QT about this.

@davidedmundson can you comment on the above?

davidedmundson commented 1 month ago

Without remembering any OBS code:

kkartaltepe commented 3 weeks ago

OBS draws directly into the QWidget for all displays (OBS rendered content), perhaps the project is using a different setting that causes the shm to be attached.

Defarius commented 1 week ago

I am also experiencing this issue or something similar. It seems to somewhat fix itself but it has reappeared today after installing openrazer. 2024-09-02 04-46-41.txt

amshafer commented 1 week ago

I posted a question about mixing app and GL buffer attaches on wayland that might be relevant here: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/211

kkartaltepe commented 1 week ago

I'm pretty sure removing https://github.com/obsproject/obs-studio/blob/master/UI/window-projector.cpp#L41-L44 will resolve this for people experiencing issues. Unfortunately a real solution is a bit more complicated assuming this really does work.