[Xcb] Frame synchronization
Sam Varshavchik
mrsam at courier-mta.com
Wed Feb 20 12:04:50 UTC 2019
VaL writes:
> If there is no any more resizing,
> you increment the counter, render your frame, increment again and wait for
> _NET_WM_FRAME_DRAWN,
> but it is not sent, there is no more _NET_WM_FRAME_DRAWN events?
As best as I can understand the extended synchronization protocol: you're
getting _NET_WM_FRAME_DRAWN in response to you incrementing the counter to
indicate a drawn frame. You expect to get it in response to every drawn
frame, and this is independent of whether or not the window is being
resized; and you have to wait until you get the message before you increment
the counter indicating that you're drawing the next frame. The whole purpose
of the previous counter's update was to tell the window manager to proceed
and compose your finished frame, and you won't touch the frame buffer until
that's done. You're waiting until that's done, and you get a
_NET_WM_FRAME_DRAWN, then you can draw the next frame.
When _NET_WM_SYNC_REQUEST enters the picture, it tells you the specific
counter value you must set after you receive configure and exposure events
that you have coming, and, presumably, after drawing the frame using the new
window configuration. You may get a _NET_WM_SYNC_REQUEST before or after
getting the last frame's _NET_WM_FRAME_DRAWN. Clearly you can get it after.
You drew the last frame, and got it's _NET_WM_FRAME_DRAWN. There is no law
that requires you to draw the next frame immediately. You might decide to
take a coffee break and not draw anything. Thirty seconds later your
window's getting resized, so you get a _NET_WM_SYNC_REQUEST out of the blue.
But you can also get it before as well. 30 second later you finished your
coffee break you decide to draw the next frame, so you inrement the counter
and start drawing. At the same time the window manager decides to resize
your window. It hasn't seen your new counter update, yet, and sends you
_NET_WM_SYNC_REQUEST, and all messages cross each other on the way. So now
you end up getting a _NET_WM_SYNC_REQUEST probably even before you finish
drawing your next frame, before noticing it.
> I've tried to stop updating the window if a resizing is started (received
> sync counter), and continue the updates when _no_ new sync request counters
> are received within 30ms (configurable).
I don't think that's necessary. _NET_WM_FRAME_DRAWN contains a counter that
specifies the exact counter update it's in response to. If it's always
checked, and ignored unless it matches your last counter update, this logic
is unambiguous. Upon receipt of a _NET_WM_SYNC_REQUEST you can do whatever
you want to do, as long as you end up setting the counter to acknowledge the
requested value in _NET_WM_SYNC_REQUEST. Whether you actually drew a frame,
or wait to see if another _NET_WM_SYNC_REQUEST arrives quickly, that's your
business, but if you actually decide to draw a frame, you have to wait until
the new frame's counter is acked by a _NET_WM_FRAME_DRAWN, ignoring any
others referencing previous frames.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20190220/1097bcb7/attachment.sig>
More information about the Xcb
mailing list