Commit 23dc546f authored by Fernando Serboncini's avatar Fernando Serboncini Committed by Commit Bot

Only update ImageBitmap if we have a real image

ImageBitmap can fail to be created, if it doesn't fit in memory.

Bug: 936885
Change-Id: I694ed4fb964782f84cdec33d465a1e404aca6324
Reviewed-on: https://chromium-review.googlesource.com/c/1496921
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarMohammad Reza Zakerinasab <zakerinasab@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636848}
parent 9da196a5
......@@ -824,11 +824,16 @@ void ImageBitmap::UpdateImageBitmapMemoryUsage() {
// but this is breaking some tests due to the repaint of the image.
int bytes_per_pixel = 4;
base::CheckedNumeric<int32_t> memory_usage_checked = bytes_per_pixel;
memory_usage_checked *= image_->width();
memory_usage_checked *= image_->height();
int32_t new_memory_usage =
memory_usage_checked.ValueOrDefault(std::numeric_limits<int32_t>::max());
int32_t new_memory_usage = 0;
if (image_) {
base::CheckedNumeric<int32_t> memory_usage_checked = bytes_per_pixel;
memory_usage_checked *= image_->width();
memory_usage_checked *= image_->height();
new_memory_usage = memory_usage_checked.ValueOrDefault(
std::numeric_limits<int32_t>::max());
}
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
new_memory_usage - memory_usage_);
memory_usage_ = new_memory_usage;
......
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