-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EGL/Wayland (Wayland, pt 3) #2484
EGL/Wayland (Wayland, pt 3) #2484
Conversation
b4a5de9
to
4e942f4
Compare
4e942f4
to
ddaed2c
Compare
This is looking really good, thanks for doing this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done reviewing for today. These comments are across this PR because i find little value in the intermediate steps. I hope its not too much trouble to pull the changes into the appropriate commit (i know if you use mercurial there is a neat absorb
function that does this)
And thanks a lot for working on this PR and bringing everything together. I really appreciate it.
xcompcap plugins are dependent on GLX. If possible getting them to work with both backends would be nice otherwise we should prevent them from loading/initializing when the EGL platform is being used. |
2053fae
to
e268252
Compare
I've investigated using EGL in the linux-capture plugins, but it would be quite complicated. For now, I just went with disabling the linux-capture plugins entirely. I'm slowly working towards another linux-capture plugin that works both with Wayland and X11. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is all my concerns.
c48b435
to
9efe3ec
Compare
Alright this is the last push. It was missing an include of |
I've been building and testing this for a few days. I'm not an extensive OBS user but it's been working well (including dmabuf with wlr-obs). Thank you very much for this! |
I've done an extensive debugging session yesterday and today, and I'm 95% confident that this crash is caused by Qt violating the Wayland protocol. Keep in mind that OBS Studio doesn't directly use Wayland APIs, or try to communicate stuff through the Wayland socket. The debug spew that |
Tried to test this today, but I can't seem to compile on my manjaro system. It fails without explanation on
I see that this PR does a lot with glad... Any chance this is a problem in the PR? Otherwise, where should I go to get help compiling? |
Either set -fcommon or rebase over #2864 |
Thanks, @kkartaltepe ! That got me unstuck. Playing and testing now on a rebased version. Everything seems fine at first glance, though there are some anomalies in stdout:
Full stdOut follows.
|
Just got a fatal while browsing the menus:
|
I've been using the AUR package of this branch for a while now with sway and wlrobs. Every once in a while, if I'm recording for a long time with obs in a different workspace, it'll crash right when I switch back to the workspace with obs in it. I'll be doing long screencasts each week for the next few months. What is the best way to try to capture logs to see if this is a problem with this PR or with wlrobs or some other component of my setup? |
@danshick I have not tested in a while. But I observed the same issue (and know of others who have it too, I will ping them if they still see the same issue). In my case it was happening every time after running OBS on an invisible sway desktop for a minute or two and then switching back to that said desktop, OBS crashed. Unfortunately I don't have GDB backtraces captured. But that might be the way to find out what is wrong. |
I might still have a coredump lying around, but I forget whether or not I disabled binary stripping in the package. Regardless, I'm sure I can reproduce it and get a coredump. Pairing that with a debug log would hopefully be more helpful. |
A coredump without your symbols will not be helpful, if you can instead provide a backtrace of all threads (with symbols) that would be the most useful thing. |
@danshick this sounds familiar; does it crash or exit with wayland protocol error? In the latter case it might be QTBUG-81504 |
I'll have some time to reproduce this later this week (with symbols). I'll post logs and coredumps when able. |
I think you're right. |
Amazing work! I'll be testing this under NixOS + Wayland (Sway/wlroots) in the following days. (btw, Cobra sends his regards from ETEC ;) ) |
85b453b
to
e2cdcce
Compare
Long time no see, my friend :) |
Introduce the OBS_NIX_PLATFORM_WAYLAND enum value, and try to detect it when OBS Studio runs by looking into the platform name.
We need to ensure we're running all X11 code on the same display.
Introduce a new Wayland/EGL renderer.
On Wayland, we want to query the window's underlying platform for the Wayland surface, instead of foolishly retrieving the X11 display. Pass QWindow instead of WId directly, and set the surface as the platform data on Wayland systems.
When a window is made invisible, then visible again, the obs_display is reused. Turns out, QT destroys the wl_surface associated with the previewer on Wayland. However, the EGL surface created on top of this wl_surface is not, and any attempt to attach a new buffer to it will crash OBS. Destroy the obs_display when becoming invisible, and when running as a Wayland client. Also nullify the display variable on destruction, to avoid subclasses double-freeing the obs display.
Right after showing the OBSQTDisplay widget, it may happen that a wl_surface is not yet created and attached to the window. When this happens, creating the OBS display results in a crash. Make QTToGSWindow return a boolean, indicating success or failure, and don't create the OBS display on failure.
The sizeChanged callback is connected to the screenChanged signal, and evidently the naming doesn't match. Rename the callback to match the signal name.
This is a dangerous operation on Wayland, and is crashing not only OBS Studio but also the whole compositor. Let's disable it for now when running as a native Wayland client. Some compositors (GNOME Shell, Plasma) still allow setting this option on the window menu.
This will be used by a new event filter, added only when running as a Wayland client, to force creating the obs_display instance even when not exposed.
This is a workaround for QWaylandWindow never becoming exposed, or receiving the QEvent::Expose [1]. [1] https://bugreports.qt.io/browse/QTBUG-86176
e2cdcce
to
e67fdbc
Compare
This is arguably one of the most well done pull requests I've ever seen. Excellent work. Thank you so much for your patience with this. |
Thank you! |
I've been giving tests to this (Without the DMA BUF for now). I'm not sure if it's a memory leak or what, but sometimes the streaming starts lagging or stuttering a bit. I don't know what triggers it but I can see it on the OBS preview. In Gnome, going to the notification area, stopping the screen share, and selecting again the origin of the screen on the OBS makes it work well again. Arch Linux 5.10.16-zen1 |
I could get more or less an example, at some point my recording was like this: first.mp4Then all I did was stop screen share on Gnome, select again the origin of the screen source a record second.mp4I don't know if it's something related to OBS, Gnome, Mutter or what. |
obs-studio (git master) has native wayland support. To build further releases of obs-studio this adds wayland to buildInputs https://github.com/obsproject/obs-studio/wiki/Install-Instructions#linux-build-directions obsproject/obs-studio#2484
(This depends on #2478 and #2482 and thus includes its commits)
This pull requests builds on top of @w23 and @cyclopsian's work, and their code (or code heavily inspired by them) is appropriately credited.
Description
Add a new
gl-nix-egl-wayland
winsys tolibobs-opengl
, and hook the code to use this winsys when (1) Wayland is enabled, and (2) the current seat is a Wayland session.A couple of places where the codebase was tied to X11 had to be modified in order to be X11-agnostic.
Motivation and Context
This is the 3rd step of RFC #14.
The goal of this pull request is introduce the EGL/Wayland winsys to
libobs-opengl
.How Has This Been Tested?
Under a Wayland desktop environment, run:
$ QT_QPA_PLATFORM=wayland obs
My particular setup is Linux + GNOME + Wayland.
Known Issues
Types of changes
Checklist: