-
Notifications
You must be signed in to change notification settings - Fork 948
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
Remove RedrawEventsCleared + MainEventsCleared, and add AboutToWait #2976
Remove RedrawEventsCleared + MainEventsCleared, and add AboutToWait #2976
Conversation
9c9cf41
to
7c10ff8
Compare
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.
The change is implemented correctly internally, however the top level docs are wrong, given that you've basically renamed RedrawEventsCleared
, but made it in a way that it'll make sense.
And MainEventsCleared
is the thing you've actually removed, not RedrawEventsCleared
.
The top level docs are all wrong in the end. Basically we should say that the event is emitted when the event loop is about to go to sleep. We could also comment that you could request_redraw
from it to wake up a loop once OS will think that it's a good time to draw.
@daxpedda I remember that on Web and likely on macOS due to its callback design the time between so called poll intervals could be really long. So the users should rely on redraw_requested
for contiguous drawing based on the request animation frame (and on macOS based on some display link calls).
@rib that means that we should probably just say that the AboutToWait
is called when the event is about to go back to waiting for events, meaning that we should drop all the mentions in relative to rendering.
We could also say that no event could occur after this event (right?).
This is semantics. I actually did a The exact provenance isn't super important but at least the way that I intuitively see it is that I removed RedrawEventsCleared and renamed MainEventsCleared since that's actually what I did from a typing pov. all that really matters here is the end result. |
This is true, but the documentation is now wrong. |
7c10ff8
to
a4217d5
Compare
615c359
to
df8eaea
Compare
Okey, I've tried to do a better job of updating the docs - sorry I didn't really do that properly before. |
With the updates I've just pushed I've generally reframed it as having removed both events and added a new This only really affects the commit message and the changelog though. |
Although I put a small note about Web in the commit message, I wonder if we should have a small platform-specific note for |
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.
We'll have to target a different branch now though.
a4217d5
to
d2709b6
Compare
df8eaea
to
4ed3e31
Compare
github will automatically move the base branch along if they are merged in the order they are stacked |
4ed3e31
to
aabc349
Compare
The idea that redraw events are dispatched with a specific ordering that makes it possible to specifically report when we have finished dispatching redraw events isn't portable and the way in which we dispatched RedrawEventsCleared was inconsistent across backends. More generally speaking, there is no inherent relationship between redrawing and event loop iterations. An event loop may wake up at any frequency depending on what sources of input events are being listened to but redrawing is generally throttled and in some way synchronized with the display frequency. Similarly there's no inherent relationship between a single event loop iteration and the dispatching of any specific kind of "main" event. An event loop wakes up when there are events to read (e.g. input events or responses from a display server / compositor) and goes back to waiting when there's nothing else to read. There isn't really a special kind of "main" event that is dispatched in order with respect to other events. What we can do more portably is emit an event when the event loop is about to block and wait for new events. In practice this is very similar to how MainEventsCleared was implemented except it wasn't the very last event previously since redraw events could be dispatched afterwards. The main backend where we don't strictly know when we're going to wait for events is Web (since the real event loop is internal to the browser). For now we emulate AboutToWait on Web similar to how MainEventsCleared was dispatched. In practice most applications almost certainly shouldn't care about AboutToWait because the frequency of event loop iterations is essentially arbitrary and usually irrelevant.
d2709b6
to
9c7f440
Compare
This is one of the follow ups for #2900, assuming that #2767 hopefully lands soon.
The idea that redraw events are dispatched with a specific ordering that makes it possible to specifically report when we have finished dispatching redraw events isn't portable and the way in which we dispatched RedrawEventsCleared was inconsistent across backends.
More generally speaking, there is no inherent relationship between redrawing and event loop iterations. An event loop may wake up at any frequency depending on what sources of input events are being listened to but redrawing is generally throttled and in some way synchronized with the display frequency.
Similarly there's no inherent relationship between a single event loop iteration and the dispatching of any specific kind of "main" event.
An event loop wakes up when there are events to read (e.g. input events or responses from a display server / compositor) and goes back to waiting when there's nothing else to read.
There isn't really a special kind of "main" event that is dispatched in order with respect to other events.
For what MainEventsCleared is used for by applications then the most portable interpretation of what applications want is to know when the event loop is about to block and wait for new events.
In practice most applications almost certainly shouldn't care about this because the frequency of event loop iterations is essentially arbitrary but it's reasonably portable to expose this.
MainEventsCleared has been renamed to AboutToWait and is the last event emitted in each iteration of the event loop.
CHANGELOG.md
if knowledge of this change could be valuable to usersNote: the base for this PR isn't currently set to master, since it's stacked on the changes for #2975