Skip to content

Ignore listener registrations for removed views, and prune dead ids before layout broadcasts - #1087

Open
criccomini wants to merge 1 commit into
lapce:mainfrom
criccomini:stale-listener-ids
Open

criccomini wants to merge 1 commit into
lapce:mainfrom
criccomini:stale-listener-ids

Conversation

@criccomini

Copy link
Copy Markdown
Contributor

Problem

A view can be removed by an earlier update message in the same batch as its own RegisterListener message. The EditorView hits this easily because it calls id.register_listener(LayoutChanged::listener_key()) when it is built, and an editor inside nested dyn_containers can be swapped out before that message is processed.

When that happens, the RegisterListener handler still pushes the dead ViewId into window_state.listeners, and records the key on the shared stale ViewState rather than the real one. remove_view has already run, so nothing ever cleans the id out. On the next commit_box_tree, get_layout on the dead id returns Some (the stale state owns a live taffy node), and get_layout_window_origin then calls ViewStorage::box_tree, which panics:

thread 'main' panicked at src/view/storage.rs:134:14:
all view ids are created with a root
   3: <floem::view::storage::ViewStorage>::box_tree
   4: ... <floem::view::id::ViewId>::get_layout_window_origin ...
   6: <floem::window::handle::WindowHandle>::commit_box_tree

Fix

  • RegisterListener skips ids whose view no longer exists.
  • commit_box_tree prunes invalid ids out of the listener lists before the LayoutChanged and VisualChanged broadcasts.

🤖 Generated with Claude Code

…efore layout broadcasts

A view can be removed by an earlier message in the same update batch as its
RegisterListener message. Registering it anyway leaves a dead ViewId in the
window's listener list, and the next commit_box_tree panics in
ViewStorage::box_tree with 'all view ids are created with a root'.
@criccomini

Copy link
Copy Markdown
Contributor Author

(This was Fable low, but the crash and debugging did happen :)

This branch has not been deployed

No deployments
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