Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Issue 1925533003: High CPU and increased memory usage fix for high-res (GIF, WEBP...) animations. (Closed)

Created:
4 years, 7 months ago by aleksandar.stojiljkovic
Modified:
4 years, 4 months ago
CC:
chromium-reviews, blink-reviews-platform-graphics_chromium.org, dshwang, eae+blinkwatch, fs, dcheng, kinuko+watch, kouhei+svg_chromium.org, rwlbuis, Yoav Weiss, krit, drott+blinkwatch_chromium.org, szager+layoutwatch_chromium.org, Justin Novosad, Rik, gavinp+loader_chromium.org, jchaffraix+rendering, blink-reviews, gyuyoung2, pdr+svgwatchlist_chromium.org, zoltan1, blink-reviews-layout_chromium.org, jbroman, pdr+graphicswatchlist_chromium.org, loading-reviews+fetch_chromium.org, Nate Chapin, danakj+watch_chromium.org, tyoshino+watch_chromium.org, pdr+renderingwatchlist_chromium.org, leviw+renderwatch, Stephen Chennney
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

High CPU and increased memory usage fix for high-res (GIF, WEBP...) animations. Patch dependens on skia patch: https://codereview.chromium.org/1928403002 Addressing issues identified with initial patch: crrev.com/1857543002: Don't recreate SkImages for high-res (GIF, WEBP...) animations. by implementing this on different way. - Out of memory fix =================== Originally, high res GIF frames are re-created and re-decoded in BitmapImage during playback , leading to re-creating SkImages and filling up SoftwareImageDecoderController cache: The problem caused here (re-decoding and increased memory allocation) is that SkImage::uniqueID() is used as SoftwareImageDecodeController::decoded_images_ cache key - clearing it causes that cache is filled for every loop and every frame rendered (always decoding and adding to cache). Next loop's SkImages have different uniqueID and keep filling up the cache with duplicates of same frames, evicting useful content. Detailed information about the issue is in comment here [1] [1] https://bugs.chromium.org/p/chromium/issues/detail?id=165750#c13 Patch here mitigates the issue by using same uniqueId which makes the cache utilized, whether it is cc SIDC or skia discardable memory cache. @fmalita's concern from [2], [3] is addressed, too: memory used with page is now about 3 times lower*. *) Note: After rebasing to the latest, memory consumption with page [3] is the same as in version without the patch (measured on Windows). Meanwhile, SIDC budget got increased and now I verified that this patch makes SIDC cache used better - there is no redecoding of every frame since they are cached in SIDC cache. After some time, depending on number of GIFs in viewport, it happens that there is no decoding at all while rendering - all the decoded bitmaps are fetched from SIDC cache. Without this patch, this isn't a case - there is re-decoding. Memory consumption (Windows "process working set" [4]) with bug 165750 is: Original : ~500MB This patch: ~ 60MB [2] https://chromiumcodereview.appspot.com/1857543002/#msg10 [3] http://www.androidpolice.com/2014/10/20/animation-bonanza-android-5-0-lollipop-in-gifs/ [4] https://chromiumcodereview.appspot.com/1857543002/#msg13 - Avoid redecoding ================== Now there is no re-decoding as there is no cache miss when accessing cached decoded bitmap. - destroyDecodedData(true) -> destroyDecodedData ================================================ There is no need to have destroyDecodedData(false) and it is removed. Since original patch [5], pixel data caching got moved to skia discardable memory and recently to SoftwareImageDecodeController. As ImageDecoder already caches only one (2 in some cases) frame, this code's effect was to remove SkImage for animations where all combined frames data is over 5 MB. [5] original patch, @pkasting, Dec 2008 https://chromium.googlesource.com/chromium/src/+/f868b0862a903e2a4ffa0fc975080a09ad73cb64 - Remove holding SkImage reference for every frame in BitmapImage ================================================================= No need to to it also for low size animations - if decoded bitmap is cached in skia or SIDC then there would be no redecoding. One frame is cached per BitmapImage (whether it is single or multiple frame) to speedup access. - destroyDecodedDataIfNecessary replaced by always caching only one frame. ========================================================================== This removes unnecessary cache layer in BitmapImage::m_frames[].m_frame - if decoded bitmap is cached in skia or SIDC then there would be no redecoding. - FrameData -> DeferredFrameData in DeferredImageDecoder ======================================================== DeferredImageDecoder doesn't use m_frame, m_haveMetadata and m_hasAlpha from FrameData so slimmed down struct introduced with required fields only. - virtual void stopAnimation() removed. ======================================= Only called for BitmapImage class. There is no usage for this method in Image and SVGImage so removed it from there. - BitmapImage::destroyDecodedData() override private->public ============================================================ virtual Image::destroyDecodedData that this one is overriding is public from the beginning [6]. instead of downcasting to Image (where the method is public) and calling it made overrides public in subclasses too. Purpose of it is unclear in original patch [6] where it replaced invalidateData. [6] original patch, @hyatt, Mar 2007 https://chromium.googlesource.com/chromium/src/+/d9bbf3787106e2620e8f51f1d371c1441643be6c%5E%21/#F12 BUG=165750 Committed: https://crrev.com/c823053729b5a8839ee32b23c3142f3cd2955bf9 Cr-Commit-Position: refs/heads/master@{#395863}

