Commit e86a2bd2 authored by nancylingwang's avatar nancylingwang Committed by Commit Bot

Fix the system crash issue when loading many app icons.

For the adaptive icon, there are 2 files opened for each icons, so when
there are many apps installed, many files are opened to load the image,
which might cause the system crash:
Too many open files

This CL modifies the code to reduce the unnecessary icon loading, and
reduce the duplicated open files:
1. For OnIntentFiltersUpdated, we don't need to update the icon to
reload the icon.
2. Modify the background image source in ArcAppIcon to set the null
host, because ArcAppIcon::Source checks the host and call
LoadForScaleFactor to read icon files. Since that has been done by the
foreground image, we don't need to do it for the background image again.

b:166430206

Change-Id: Iecc76ca8e02bc5ef2230f99553abb8fb4a00362c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386435
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Reviewed-by: default avatarLong Cheng <lgcheng@google.com>
Cr-Commit-Position: refs/heads/master@{#803350}
parent c8026dea
......@@ -1131,7 +1131,8 @@ void ArcApps::OnIntentFiltersUpdated(
auto GetAppInfoAndPublish = [prefs, this](std::string app_id) {
std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs->GetApp(app_id);
if (app_info) {
Publish(Convert(prefs, app_id, *app_info), subscribers_);
Publish(Convert(prefs, app_id, *app_info, false /* update_icon */),
subscribers_);
}
};
......
......@@ -268,9 +268,14 @@ ArcAppIcon::ArcAppIcon(content::BrowserContext* context,
std::make_unique<Source>(weak_ptr_factory_.GetWeakPtr(),
resource_size_in_dip),
resource_size);
// ArcAppIcon::Source::GetImageForScale calls host_->LoadForScaleFactor to
// read both the foreground and background files, so the
// |background_image_skia_| doesn't need to set the host to call
// LoadForScaleFactor again. Otherwise, it might duplicate the opened
// files number, and cause the system crash,
background_image_skia_ = gfx::ImageSkia(
std::make_unique<Source>(weak_ptr_factory_.GetWeakPtr(),
resource_size_in_dip),
std::make_unique<Source>(nullptr, resource_size_in_dip),
resource_size);
for (const auto& scale_factor : scale_factors) {
foreground_incomplete_scale_factors_.insert(
......
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