-
Notifications
You must be signed in to change notification settings - Fork 920
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
Use setTimeout()
trick instead of Window.requestIdleCallback()
#3044
Conversation
This method seems to be very unstable, the frametimes vary a lot on both firefox and chrome for me, it does however fix the issue. I'll create a small minimal reproducible example in hopes of narrowing it down, I think idleCallback is the lesser of the two evils here and should be preferred. Maybe something like a rust version of the javascript noop requestAnimationFrame could be ductaped onto it |
Update: It is not a bug in winit 10000% confirmed, requestIdleCallback is fine
the actual workload in the loop seems to make no difference Seeing as this is strictly worse than It feels out of scope for winit to try and solve as it's likely a browser implementation detail |
Could you specify what exactly doesn't work? This patch doesn't actually touch rAF (
I wouldn't dismiss the possibility out of hand, we don't understand their throttling algorithm, so it might be that itch.io is causing throttling somehow that we don't know how to reproduce. Thank you so much for looking into it though. |
newEvents using this PR does indeed run as fast as it can with something about 0.2ms on firefox and ~2ms on chrome inbetween, it does however cause redrawrequested to skip about 5ish frames so it runs at 12fps mostly. After more testing it seems that's only an issue on firefox because of course it is whereas with IdleCallback you get one event in sync with the redraw and that gets called as you'd expect at about 60fps.
I was refering to the loop-pausing-bug appearing, only appears on itch I preemptively claimed this method as worse before checking deeper do you think there's a way to keep this behaviour on chrome and increase the timeout on firefox to something comparable? I tested in the place where the timeout gets requested when duration is None, to just set it to 2ms and that fixes the performance issue on firefox and keeps working on chrome so it seems to be just a busyness issue, im not sure how it degrades when redrawrequested takes longer or some other event handler takes longer (or if that even matters) that might be the """"fix"""" unless you see glaring issues, other than it turning |
! Actually after some testing I reproduced this. Will debug it and see if I can fix it.
I think the issue in general is just that Firefox is throttled badly because In general though I'm not entirely sure what the use-case for In any case, will report back. |
Okay, so this has nothing to do with Winit indeed. Firefox is just not very good with handling this kind of performance pressure. I would recommend you to not use After I implement #3042 I can expose |
Chrome should work even better now. |
I think that's reasonable, one concern i have is how it might affect the ecosystem as polling is the default |
I don't have enough knowledge about how |
tested and wow yeah chrome now has the same delay as firefox |
This reverts #2880 and instead uses a trick to prevent
setTimeout()
to throttle to 4ms.On Chrome this should use the new Prioritized Task Scheduling API instead, which I will implement as a follow up.
Using
Window.requestIdleCallback()
should still remain an option for it's tradeoffs, which can be re-implemented after #3042.Cc @GloopShlugger.