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

resize-limiter: add additional check for low-hz monitors #4553

Merged
merged 4 commits into from Mar 6, 2024

Conversation

bvr-yr
Copy link
Contributor

@bvr-yr bvr-yr commented Jan 28, 2024

Describe your PR, what does it fix/add?

adding 5-6 ms of delay can fix render lag on mouse movement events in some weird combo mouse + 60hz display

should fix #4542
should fix #4669

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

nope

Is it ready for merging, or does it need work?

ready

@bvr-yr bvr-yr force-pushed the main branch 3 times, most recently from 33254c6 to 9272021 Compare January 30, 2024 22:39
@vaxerski
Copy link
Member

unsure how this is supposed to fix anything tbh

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Jan 30, 2024

try forcing 60hz refresh rate and move wayland window with bindm, it moves like at 30fps
maybe it's because old hardware but i doubt, cause issue OP have relativly new (tigerlake) intel gpu

this just returns things like they were before 9f20a15 not breaking already done fixes

if there is different solution, sure, but atleast i tried :D

@vaxerski
Copy link
Member

christ 60hz is disgusting.

Anyways tried and can't see any issues.

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Jan 30, 2024

christ 60hz is disgusting.

what can i do it's builtin laptop display :p
imagine how it is like u are on 30hz when moving :D

with plugged 120hz moni its okay rendering on both

Anyways tried and can't see any issues.

well, it might be intel issue, as i'm not only one having this on intel
seen some reports here considering slow gpu wakeups even with forced maxed clock rate. without that forcing animations are noway

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Feb 2, 2024

i think i found the root cause of the problem

i tried with my old mouse (Logitech g603), which has two modes

  • low refresh - 125hz 8ms
  • high refresh - 1000hz 1ms

as well as some random wired mouse
all, including my current one sending events every ~8ms

so the timings on 60hz display are:

  7-8ms -> return
15-16ms -> return
23-24ms -> render

while g603 with in high mode sending events every 1-2ms with no render lag

@bvr-yr bvr-yr changed the title input: check on xwayland in resize limiter input: add delay for resize limiter as config option Feb 2, 2024
@burein-ita
Copy link

Just tested, don't know why but this indeed fixes #4542

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Feb 5, 2024

i suppose that's because of unlucky timings, returns occurs every 7-8 ms while threshold for 60hz is 16.666666ms, right after second return from limiter but there is too much lag before render happens

this is firing for default non-hi-res input devices on 60hz, and since that might be not the case for the majority of userbase, issue is pretty niche

@vaxerski is adding cfg option viable? or i could think on some another logic in checker

@vaxerski
Copy link
Member

vaxerski commented Feb 6, 2024

hm. I am still unsure what the best course of action is here. Maybe update the cursor pos all the time, and update resize status in a preRender hook?

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Feb 28, 2024

there's another related issue #4669
i doubt i can do more than adding cfg option, cause it will be a guessing from my side

feel free to close if you are planning to fix it in natural way, i can continue patching if needed

@vaxerski
Copy link
Member

I have no idea why that happens, but making the resize inherently more choppy is not the way to do it.

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Mar 5, 2024

could u please run this snippet from shell

