use fully fledged async, NDPositions improvements#1050
Conversation
NDPositions improvements
|
No more jitter and jiggly effect in no-jitter-2026-05-11_03.16.52.mp4IO such as video decoding in an independent process + new async lets us get 120+fps easily. We still get ~100fps+ rendering when we set the playback fps to 100. With the previous generator-as-a-coroutine simpler async without rendercanvas scheduling we got ~60fps, so we can get almost double the fps with this proper async that uses rendercanvas scheduling! 🥳 . The decoder does get stuck for a few seconds if a huge backlog piles up I think, but from inspecting the stack this lag comes from the decoder. Anyways the frame corresponding to the latest indices do appear within a few seconds and I think it's unlikely a user will be scrolling such that they request 100 different random frames/second for long periods of time, or playback at > 100fps. gerbies-async-2026-05-11_03.25.59.mp4With masknmf demixing results with many subplots etc. (this) I get ~28fps with the new propery async, 17 fps before. |
This replaces the generator-as-a-couroutine with proper full async and uses rendercanvas's existing loop for scheduling. Throttling behavior is much more natural now and IO never blocks rendering even when waiting for Futures to resolve. The entire pipeline from getting the raw data -->
window_funcs-->spatial_funcis async and fully concurrent.closes #1042
@apasarkar this should allow concurrent running of
window_funcsandspatial_funcswritten usingtorchthat stay on the device until the very end, ex:torch.mean()for rolling mean windows instead ofnp.mean.NDWSubplot.subplotproperty @apasarkarNDGraphic._set_indices_()doesn't take any arguments, it retrieves the latest indices directly from the ref_index instance. This is because since_set_indices_()is a scheduled request AND theindicesdict is produced at the time it's scheduled in_render_indices(), theindicesargument will not reflect the latest indices at execution time. SoNDGraphic._set_indices_()just always grabs the latest indices when it executes.x_range_modelogic in NDPostions, get rid of jittery and jigglyness whenx_range_mode="auto", fix other bugs._update_from_view_range()useswith block_indices_ctx()to any async scheduling of_set_indices_()whenx_range_mode="auto"but we allow async scheduling to update all otherNDGraphics. We thenrun_sync(self._set_indices_())immediately so that theNDPositionsgraphic immediately reflects the latest polled camera state. This gets rid of the jitter and jiggly effect! 🥳x_rangefighting when setting indices via_set_indices_x_rangefighting with_update_from_view_range()- trying to figure this outVisibilitySelectorand no lines are visible (i.e. initial selection is empty, blank subplot).NDPositionsLinearSelectorper-subplot, so multiple timeseries can be overlaid in one subplot and they use the same linear selector.PlotArea.x_rangeandy_rangesetters and getters.Futurecancellation inReferenceIndexrender request logic.fava- almost theremasknmf.DemixingResultsand moving the slider very fast.@BalzaniEdoardo