Skip to content

protocols: add Fifo-v1 and commit-timing-v1#12052

Merged
vaxerski merged 14 commits into
hyprwm:mainfrom
gulafaran:fifo
Nov 6, 2025
Merged

protocols: add Fifo-v1 and commit-timing-v1#12052
vaxerski merged 14 commits into
hyprwm:mainfrom
gulafaran:fifo

Conversation

@gulafaran
Copy link
Copy Markdown
Contributor

@gulafaran gulafaran commented Oct 15, 2025

introduce fifo-v1 and commit-timing-v1

TODO

  • add commit-timing-v1
  • properly test fifo-v1
  • properly test commit-timing-v1
  • ensure nothing else broke because of CSurfaceStateQueue

fixes: #11386

@gulafaran gulafaran changed the title protocols: add Fifo-v1 and CommitTiming protocols: add Fifo-v1 and commit-timing-v1 Oct 15, 2025
@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Oct 17, 2025

playing video in mpv keeps freezing, continuously moving the mouse avoids it

@gulafaran
Copy link
Copy Markdown
Contributor Author

playing video in mpv keeps freezing, continuously moving the mouse avoids it

Bleh, so it wasnt buffers being held up. made it work here. Hrmhm. Thanks

@ikalco
Copy link
Copy Markdown
Contributor

ikalco commented Oct 18, 2025

this generally LGTM
I don't have time to test but here are some things that might break

  • minecraft with vsync vs unlimited fps and fullscreen (ds) vs windowed
  • csgo windowed + ds
  • vkcube windowed + ds
  • screensharing with obs (screencopy + toplevel export)

@gulafaran
Copy link
Copy Markdown
Contributor Author

this generally LGTM I don't have time to test but here are some things that might break

* minecraft with vsync vs unlimited fps and fullscreen (ds) vs windowed

* csgo windowed + ds

* vkcube windowed + ds

* screensharing with obs (screencopy + toplevel export)

i think tearing might be affected aswell, The condition is cleared immediately after the following latching deadline for non-tearing presentation.

however i still havent figured out why mpv is being annoyed. its almost like there is an upper render scheduling/damage issue. vfr = 0 or damage_bling = 1 or simply scheduling a monitor frame at the end of each renderMonitor which those two settings kinda does. makes it not drop frames nor freeze

@gulafaran
Copy link
Copy Markdown
Contributor Author

@fxzzi i assume something like this makes mpv work for you too?

@g3r
Copy link
Copy Markdown

g3r commented Oct 18, 2025

@fxzzi i assume something like this makes mpv work for you too?

I'm also having this issue with mpv, I tested the latest commit and if I launch a video from the terminal it works fine. But if I open the video from dolphin without background applications causing damage (pressing Enter or double-click without moving the mouse) The mpv window doesn't appear until I move the mouse, after that it seems to works fine.
It seems that if there is something in the background causing damage, the window appears

@gulafaran
Copy link
Copy Markdown
Contributor Author

@fxzzi i assume something like this makes mpv work for you too?

I'm also having this issue with mpv, I tested the latest commit and if I launch a video from the terminal it works fine. But if I open the video from dolphin without background applications causing damage (pressing Enter or double-click without moving the mouse) The mpv window doesn't appear until I move the mouse, after that it seems to works fine. It seems that if there is something in the background causing damage, the window appears

yeah probably didnt have entered an output, yet. and poof that scheduleframe never triggers. atleast we are rounding in where the issue is just gotta figure out something proper, thanks.

@gulafaran
Copy link
Copy Markdown
Contributor Author

@fxzzi i assume something like this makes mpv work for you too?

I'm also having this issue with mpv, I tested the latest commit and if I launch a video from the terminal it works fine. But if I open the video from dolphin without background applications causing damage (pressing Enter or double-click without moving the mouse) The mpv window doesn't appear until I move the mouse, after that it seems to works fine. It seems that if there is something in the background causing damage, the window appears

how about now?

@g3r
Copy link
Copy Markdown

g3r commented Oct 18, 2025

how about now?

Tested mpv and vkcube. All seems to be fine now. Thanks.

@gulafaran gulafaran marked this pull request as ready for review October 18, 2025 23:12
@gulafaran
Copy link
Copy Markdown
Contributor Author

added 720a468 since we already are touching all sorts of surface state commits, lets improve if further if possible. still needs some VRR and random other usage testing so it doesnt regress.

@gulafaran
Copy link
Copy Markdown
Contributor Author

