Skip to content
Snippets Groups Projects
Commit 869def26 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

throttle gui_canvas_get_scroll instead of debouncing

while debouncing this call can save re-layouts of the DOM, with indeterminate
streams of redraws coming from Pd it can result in no re-layouts at all. In
the case where a user opens a subpatch that has a redraw triggered by a
[metro 200] object, there may not even be an initial layout. This can result
in the patchsvg never getting its viewBox set and appearing not to display
at all.

One workaround could be to do an initial call immediately after mapping the
window, but there are still cases (like resizing a window or adding objects)
that could result in putting off a needed re-layout for too long.

So instead of debouncing, we throttle. This means there will only be a
single call every 250ms (or whatever value we want), but that call is
_guaranteed_ to happen at the end of the chosen duration. So for a stream
of redraws coming from a [metro 200] we'll get a re-layout every 250ms. That's
more expensive than putting them off indefinitely, but obviously more
responsive and usable.

Ideally we would send a do_getscroll _first_ and then wait 250ms. That would
result in a more responsive UX-- as it is the 250ms makes the initial window
rendering appear sluggish. Unfortunately there's still some kind of race
between the rendering of the window menu and the window size measurements
reported by the DOM API-- if we measure too early the vertical measurement is
too big, resulting in an unnecessary vertical scrollbar.

So instead we wait 250ms and call do_getscroll after. This apparently
gives enough time for the menubar to render and for the DOM to take it into
account when feeding us the window dimensions. But if that race can be fixed
or worked around, we can change the behavior here to call first then wait
second.
parent 1f41004d
No related branches found
No related tags found
1 merge request!112throttle gui_canvas_get_scroll instead of debouncing
Pipeline #
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment