0

[Read anything] Unserialize updates before clearing pending updates.

It's possible to receive events in the following order during
distillation:
1. AccessibilityEventReceived(old_tree)
2. OnActiveAXTreeIDChanged(new_tree)
3. AccessibilityEventReceived(old_tree)

(2) clears the pending updates set by (1), which means that reading mode
will experience tree inconsistency issues / crashes in (3) when
attempting to unserialize the new updates on the old tree.

Bug: 409110161,410476538
Change-Id: I21213e315264b5ed9f5ebc2d0e530eccb178ef20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6517673
Reviewed-by: Kristi Saney <kristislee@google.com>
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: Aaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1456973}
This commit is contained in:
Lauren Winston
2025-05-07 07:08:29 -07:00
committed by Chromium LUCI CQ
parent 0bc24ff193
commit 313b32300b

@ -721,6 +721,14 @@ void ReadAnythingAppModel::OnScroll(bool on_selection,
}
void ReadAnythingAppModel::SetActiveTreeId(ui::AXTreeID active_tree_id) {
// Unserialize any updates on the previous active tree;
// Otherwise, this can cause tree inconsistency issues if reading mode later
// incorrectly receives updates from the old tree.
if (active_tree_id_ != active_tree_id &&
active_tree_id_ != ui::AXTreeIDUnknown() && ContainsActiveTree()) {
UnserializePendingUpdates(active_tree_id_);
}
active_tree_id_ = std::move(active_tree_id);
// If data collection mode for screen2x is enabled, begin
// `timer_since_page_load_for_data_collection_` from here. This is a