Commit 9f92227f authored by Andrew Xu's avatar Andrew Xu Committed by Commit Bot

Possible fixing for the crash in ChromeAppListModelUpdater

Learnt from other engineers that map::count at some time gives
unexpected results. So replace map::count with map::find in
ChromeAppListModelUpdater::FindItem.

In addition, it is suspected that ActivateChromeItem may affect
|current_model_updater_| in a surprising way. So move ActivateChromeItem
to the end of function. Meanwhile, add more checks to help the bug
investigation.

Bug: 969810
Change-Id: Ic5c7b21efb4746d9761742482d9a697ebe322c44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1714214Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Andrew Xu <andrewxu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680088}
parent afca6264
......@@ -191,10 +191,7 @@ void AppListClientImpl::ActivateItem(int profile_id,
return;
}
requested_model_updater->ActivateChromeItem(id, event_flags);
// Send a training signal to the search controller.
CHECK(current_model_updater_);
const auto* item = current_model_updater_->FindItem(id);
if (item) {
app_list::AppLaunchData app_launch_data;
......@@ -205,6 +202,19 @@ void AppListClientImpl::ActivateItem(int profile_id,
}
app_launch_event_logger_.OnGridClicked(id);
requested_model_updater->ActivateChromeItem(id, event_flags);
// Suspect that |id| may be destructed after calling ActivateChromeItem. Add
// the following two lines to help investigate the crash.
std::string copy = id;
base::debug::Alias(&copy);
// Suspect that the model updater may change after calling ActivateChromeItem.
// Add checks to help invesigate the crash.
CHECK(current_model_updater_);
CHECK(requested_model_updater);
CHECK(current_model_updater_ == requested_model_updater);
}
void AppListClientImpl::GetContextMenuModel(
......
......@@ -310,7 +310,7 @@ void ChromeAppListModelUpdater::NotifySearchResultItemInstalled(
// Methods for item querying
ChromeAppListItem* ChromeAppListModelUpdater::FindItem(const std::string& id) {
return items_.count(id) ? items_[id].get() : nullptr;
return items_.find(id) != items_.end() ? items_[id].get() : nullptr;
}
size_t ChromeAppListModelUpdater::ItemCount() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment