-
Notifications
You must be signed in to change notification settings - Fork 569
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
Move AnimFrame from lifecycle to event. #1155
Conversation
I don't have very strong feelings whether animframe is an event or a lifecycle; I think I originally had it as the former. I believe @cmyr was the main driver behind moving it to lifecycle, and might have a good argument why it should be kept there. |
the animation event is definitely one of the awkward corners of druid, as it currently exists. The reason I don't like In general, in druid, execution follows a very simple cycle:
The problem with Druid keeps a flag indicating whether or not it is currently animating. When you request an animation frame, we set this flag, and then ask The thing that is weird about the This is why A possible approach:It would be nice if we could make |
Some of what you wrote I changed in #1057, which is what made this PR feasible. The current situation is that when the OS tells druid-shell that it's time to repaint, druid-shell calls into druid twice. The first time, it calls This PR delivers the |
oh cool, yes, this does sound similar, and might be enough to make this change. One other concern I would have is that often when the OS is telling us to paint, we're really not expected to be doing anything else, and we possibly risk missing frames if we're doing a bunch of other stuff while handling that event; but I'm happy to just write that down and put the onus on the programmer to not be too silly. |
And to clarify: really the only basis of my having moved |
Ok, cool. I will do some cleanup and testing, and then remove the draft status.
This is a good point, and I've added a comment to |
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.
This looks entirely reasonable, and smooths over what was one of the uglier corners of the event loop, which makes me very happy. Thanks!
Great, thanks! @ForLoveOfCats are you close to landing #1107? If so, I can wait and rebase off that. |
I'll take another pass at #1107 soon. |
This should no longer be blocked! |
Fixes #1060.
I'm sure there's a good reason for the current placement of AnimFrame, so I definitely expect pushback on this; I'm mostly just exploring possible solutions for #1060, and this seemed like the easiest.
I think there is part of this patch that is worth salvaging in any case: it simplifies the handling of
last_anim
in window.rs, and it makes the behavior ofAnimFrame
match the documentation, even in the case that the animation is first requested in the event context (previously, that would lead toAnimFrame
having a non-zero initial value).