Patch Set 1 #

Total comments: 29

Patch Set 2 : Beter approach (use same uniqueId for same SkImage) - thanks @pkasting. #

Total comments: 6

Patch Set 3 : @scroggo, thanks a lot - this makes page [3] to use 250MB (was 750MB) #

Total comments: 41

Patch Set 4 : minor - revert back to cached m_isComplete #

Patch Set 5 : review #23 fixes #

Total comments: 10

Patch Set 6 : Comments related to review #28 #

Patch Set 7 : BitmapImage::isAllDataReceived and hasColorProfile back to public #

Total comments: 4

Patch Set 8 : Nits related to review #31 #

Total comments: 1

Patch Set 9 : Rebasing. DCHECK. Thanks fmalita@. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+122 lines, -156 lines) Patch
M third_party/WebKit/Source/core/fetch/ImageResource.cpp View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/ImageQualityControllerTest.cpp View 1 3 chunks +3 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/core/svg/graphics/SVGImage.h View 1 2 3 4 5 6 7 8 2 chunks +1 line, -2 lines 0 comments Download
M third_party/WebKit/Source/core/svg/graphics/SVGImage.cpp View 1 2 3 4 5 6 7 8 1 chunk +0 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/svg/graphics/SVGImageForContainer.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/DragImageTest.cpp View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/graphics/BitmapImage.h View 1 2 3 4 5 6 7 8 6 chunks +15 lines, -27 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/BitmapImage.cpp View 1 2 3 4 5 6 7 8 12 chunks +25 lines, -45 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp View 1 2 3 4 5 6 7 8 5 chunks +16 lines, -37 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.h View 1 2 3 4 1 chunk +6 lines, -1 line 0 comments Download
M third_party/WebKit/Source/platform/graphics/DecodingImageGenerator.cpp View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.h View 1 2 3 4 5 6 7 8 3 chunks +4 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp View 1 2 3 4 5 6 7 8 7 chunks +41 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/FrameData.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/FrameData.cpp View 1 2 3 4 5 6 7 8 1 chunk +1 line, -7 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/GeneratedImage.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/graphics/Image.h View 1 2 3 4 5 6 7 8 2 chunks +1 line, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/graphics/ImageLayerChromiumTest.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/graphics/StaticBitmapImage.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 46 (13 generated)
aleksandar.stojiljkovic
4 years, 7 months ago (2016-04-27 08:15:34 UTC) #3
Peter Kasting
From your CL description: "SkImage::uniqueID() is used as SoftwareImageDecodeController::decoded_images_ cache key - clearing it causes ...
4 years, 7 months ago (2016-04-28 23:07:55 UTC) #4
aleksandar.stojiljkovic
On 2016/04/28 23:07:55, Peter Kasting wrote: > From your CL description: > > "SkImage::uniqueID() is ...
4 years, 7 months ago (2016-04-29 17:15:50 UTC) #7
aleksandar.stojiljkovic
patch#2 looks like a proper way to fix it if skia patch gets accepted: https://codereview.chromium.org/1928403002/ ...
4 years, 7 months ago (2016-04-29 17:17:43 UTC) #8
aleksandar.stojiljkovic
Skia part of this feature landed: https://codereview.chromium.org/1928403002 Thanks @reed. @pkasting, since you LGTM-ed original patch ...
4 years, 7 months ago (2016-05-02 08:55:27 UTC) #9
scroggo
Drive-by review: I came here by way of crrev.com/1928403002, and wanted to see how it's ...
4 years, 7 months ago (2016-05-02 14:07:25 UTC) #11
scroggo
https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp (right): https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode315 third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp:315: m_frameData[index].m_uniqueID = m_frameData[index].m_isComplete ? image->uniqueID() : 0; On 2016/05/02 ...
4 years, 7 months ago (2016-05-02 16:42:25 UTC) #12
aleksandar.stojiljkovic
https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp (right): https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode53 third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp:53: bool m_isComplete : 1; On 2016/05/02 14:07:25, scroggo wrote: ...
4 years, 7 months ago (2016-05-02 16:44:37 UTC) #14
aleksandar.stojiljkovic
On 2016/05/02 16:42:25, scroggo wrote: > https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp > File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp > (right): > > https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode315 ...
4 years, 7 months ago (2016-05-02 16:56:49 UTC) #15
scroggo
https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp (right): https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode315 third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp:315: m_frameData[index].m_uniqueID = m_frameData[index].m_isComplete ? image->uniqueID() : 0; On 2016/05/02 ...
4 years, 7 months ago (2016-05-02 17:46:27 UTC) #16
aleksandar.stojiljkovic
On 2016/05/02 17:46:27, scroggo wrote: > https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp > File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp > (right): > > https://codereview.chromium.org/1925533003/diff/20001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode315 ...
4 years, 7 months ago (2016-05-02 18:04:13 UTC) #17
aleksandar.stojiljkovic
message: > On 2016/05/02 17:46:27, scroggo wrote: > > Would you please walk me through ...
4 years, 7 months ago (2016-05-02 20:52:47 UTC) #18
Peter Kasting
I'm basically staying silent here until you both agree you're OK with whatever the latest ...
4 years, 7 months ago (2016-05-03 00:52:01 UTC) #19
scroggo_chromium
Peter, go ahead. I have a small concern (stated in my comment, below), but I ...
4 years, 7 months ago (2016-05-03 13:08:52 UTC) #21
aleksandar.stojiljkovic
On 2016/05/03 13:08:52, scroggo_chromium wrote: > Peter, go ahead. I have a small concern (stated ...
4 years, 7 months ago (2016-05-03 22:38:56 UTC) #22
Peter Kasting
https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp File third_party/WebKit/Source/platform/graphics/BitmapImage.cpp (right): https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp#newcode72 third_party/WebKit/Source/platform/graphics/BitmapImage.cpp:72: , m_frameIndex(0) Here and below: Initialize members in the ...
4 years, 7 months ago (2016-05-04 03:01:07 UTC) #23
aleksandar.stojiljkovic
Patch Set 5 : review #23 fixes Thanks @pkasting https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp File third_party/WebKit/Source/platform/graphics/BitmapImage.cpp (right): https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp#newcode144 third_party/WebKit/Source/platform/graphics/BitmapImage.cpp:144: ...
4 years, 7 months ago (2016-05-04 20:56:30 UTC) #24
scroggo_chromium
https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp (right): https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode315 third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp:315: m_frameData[index].m_uniqueID = (m_allDataReceived || (m_actualDecoder && m_actualDecoder->frameIsCompleteAtIndex(index))) ? image->uniqueID() ...
4 years, 7 months ago (2016-05-04 21:15:55 UTC) #25
aleksandar.stojiljkovic
https://codereview.chromium.org/1925533003/diff/80001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp File third_party/WebKit/Source/platform/graphics/BitmapImage.cpp (right): https://codereview.chromium.org/1925533003/diff/80001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp#newcode219 third_party/WebKit/Source/platform/graphics/BitmapImage.cpp:219: m_cachedFrame.clear(); On 2016/05/04 21:15:54, scroggo_chromium wrote: > Should we ...
4 years, 7 months ago (2016-05-04 21:28:07 UTC) #26
scroggo_chromium
Changes in DeferredImageDecoder/DecodingImageGenerator LGTM
4 years, 7 months ago (2016-05-06 14:08:45 UTC) #27
Peter Kasting
https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp File third_party/WebKit/Source/platform/graphics/BitmapImage.cpp (right): https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp#newcode553 third_party/WebKit/Source/platform/graphics/BitmapImage.cpp:553: m_animationFinished = false; On 2016/05/04 20:56:29, aleksandar.stojiljkovic wrote: > ...
4 years, 7 months ago (2016-05-07 01:58:29 UTC) #28
aleksandar.stojiljkovic
patch set #6: Comments. Thanks @pkasting. https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp File third_party/WebKit/Source/platform/graphics/BitmapImage.cpp (right): https://codereview.chromium.org/1925533003/diff/40001/third_party/WebKit/Source/platform/graphics/BitmapImage.cpp#newcode72 third_party/WebKit/Source/platform/graphics/BitmapImage.cpp:72: , m_frameIndex(0) On ...
4 years, 7 months ago (2016-05-07 19:50:53 UTC) #29
aleksandar.stojiljkovic
https://codereview.chromium.org/1925533003/diff/80001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp (right): https://codereview.chromium.org/1925533003/diff/80001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode315 third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp:315: if (m_allDataReceived || m_frameData[index].m_isComplete) On 2016/05/07 19:50:53, aleksandar.stojiljkovic wrote: ...
4 years, 7 months ago (2016-05-09 09:33:03 UTC) #30
Peter Kasting
LGTM https://codereview.chromium.org/1925533003/diff/80001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp (right): https://codereview.chromium.org/1925533003/diff/80001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode315 third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp:315: if (m_allDataReceived || m_frameData[index].m_isComplete) On 2016/05/09 09:33:02, aleksandar.stojiljkovic ...
4 years, 7 months ago (2016-05-09 22:31:25 UTC) #31
aleksandar.stojiljkovic
On 2016/05/09 22:31:25, Peter Kasting wrote: > LGTM > > https://codereview.chromium.org/1925533003/diff/80001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp > File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp > ...
4 years, 7 months ago (2016-05-11 10:33:14 UTC) #32
Peter Kasting
Still LGTM
4 years, 7 months ago (2016-05-11 18:39:45 UTC) #33
aleksandar.stojiljkovic
On 2016/05/11 18:39:45, Peter Kasting wrote: > Still LGTM @fmalita, @senorblanco - could you please ...
4 years, 7 months ago (2016-05-11 21:57:27 UTC) #34
aleksandar.stojiljkovic
senorblanco@ and fmalita@ seem busy. Checking if other OWNERS from platform/graphics are available. chrishtr@, schenney@, ...
4 years, 7 months ago (2016-05-19 14:47:09 UTC) #36
f(malita)
On 2016/05/19 14:47:09, aleksandar.stojiljkovic wrote: > senorblanco@ and fmalita@ seem busy. > Checking if other ...
4 years, 7 months ago (2016-05-24 15:31:08 UTC) #37
f(malita)
https://codereview.chromium.org/1925533003/diff/140001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp File third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp (right): https://codereview.chromium.org/1925533003/diff/140001/third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp#newcode319 third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp:319: m_frameData[index].m_uniqueID = image->uniqueID(); Nit: before assigning the new ID ...
4 years, 7 months ago (2016-05-24 15:31:21 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1925533003/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1925533003/160001
4 years, 7 months ago (2016-05-25 09:38:01 UTC) #41
commit-bot: I haz the power
Committed patchset #9 (id:160001)
4 years, 7 months ago (2016-05-25 11:26:28 UTC) #44
commit-bot: I haz the power
4 years, 7 months ago (2016-05-25 11:27:34 UTC) #46
Message was sent while issue was closed.
Patchset 9 (id:??) landed as
https://crrev.com/c823053729b5a8839ee32b23c3142f3cd2955bf9
Cr-Commit-Position: refs/heads/master@{#395863}

Powered by Google App Engine
This is Rietveld 408576698