declare -i n=0 total=0
unset time0 time1 m avg
(( ZSH_VERSION )) && m=1.0 || m=1
wev -f wl_pointer:motion | while read -r line; do
	n+=1
	time0=${line%;*}
	time0=${time0#*time: }
	(( delta = time0 - ${time1:-$time0} ))
	(( total += delta < 16 ? delta : avg ))
	(( avg = total * m / n ))
	echo "time:$time0  ms:$delta  avg:$avg"
	time1=${line%;*}
	time1=${time1#*time: }
done

move mouse a bit and paste few last lines

@vaxerski
Copy link
Member

vaxerski commented Mar 5, 2024

finna get a few trojans


time:16728829  ms:8  avg:7.9322033898
time:16728837  ms:8  avg:7.9327731092
time:16728845  ms:8  avg:7.9333333333
time:16728853  ms:8  avg:7.9338842975
time:16728861  ms:8  avg:7.9344262295
time:16728877  ms:16  avg:7.9268292683
time:16728885  ms:8  avg:7.9274193548
time:16728893  ms:8  avg:7.9280000000
time:16728901  ms:8  avg:7.9285714286
time:16728909  ms:8  avg:7.9291338583
time:16728917  ms:8  avg:7.9296875000
time:16728925  ms:8  avg:7.9302325581
time:16728933  ms:8  avg:7.9307692308
time:16728941  ms:8  avg:7.9312977099
time:16728949  ms:8  avg:7.9318181818
time:16728957  ms:8  avg:7.9323308271
time:16728965  ms:8  avg:7.9328358209
time:16728973  ms:8  avg:7.9333333333
time:16728981  ms:8  avg:7.9338235294
time:16728989  ms:8  avg:7.9343065693
time:16728997  ms:8  avg:7.9347826087
time:16729013  ms:16  avg:7.9280575540
time:16729021  ms:8  avg:7.9285714286
time:16729029  ms:8  avg:7.9290780142
time:16729037  ms:8  avg:7.9295774648
time:16729045  ms:8  avg:7.9300699301
time:16729053  ms:8  avg:7.9305555556
time:16729061  ms:8  avg:7.9310344828
time:16729069  ms:8  avg:7.9315068493

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Mar 5, 2024

nice, u also have shitty mouse

look, can we do like this?
as been reported in #4542 and #4669 issue arises mostly on 60hz
now, if 60hz, there is additional check making it not return 1 extra time and draw instead when input events are too slow

if mouse sends ~1ms (like g603 which i tested), maybe it will skip 1 or 2 returns out of ~15

although, 75hz been mentioned once, i can't see it stuttering, atleast on headless
but if needed, we can just lower bound to 13.0

@bvr-yr bvr-yr changed the title input: add delay for resize limiter as config option resize-limiter: add additional check for low-hz monitors Mar 5, 2024
@vaxerski
Copy link
Member

vaxerski commented Mar 5, 2024

nice, u also have shitty mouse

I don't, I just am not stupid enough to set it to 1000hz. This is a deathadder v2

@vaxerski
Copy link
Member

vaxerski commented Mar 5, 2024

I can't see any stutters even on 1khz

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Mar 5, 2024

but u won't, it's only 60hz and 7-8ms

if any, 1khz mouse or high rr moni = ok

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Mar 5, 2024

that's the problem, when both conditions are met:

return
return
draw
return
return
draw

now its

return
draw
return
draw

src/layout/IHyprLayout.cpp Outdated Show resolved Hide resolved
@bvr-yr bvr-yr requested a review from vaxerski March 5, 2024 22:09
src/layout/IHyprLayout.cpp Outdated Show resolved Hide resolved
Copy link
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.

united we stand

@vaxerski vaxerski merged commit fb87e33 into hyprwm:main Mar 6, 2024
11 checks passed
@Sinaaaa
Copy link

Sinaaaa commented Mar 6, 2024

I thought the bad floating window movement performance was on my haswell igpu, but hey this thing seems to have made quite a positive difference. Thank you ~

@bvr-yr
Copy link
Contributor Author

bvr-yr commented Mar 6, 2024

yeah, it was confusing. initially i thought the same (lulswell too), but people on Tigerlake had same problem, and it is pure luck i have 2 monitors and switchable mouse to catch the problem

glad to help
no more yay --editmenu thank god

lisuke pushed a commit to lisuke/Hyprland that referenced this pull request Apr 15, 2024
…ow-hz monitors (hyprwm#4553)

* resize-limiter: add additional check for low-hz monitors

* simplify checker

* add comment

* rename variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sluggish moving windows in 0.35 9f20a15 Introduces subtle stuttering when moving floating windows
4 participants