added 720a468 since we already are touching all sorts of surface state commits, lets improve if further if possible. still needs some VRR and random other usage testing so it doesnt regress.

i think it might be problematic if a later buffer commit becomes ready before the first. so it essentially skips the first and just merges into the last one. but i havent yet seen that occur here

@gulafaran
Copy link
Copy Markdown
Contributor Author

added 720a468 since we already are touching all sorts of surface state commits, lets improve if further if possible. still needs some VRR and random other usage testing so it doesnt regress.

i think it might be problematic if a later buffer commit becomes ready before the first. so it essentially skips the first and just merges into the last one. but i havent yet seen that occur here

added 720a468 since we already are touching all sorts of surface state commits, lets improve if further if possible. still needs some VRR and random other usage testing so it doesnt regress.

i think it might be problematic if a later buffer commit becomes ready before the first. so it essentially skips the first and just merges into the last one. but i havent yet seen that occur here

nvm 0a3d39d thinking about it. certain changes are relative to the buffer attached, cant go beyond it
and apply those onto the next buffer.

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Oct 21, 2025

SDL2 and SDL3 are still causing Hyprland to crash when in native wayland.

osu!lazer with OSU_SDL3=1 crashes - because fifo and commit timing are available, SDL3 picks wayland by default, then proceeds to crash
osu!lazer with SDL_VIDEODRIVER=wayland - without above env var osu! runs with SDL2, which never sets wayland by default. Setting to wayland makes Hyprland crash
CS2 with SDL_VIDEO_DRIVER=wayland - cs2 launch script sets to x11 by default, so env var is needed even though its SDL3. Causes crash
CS:Source with STEAM_COMPAT_RUNTIME_SDL2=sdl2-compat SDL_VIDEO_DRIVER=wayland also crashes. env vars above make it use SDL3, i assume it'll crash with SDL2 as well.

hyprlandCrashReport3626.txt

(mpv issues from before are fixed)

@AntoSkate
Copy link
Copy Markdown

AntoSkate commented Oct 21, 2025

After some quick testing i came across 2 issues:

  • Resizing fifo apps is broken on both tiled and floating modes (works fine on master)

This PR

fifo_pr.mp4

Master

