Skip to content
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

wayland: fix and enable by default #12333

Merged
merged 2 commits into from
Feb 21, 2025
Merged

wayland: fix and enable by default #12333

merged 2 commits into from
Feb 21, 2025

Conversation

GovanifY
Copy link
Member

@GovanifY GovanifY commented Feb 20, 2025

Following the original discovery that Qt's wl_surface lifetime were broken around 8 months ago, here's another upstream Qt bug!

Qt has two types of rendering for its widgets, alien and native. While alien is usually more efficient and allows Qt to handle its own refresh primitives, native window rendering is necessary if we want to paint to a widget ourselves (see Qt::WA_PaintOnScreen ).

Unfortunately, this comes with the side effect of letting the compositor decide how to deal with those surfaces.
Compositors that do not implement SSD, like GNOME (mutter) or weston do not by design refresh the way Qt assumes, thus leading to pretty borked results on those OSes for some widgets, for example:

image

As such, let's disable native window rendering for everything but the DisplayWidget.

This bug is reported and tracked upstream: https://bugreports.qt.io/browse/QTBUG-133919
POC: https://projects.govanify.com/govanify/qt-native-wayland-borked

NB: Do we want to enable alien rendering for every platform out of Wayland? Qt's documentation do mention that they are more efficient, but I only enabled it for wayland for now in fear of breakage.
EDIT: added alien widget rendering for all platforms as windows testing showed a performance boost

image

Suggested Testing Steps

DO EVERYTHING YOU CAN TO MAKE IT BREAK!
Be sure to test GNOME wayland in priority, and don't hesitate to do weird things with the window, like hide, unhide, rotate 33° idk.

@GovanifY GovanifY force-pushed the govanify/wayland branch 2 times, most recently from 20f4495 to c28ef97 Compare February 20, 2025 22:44
@JordanTheToaster
Copy link
Member

JordanTheToaster commented Feb 20, 2025

Spent a little bit with this enabled on Windows and it was all good there so it would be worthwhile just enabling this globally.

image

@GovanifY
Copy link
Member Author

Enabling it globally, as alien widget rendering is more performant as I said originally and windows testing seems to be fine
image

This is a workaround for QTBUG-133919
@AmyRoxwell
Copy link

I wonder, to test this do we want to launch it with the env I_WANT_A_BROKEN_WAYLAND_UI=YES set or do we just launch it as normal?

@kamfretoz
Copy link
Contributor

kamfretoz commented Feb 21, 2025

I wonder, to test this do we want to launch it with the env I_WANT_A_BROKEN_WAYLAND_UI=YES set or do we just launch it as normal?

Launch it as normal and it'll run in native wayland by default, since the I_WANT_A_BROKEN_WAYLAND_UI=YES env var has been removed

@AmyRoxwell
Copy link

(Left is Master, Right is PR)

This fixes:

  1. The right slider is much smoother and doesn't suddenly stops working if you move the mouse too much to the left or right on this version compared to the x11 version.
    Video Demonstration: https://www.youtube.com/watch?v=yCD9AN0TdSA

  2. Game list doesn't seem to break after you stop emulation (I remember this being a big problem with the old wayland version).

  3. Overall, It feels smoother to move the window around, going through the pcsx2 menus, etc. compared to Xwayland (This is very noticeable while going from windowed to fullscreen, on Xwayland it takes 10 seconds to go into fullscreen sometimes. Meanwhile wayland it's instant)

This doesn't fix:

  1. Window not saving the position it was left on after you close the application. (Might cause issues if you have pcsx2 in another monitor) but it saves the shape it had.

  2. Resizing the window is a bit worse, it freaks out more compared to xwayland, even by just resizing a bit. Log doesn't say anything useful.
    Video Demonstration of the worst case scenario: https://www.youtube.com/watch?v=Y3edmIA3Rwc

@GovanifY
Copy link
Member Author

  1. Window not saving the position it was left on after you close the application. (Might cause issues if you have pcsx2 in another monitor) but it saves the shape it had.

This is to be expected, as wayland does not support absolute positioning. It would break environments like gnome or tiling wms a la sway.
Maybe we should keep the main window open while starting the fullscreen subsurface so that when fullscreen exits it goes back to it?

2. Resizing the window is a bit worse, it freaks out more compared to xwayland, even by just resizing a bit. Log doesn't say anything useful.
Video Demonstration of the worst case scenario: https://www.youtube.com/watch?v=Y3edmIA3Rwc

Proooobably due to QTBUG-133919 fucking up with native. Unsure I can do anything about this...

@GovanifY GovanifY merged commit f449b54 into master Feb 21, 2025
22 checks passed
@GovanifY GovanifY deleted the govanify/wayland branch February 21, 2025 11:31
@PCSX2 PCSX2 locked as spam and limited conversation to collaborators Feb 21, 2025
@PCSX2 PCSX2 deleted a comment from ryzendew Feb 21, 2025
@refractionpcsx2
Copy link
Member

If you've come here to try and poke fun at us fixing a wayland bug we said wasn't our fault, well if you read the OP it's an upstream bug and this is a workaround.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants