GeezerVison is showing github.com — Reactive rendering · Issue #1018 · fastplotlib/fastplotlib
DescriptionFollow up from #1017 . Right now a subplot is rendered even if nothing has changed in it, this is expensive when we have lots of subplots and especially when we have lots of docks with the HistogramLUTTool next to images. I think we can implement reactive rendering like this:
Graphic has a method Graphic.flag_update() which is called whenever anything about a graphic changes. This just sets PlotArea.flag_update = True. PlotArea.render() does nothing if PlotArea.flag_update is False.
- The camera also sets
PlotArea.flag_update when its state changes, not entirely sure how to do that yet.
If we do use the plot area flag, if something about a graphic changes we should do the check only if it's False.
@clewis7 thoughts? Activitykushalkolar commented on Mar 18, 2026 kushalkolar commented on Mar 19, 2026 @almarklein quick question, is there a nice way to know if anything about a WorldObject has changed? The geo, a geo buffer, material, or a material prop? almarklein commented on Mar 27, 2026 Sorry, I missed this earlier. No, there's not a good way to do this currently. It would also be really hard to implement. A material does not know to what objects it is attached. So setting a prop on the material is not easily propated up the tree. It would be possible (with some changes in a few places) to traverse the tree and check for some sort of version number or dirty flag, but that traversal would be expensive. kushalkolar commented on Mar 27, 2026 Will think more about this. We might be able to get away with setting a flag when a graphic feature set_value is called, or when the material changes. almarklein commented on Mar 30, 2026 I think that could make sense. In PyGfx the separation in object / material / geometry works against us for this particular use-case. But in FPL the object model is simpler, which gives the opportunity to do this. If possible, you want to set a flag at the view/subplot/scene, to avoid iterating over possibly 1000ths objects at render-time. kushalkolar commented on Apr 13, 2026 Thanks Almar!
Did some basic benchmarking and we definitely need reactive rendering, huge performance benefit. Double fps easily.
wtf-reactive-epic-2026-04-13_17.23.05.mp4
It needs the following:
- meshes in underlay render pass should only have geometry for the frame so they can be drawn regardless of the subplot's dirty state
- Need to allow flushing render with alpha blending, been playing around with this in the renderer will post on pygfx and probably do a PR. Overlay render pass should be flushed with this alpha blend. Overlay render pass also needs a settable dirty flag.
kushalkolar commented on May 4, 2026 4am thoughts: I might be able to get away with just registering an event handler on all graphic features and having those set a flag. PlotArea uses this flag if the render_mode = "reactive". Should benchmark if firing graphic feature events at 60-100Hz across all these graphics is too much overhead. almarklein commented on May 14, 2026 Not sure if this fits, but I'd create a tiny object. Something like this:
class UpdateFlag:
is_set = False
def set(self):
self.is_set = True
Have one of these for each view/canvas. Pass the object to each graphic, and make the graphic call flag.set() whenever anything changes.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|