h5web: Don't use debounce on slice slider (update as fast as possible)
Is your feature request related to a problem?
When using the slicing slider (in DimensionMapper) for heatmaps, the plot is not updated smoothly when the slider is moved, even when using h5wasm provider (which should allow very fast updates).
The debounce that is applied is preventing updates to the plot.
Requested solution or feature
Instead of debouncing the slider signal, I think a different approach is merited here and would provide huge gains in responsiveness:
- add a separate independent requestAnimationFrame loop that checks if the heatmap needs to be redrawn
- if “needs redraw” flag is true and not “drawing” flag, set “drawing” = true:
- set “needs redraw” = false
- start redraw with current slider value (redraw operation should do the data slicing, which could be slow if coming from a server)
- when fetch + redraw is complete, set “drawing” = false and continue animation loop
- if “needs redraw” is false, do nothing and continue animation loop.
- if “needs redraw” flag is true and not “drawing” flag, set “drawing” = true:
- when the slider is moved, set the “needs redraw” flag to true.
The advantage of this system over debounce is that it updates as fast as the (data slice + plot) operation can be carried out, rather than arbitrarily delaying execution of the slice by the debounce timers. There is natural rate-limiting to slice requests from e.g. H5Grove because no more than one request will be issued at a time. Providers with very fast slice turnarounds (e.g. h5wasm) will be able to update nearly instantly (smooth visual scrolling through datasets!)
Alternatives you’ve considered
Additional context
I have implemented this type of buffering on many occasions for smooth updates of visualizations from user inputs. I’m happy to help with this.
I couldn’t find a nice requestAnimationFrame equivalent to the react-hookz/web debounce tools being used, so it might have to be coded by hand rather than using a library.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 16 (16 by maintainers)
Yeah, only downside is, you have to actually release the mouse pointer for
onAfterChangeto be triggered. To be honest, I think we need a combination of all the above:onAfterChangeis called;For 2 and 3, maybe cancel any other ongoing fetch, though not sure it would make a difference and we may actually prefer to see the result of this ongoing fetch until the final fetch completes.
Here is a demo with debouncing turned off:
https://github.com/silx-kit/h5web/assets/686570/4d791ea8-c83f-49c7-a1e5-a16caccbb209