master.mp4
  • CS2 crashes the compositor soon after launch (also doesn't happen on master)
cs2.mp4

Also i'm on nvidia if it's relevant

@gulafaran
Copy link
Copy Markdown
Contributor Author

SDL2 and SDL3 are still causing Hyprland to crash when in native wayland.

osu!lazer with OSU_SDL3=1 crashes - because fifo and commit timing are available, SDL3 picks wayland by default, then proceeds to crash osu!lazer with SDL_VIDEODRIVER=wayland - without above env var osu! runs with SDL2, which never sets wayland by default. Setting to wayland makes Hyprland crash CS2 with SDL_VIDEO_DRIVER=wayland - cs2 launch script sets to x11 by default, so env var is needed even though its SDL3. Causes crash CS:Source with STEAM_COMPAT_RUNTIME_SDL2=sdl2-compat SDL_VIDEO_DRIVER=wayland also crashes. env vars above make it use SDL3, i assume it'll crash with SDL2 as well.

hyprlandCrashReport3626.txt

(mpv issues from before are fixed)

the heck...

2025-10-21-185927_hyprshot

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Oct 21, 2025

👀

weird, person above also has same crash

@gulafaran
Copy link
Copy Markdown
Contributor Author

After some quick testing i came across 2 issues:

* Resizing fifo apps is broken on both tiled and floating modes (works fine on master)

This PR
fifo_pr.mp4

Master
master.mp4

* CS2 crashes the compositor soon after launch (also doesn't happen on master)

cs2.mp4

Also i'm on nvidia if it's relevant

👀

weird, person above also has same crash

yeah, atleast i got proof i did test things :D , il dig hrmlm. this is why i wanted more people testing because weird things happends all the time when it comes to buffers lol. fix one thing break 3 other. thanks.

@gulafaran
Copy link
Copy Markdown
Contributor Author

ok that should handle the crashes, kwin apparently also blocks fifo when actively tearing. i guess its up to debate what todo here. block fifo or block tearing?. and il see if i cant make it cleaner later.

il see what that resizing vkcube is about, might be a day away if i dont find it shortly. working 2 long days.

@AntoSkate
Copy link
Copy Markdown

ok that should handle the crashes, kwin apparently also blocks fifo when actively tearing. i guess its up to debate what todo here. block fifo or block tearing?. and il see if i cant make it cleaner later.

il see what that resizing vkcube is about, might be a day away if i dont find it shortly. working 2 long days.

can confirm it doesn't crash anymore 🎉
btw it's not only vkcube but also mpv (so probably every app that uses fifo)

dont fifo lock on tearing.
queue the state directly and use the .lock function instead of directly
modify the lockMask on the state.
fifo barriers introduces such long wait that upon commit time a
race happends with current xdg configure implentation that the buffer
and image is actually destroyed when entering commitState, doing it at
buffer creation time with EGL_PRESERVED_KHR means it sticks around until
we are done. so revert 82759d4 and 32f3233 for now.
@gulafaran
Copy link
Copy Markdown
Contributor Author

did u set render:new_render_scheduling in the hyprland config file?

i've had it set to false since it was introduced

ok how about now?

@gulafaran
Copy link
Copy Markdown
Contributor Author

b188e1b should atleast solve resizing issues, cs2 im unsure since i cant reproduce it

@AntoSkate
Copy link
Copy Markdown

b188e1b should atleast solve resizing issues, cs2 im unsure since i cant reproduce it

it solved both vkcube and mpv on my end :O
but cs2 still has the same issue :/

@gulafaran
Copy link
Copy Markdown
Contributor Author

b188e1b should atleast solve resizing issues, cs2 im unsure since i cant reproduce it

it solved both vkcube and mpv on my end :O but cs2 still has the same issue :/

do you have vrr on and you sure this doesnt occur on -git without this PR?

Copy link
Copy Markdown
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generall lgtm

Comment thread src/protocols/types/SurfaceState.hpp Outdated
Comment thread src/protocols/types/SurfaceState.hpp Outdated
Comment thread src/protocols/types/SurfaceState.hpp Outdated
eLockReason and LOCK_REASON_NONE.
@vaxerski
Copy link
Copy Markdown
Member

@AntoSkate what about that cs2 issue?

@AntoSkate
Copy link
Copy Markdown

do you have vrr on and you sure this doesnt occur on -git without this PR?

i have vrr off and i retested it doesn't happen on master
sorry for late response btw i was away this weekend

@AntoSkate
Copy link
Copy Markdown

also tested this pr with vrr and without mangohud for science and it still freezes

@gulafaran
Copy link
Copy Markdown
Contributor Author

yeah gonna need some way to reproduce it to figure out why, tried nvidia, intel, dual monitors. single monitor. vrr, tearing, you name it. still doesnt occur here

@AntoSkate
Copy link
Copy Markdown

AntoSkate commented Oct 28, 2025

I just tested on a friends pc with my config and everything and i couldn't reproduce it either 💀
i really don't know at this point everything else has been resolved

@AntoSkate
Copy link
Copy Markdown

i forgot to set game to native wayland on his pc. can riproduce now on full amd system💀

@gulafaran
Copy link
Copy Markdown
Contributor Author

also tested this pr with vrr and without mangohud for science and it still freezes

i pulled my hair until i got a bald spot for the past 12 hours. it might have been there already who knows. I CAN REPRODUCE. for some reason i never figured the ingame vsync option was the important bit to hit it. now im making an appointment to the barber and while waiting im looking into this freeze.

@AntoSkate
Copy link
Copy Markdown

i pulled my hair until i got a bald spot for the past 12 hours. it might have been there already who knows. I CAN REPRODUCE. for some reason i never figured the ingame vsync option was the important bit to hit it. now im making an appointment to the barber and while waiting im looking into this freeze.

Dang I might have to send some to cover for barber expenses 😂

@UjinT34
Copy link
Copy Markdown
Contributor

UjinT34 commented Oct 28, 2025

Freezes might be caused by modeset or other vrr/ds/hdr transitions. Cyberpunk freezes for a couple of seconds when it starts (audio keeps playing).

VRR seems to have less jitter now. Earlier it could jump all the way between min and max rate while keeping the same average, now it's only +-3hz or so.

@gulafaran
Copy link
Copy Markdown
Contributor Author

Freezes might be caused by modeset or other vrr/ds/hdr transitions. Cyberpunk freezes for a couple of seconds when it starts (audio keeps playing).

VRR seems to have less jitter now. Earlier it could jump all the way between min and max rate while keeping the same average, now it's only +-3hz or so.

nah its fifo. the nuke debug it alll patch makes it not freeze. now just to figure out why.

diff --git a/src/protocols/CommitTiming.cpp b/src/protocols/CommitTiming.cpp
index 2fcd8e9c..d2d71a04 100644
--- a/src/protocols/CommitTiming.cpp
+++ b/src/protocols/CommitTiming.cpp
@@ -43,7 +43,8 @@ CCommitTimerResource::CCommitTimerResource(UP<CWpCommitTimerV1>&& resource_, SP<
         if (!m_pendingTimeout.has_value())
             return;
 
-        m_surface->m_stateQueue.lock(state, LOCK_REASON_TIMER);
+        //m_surface->m_stateQueue.lock(state, LOCK_REASON_TIMER);
+        LOGM(ERR, "locking timer");
 
         if (!m_timerPresent) {
             m_timerPresent = true;
@@ -53,7 +54,8 @@ CCommitTimerResource::CCommitTimerResource(UP<CWpCommitTimerV1>&& resource_, SP<
                     if (!m_surface)
                         return;
 
-                    m_surface->m_stateQueue.unlockFirst(LOCK_REASON_TIMER);
+                    //m_surface->m_stateQueue.unlockFirst(LOCK_REASON_TIMER);
+                    LOGM(ERR, "unlocking timer");
                 },
                 nullptr);
         } else
diff --git a/src/protocols/Fifo.cpp b/src/protocols/Fifo.cpp
index 63ce8579..dcfe2d27 100644
--- a/src/protocols/Fifo.cpp
+++ b/src/protocols/Fifo.cpp
@@ -66,8 +66,11 @@ CFifoResource::CFifoResource(UP<CWpFifoV1>&& resource_, SP<CWLSurfaceResource> s
         }
 
         // only lock once its mapped.
-        if (m_surface->m_mapped)
-            m_surface->m_stateQueue.lock(state, LOCK_REASON_FIFO);
+        if (m_surface->m_mapped) {
+            LOGM(ERR, "locking fifo");
+            //m_surface->m_stateQueue.lock(state, LOCK_REASON_FIFO);
+        }
+
 
         m_pending = {};
     });
@@ -82,7 +85,8 @@ bool CFifoResource::good() {
 }
 
 void CFifoResource::presented() {
-    m_surface->m_stateQueue.unlockFirst(LOCK_REASON_FIFO);
+    LOGM(ERR, "unlocking fifo");
+    //m_surface->m_stateQueue.unlockFirst(LOCK_REASON_FIFO);
 }
 
 CFifoManagerResource::CFifoManagerResource(UP<CWpFifoManagerV1>&& resource_) : m_resource(std::move(resource_)) {

@fxzzi
Copy link
Copy Markdown
Contributor

fxzzi commented Oct 28, 2025

VRR seems to have less jitter now. Earlier it could jump all the way between min and max rate while keeping the same average, now it's only +-3hz or so.

can confirm, vrr feels great now with this PR, and my OSD reports only fluctuations of about 1-2Hz all the way from 49Hz to 170Hz for me.

I am wondering whether VRR below the minimum VRR range is up to the compositor or the driver to handle? With my Nvidia GPU on linux and using vrrtest, when I reach my minimum of 48Hz, VRR pretty much breaks. In theory what it should do is double the frames sent to make the frame count effectively be within the VRR range, so for example 30fps should show 60 on the monitor OSD.

workaround cursor commits causing fifo to get forever locked, this
entire thing needs to be worked out.
@gulafaran
Copy link
Copy Markdown
Contributor Author

ok so pushed a workaround, it however causes fifo to not work as intended in direct scanout. every once in a while it unlocks to early. but atleast things arent forever frozen. gonna see if i cant figure out something more proper later

@vaxerski vaxerski merged commit 8e8bfbb into hyprwm:main Nov 6, 2025
13 checks passed
@cpiber
Copy link
Copy Markdown

cpiber commented Nov 6, 2025

This PR breaks building plugins with following error:

/usr/bin/g++-14 -shared -fPIC  main.cpp borderDeco.cpp BorderppPassElement.cpp -o borders-plus-plus.so -g `pkg-config --cflags pixman-1 libdrm hyprland pangocairo libinput libudev wayland-server xkbcommon` -std=c++2b -O2
In file included from /usr/include/hyprland/src/render/OpenGL.hpp:33,
                 from /usr/include/hyprland/src/render/Renderer.hpp:7,
                 from main.cpp:9:
/usr/include/hyprland/src/protocols/core/Compositor.hpp:16:10: fatal error: protocols/types/SurfaceStateQueue.hpp: No such file or directory
   16 | #include "protocols/types/SurfaceStateQueue.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

The include here should be relative, like #include "../protocols/types/ContentType.hpp" I think, same for the one in src/protocols/types/SurfaceState.cpp (?), only src/protocols/FrogColorManagement.cpp does not do the relative include, and I'd assume that breaks in plugins as well

Edit: Ignore the comment, didn't see #12228 which is now merged

ArchSav pushed a commit to ArchSav/Hyprland that referenced this pull request Nov 17, 2025
* protocols: add Fifo-v1

introduce fifo-v1

* fifo: only present locked surfaces

dont present to unlocked surfaces and commit pending states from the
fifo protocol.

* fifo: cformat

cformat

* protocols: add committiming and surface state queue

introduce CSurfaceStateQueue and commit-timing-v1

* fifo: schedule a frame if waiting on barrier

if we are waiting on a barrier the state doesnt commit until the next
refresh cycle meaning the monitor might have no pending damage and we
never get onPresented to unlock the barrier, moment 22. so schedule a
frame.

* fifo: properly check monitor intersection

check for m_enteredoutputs or monitor intersection if client hasnt bound
one yet, and dont fifo lock it until the surface is mapped.

* buffer: try to merge states before committing them

try to merge states before committing them meaning way less churn and
surface commits if a surface sends multiple small ones while we wait for
buffer readyness from either fifo locks or simply fences.

* buffer: dont commit states past the buffer

certain changes are relative to the buffer attached, cant go beyond it
and apply those onto the next buffer.

* buffer: set the lockmask directly

cant use .lock since the state hasnt been queued yet, set the lockmask
directly when exporting buffer fence.

* fifo: dont fifo lock on tearing

dont fifo lock on tearing.

* buffer: queue the state directly

queue the state directly and use the .lock function instead of directly
modify the lockMask on the state.

* buffer: revert creating texture at commit time

fifo barriers introduces such long wait that upon commit time a
race happends with current xdg configure implentation that the buffer
and image is actually destroyed when entering commitState, doing it at
buffer creation time with EGL_PRESERVED_KHR means it sticks around until
we are done. so revert 82759d4 and 32f3233 for now.

* buffer: rename enum and lockreasons

eLockReason and LOCK_REASON_NONE.

* fifo: workaround direct scanout lock

workaround cursor commits causing fifo to get forever locked, this
entire thing needs to be worked out.
crthpl pushed a commit to crthpl/Hyprland that referenced this pull request Jun 3, 2026
* protocols: add Fifo-v1

introduce fifo-v1

* fifo: only present locked surfaces

dont present to unlocked surfaces and commit pending states from the
fifo protocol.

* fifo: cformat

cformat

* protocols: add committiming and surface state queue

introduce CSurfaceStateQueue and commit-timing-v1

* fifo: schedule a frame if waiting on barrier

if we are waiting on a barrier the state doesnt commit until the next
refresh cycle meaning the monitor might have no pending damage and we
never get onPresented to unlock the barrier, moment 22. so schedule a
frame.

* fifo: properly check monitor intersection

check for m_enteredoutputs or monitor intersection if client hasnt bound
one yet, and dont fifo lock it until the surface is mapped.

* buffer: try to merge states before committing them

try to merge states before committing them meaning way less churn and
surface commits if a surface sends multiple small ones while we wait for
buffer readyness from either fifo locks or simply fences.

* buffer: dont commit states past the buffer

certain changes are relative to the buffer attached, cant go beyond it
and apply those onto the next buffer.

* buffer: set the lockmask directly

cant use .lock since the state hasnt been queued yet, set the lockmask
directly when exporting buffer fence.

* fifo: dont fifo lock on tearing

dont fifo lock on tearing.

* buffer: queue the state directly

queue the state directly and use the .lock function instead of directly
modify the lockMask on the state.

* buffer: revert creating texture at commit time

fifo barriers introduces such long wait that upon commit time a
race happends with current xdg configure implentation that the buffer
and image is actually destroyed when entering commitState, doing it at
buffer creation time with EGL_PRESERVED_KHR means it sticks around until
we are done. so revert d6e42ac and e036393 for now.

* buffer: rename enum and lockreasons

eLockReason and LOCK_REASON_NONE.

* fifo: workaround direct scanout lock

workaround cursor commits causing fifo to get forever locked, this
entire thing needs to be worked out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement fifo v1

10 participants