Skip to content

Keep following the store with the graphs of destroyed views that are still held - #364

Merged
mbastian merged 2 commits into
masterfrom
fix/destroyed-view-empty
Oct 25, 2026
Merged

mbastian merged 2 commits into
masterfrom
fix/destroyed-view-empty

Conversation

@mbastian

@mbastian mbastian commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Problem

A destroyed view is removed from GraphViewStore.views, so the store no longer updates it. A graph of it that is still held keeps stale counts and bit vectors, and store ids are reused, so it can even contain elements it never had.

This happens in Gephi's layouts: they fetch getGraphVisible() and only then take its read lock. In that window a filter can replace the visible view and destroy the old one. If edges are then removed from the store, getEdges().toArray() on the held graph throws IllegalStateException: End size ... is less than fixed size ... and kills the layout thread. It was found by the release-test soak with ForceAtlas 2.

Fix

GraphViewStore tracks the most recently destroyed views (up to MAX_DESTROYED_VIEWS = 8) through weak references, and the hooks that update the views (addNode, removeNode, addEdge, removeEdge, setEdgeType, clear, clearEdges) update them too. A graph held after the destroy therefore behaves like the graph of a live view, and unreferenced destroyed views are dropped by the garbage collector. A view that falls out of the 8 most recent is emptied, so it stays consistent instead of going stale.

Not changed: a destroyed view is still gone for everything addressed by view (observers, indexes, setVisibleView, ...), these keep throwing The view doesn't exist. The view indexes are deleted on destroy and are not recreated.

Emptying the view on destroy was tried first and dropped, as callers rely on a destroyed view keeping its content (e.g. a filter swap alone doesn't change the store, so the previous result is still valid).

Cost

Each tracked destroyed view costs about the same as a live view on every change of the store, so the cap (8) is the worst case, however many views are held. Without destroyed views there is no measurable change. With 8 tracked node-only views (10k nodes, 100k edges), adding the edges takes about 61-67 ms instead of 43 ms and removing them about 36-41 ms instead of 21 ms; node+edge views cost much less (about 44 and 23 ms).

Tests

GraphViewStoreTest compares destroyed views with live control views created the same way (node and edge, node-only and edge-only views) after removals, store id reuse, edge type changes, clear and clearEdges, with attribute and time indexes, and checks the cap and that unreferenced views are released. Without the fix 9 of the 10 new tests fail, one of them with the original exception (the tenth guards against emptying the view on destroy).

🤖 Generated with Claude Code

…still held

A destroyed view was no longer updated by the store, so a graph of it that was still held, for instance fetched just before a filter replaced and destroyed the visible view, went stale. Its counts and bit vectors no longer matched the store, store ids are reused, and `getEdges().toArray()` threw `IllegalStateException: End size ... is less than fixed size ...`.

The most recently destroyed views (up to 8) are now tracked through weak references and updated by the same hooks as the live views, so a graph held after the destroy behaves like the graph of a live view. The older ones are emptied, which keeps them consistent, and unreferenced ones are dropped by the garbage collector.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant