Commit 2375197a authored by Rayan Kanso's avatar Rayan Kanso Committed by Commit Bot

Fix crash in the ThreadedIconLoader.

Crash reports show that this was happening in the SkBitmap's copy
constructor, which likely means that the Resize image operation
sometimes returns a null icon. This CL adds an extra check.

Bug: 1003293
Change-Id: If26c5a9a2690a6d0124dc2b7fcaaa487681dafce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1805654
Auto-Submit: Rayan Kanso <rayankans@chromium.org>
Commit-Queue: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#701186}
parent 08c9b5f4
......@@ -152,10 +152,16 @@ void ThreadedIconLoader::DecodeAndResizeImageOnBackgroundThread(
// Use the RESIZE_GOOD quality allowing the implementation to pick an
// appropriate method for the resize. Can be increased to RESIZE_BETTER
// or RESIZE_BEST if the quality looks poor.
decoded_icon_ = skia::ImageOperations::Resize(
SkBitmap resized_icon = skia::ImageOperations::Resize(
decoded_icon_, skia::ImageOperations::RESIZE_GOOD, resized_width,
resized_height);
if (resized_icon.isNull()) {
notify_complete(1.0);
return;
}
decoded_icon_ = std::move(resized_icon);
notify_complete(scale);
}
......
......@@ -137,5 +137,18 @@ TEST_F(ThreadedIconLoaderTest, LoadTimeRecordedByUMA) {
histogram_tester.ExpectTotalCount("Blink.ThreadedIconLoader.LoadTime", 1);
}
TEST_F(ThreadedIconLoaderTest, ResizeFailed) {
WebSize dimensions = {25, 0};
auto result = LoadIcon(RegisterMockedURL(kIconLoaderIcon100x100), dimensions);
const SkBitmap& icon = result.first;
double resize_scale = result.second;
// Resizing should have failed so the original will be returned.
ASSERT_FALSE(icon.isNull());
EXPECT_EQ(icon.width(), 100);
EXPECT_EQ(icon.height(), 100);
EXPECT_EQ(resize_scale, 1.0);
}
} // namespace
} // namespace blink
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