Sever pipe subscriptions when a cell widget is disposed - #1226
Merged
Conversation
A cell rebuilt while its grid is visible left the discarded widget's rendered plot subscribed to the layers' hv.streams.Pipe: replacing the widget in the GridSpec slot does not run Panel's pane cleanup, so every SessionLayer.update_pipe drove the dead plot alongside the live one for the rest of the session, one extra rendering per rebuild (#1224). CellWidget now keeps a handle on the pn.pane.HoloViews it builds and dispose() runs Plot.cleanup() on the rendered plots and drops the pane's plot registry. Plot.cleanup() severs every weakly-wrapped plot-refresh subscriber on the touched streams, not only its own — holoviews treats them all as reapable — which is safe because a layer's pipe is per session and per cell, and a rebuild disposes the displaced widget before the replacement renders. Fixes #1224. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The missing GridSpec cleanup is holoviz/panel#8710 (in-place objects mutation defeats the removed-child diff) and the over-broad Plot.cleanup is holoviz/holoviews#6988; the TODO states when the sever block can be deleted and where the regression tests move then. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1224.
A cell rebuilt while its grid is visible left the discarded widget's rendered plot subscribed to the layers'
hv.streams.Pipe: replacing the widget in theGridSpecslot does not run Panel's pane cleanup, so everySessionLayer.update_pipedrove the dead plot alongside the live one for the rest of the session — roughly doubling the dominant cost of the poll pass per rebuild, monotonically (see the issue for measurements).CellWidgetnow keeps a handle on thepn.pane.HoloViewsit builds, anddispose()runsPlot.cleanup()on the rendered plots and drops the pane's plot registry.dispose()already runs on rebuild, orphan removal, and document teardown, so all paths are covered.One subtlety discovered while testing:
Plot.cleanup()'s owner filter is defeated by holoviews'_WeakSubscriberwrapper (its__bool__isFalsefor any param-method subscriber, current upstream included), so cleanup severs every weakly-wrapped plot-refresh subscriber on the touched streams, not only its own. This is safe here because a layer's pipe is per session and per cell, and a rebuild disposes the displaced widget before the replacement renders — the docstring records the reasoning. Filed upstream as holoviz/holoviews#6988; the missing GridSpec cleanup itself is holoviz/panel#8710 (in-placeobjectsmutation defeats the removed-child diff).The sever uses the pane's private
_plotsregistry, mirroring the pipe half ofpn.pane.HoloViews._cleanup: Panel only runs that from a document root we no longer have, and exposes no public teardown.Test plan
🤖 Generated with Claude Code