Files
brave-core/components/tabs
Netzenbot 4e57b251f7 Fix intermittent crash in TreeTabsBrowserTest.PinTab_PinnedCollectionAlreadyHasSplit (#35265)
* Fix intermittent crash in TreeTabsBrowserTest.PinTab_PinnedCollectionAlreadyHasSplit

TreeTabModel::AddTreeTabNode defers its kNodeCreated notification
via PostTask. On macOS, nested event loop pumping during UI
operations (tab activation, view creation) can cause this deferred
notification to fire at an unexpected time when tab views may not
yet exist or tabs may have been moved.

Two fixes:
1. BuildTreeTabs: call on_create callback after AddCollection so
   the tree node is in the collection tree when the deferred
   notification eventually fires. Previously on_create was called
   before AddCollection, meaning the tree node was not yet attached.
2. kNodeCreated handler: change CHECK_NE to graceful continue for
   kNoTab index, matching the existing pattern in kNodeWillBeDestroyed.
   This prevents a crash if the deferred notification fires after
   the tab has been moved (e.g., to pinned collection).

Fixes https://github.com/brave/brave-browser/issues/54161

* Add comment explaining kNoTab guard in kNodeCreated handler
2026-04-06 16:59:41 -04:00
..