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

Issue 14317005: Checking if frame is complete and access duration doesn't need a decode (Closed)

Created:
7 years, 8 months ago by Alpha Left Google
Modified:
7 years, 7 months ago
CC:
blink-reviews, jamesr, Stephen Chennney, jeez, urvang (Google), skal
Visibility:
Public.

Description

Checking if frame is complete and access duration doesn't need a decode The goal of this change is to minimize image decoding on the main thread. This change is to avoid image decoding for these two operations: 1. frameIsCompleteAtIndex 2. frameDurationAtIndex These two operations are moved to ImageDecoder interface and are now const to prevent future regression. We are now able to check if a frame is complete by parsing the entire GIF file without decoding. This also provides information like frame duration such that controller the animation doesn't require any decoding. This change is critical to moving animated image decoding off the main thread. BUG=169377, 181321 TEST=(1) Unit test in GIFImageDecoderTest to test change in decoder behavior. (2) Image animation cannot be tested reliable via layout test and is tested manually with wikigifs.org. Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=149883

Patch Set 1 #

Patch Set 2 : const #

Patch Set 3 : const #

Total comments: 21

Patch Set 4 : fixed nits #

Total comments: 4

Patch Set 5 : default impl for frameIsCompleteAtIndex() #

Total comments: 1

Patch Set 6 : update frameIsCompleteAtIndex #

Total comments: 6

Patch Set 7 : done #

Unified diffs Side-by-side diffs Delta from patch set Stats (+121 lines, -39 lines) Patch
M Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp View 1 2 3 1 chunk +56 lines, -0 lines 0 comments Download
M Source/core/platform/graphics/BitmapImage.cpp View 1 2 3 1 chunk +6 lines, -6 lines 0 comments Download
M Source/core/platform/graphics/ImageSource.h View 1 2 3 1 chunk +3 lines, -3 lines 0 comments Download
M Source/core/platform/graphics/ImageSource.cpp View 1 2 3 2 chunks +6 lines, -16 lines 0 comments Download
M Source/core/platform/graphics/chromium/DeferredImageDecoder.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M Source/core/platform/graphics/chromium/DeferredImageDecoder.cpp View 1 2 3 1 chunk +12 lines, -0 lines 0 comments Download
M Source/core/platform/image-decoders/ImageDecoder.h View 1 2 3 4 1 chunk +6 lines, -0 lines 0 comments Download
M Source/core/platform/image-decoders/ImageDecoder.cpp View 1 2 3 4 5 6 1 chunk +7 lines, -5 lines 0 comments Download
M Source/core/platform/image-decoders/gif/GIFImageDecoder.h View 1 2 3 6 1 chunk +2 lines, -0 lines 0 comments Download
M Source/core/platform/image-decoders/gif/GIFImageDecoder.cpp View 1 2 3 4 5 6 4 chunks +17 lines, -7 lines 0 comments Download
M Source/core/platform/image-decoders/gif/GIFImageReader.h View 1 2 3 1 chunk +4 lines, -2 lines 0 comments Download

Messages

Total messages: 26 (0 generated)
Alpha Left Google
7 years, 8 months ago (2013-04-20 01:11:00 UTC) #1
Alpha Left Google
senorblanco: Please look at platform/graphics/* pkasting: Please look at GIF* including decoder and tests.
7 years, 8 months ago (2013-04-20 01:17:24 UTC) #2
Peter Kasting
https://codereview.chromium.org/14317005/diff/3001/Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp File Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp (right): https://codereview.chromium.org/14317005/diff/3001/Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp#newcode251 Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp:251: RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data->size() - 10); Maybe we ...
7 years, 8 months ago (2013-04-23 21:43:20 UTC) #3
Alpha Left Google
https://codereview.chromium.org/14317005/diff/3001/Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp File Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp (right): https://codereview.chromium.org/14317005/diff/3001/Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp#newcode251 Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp:251: RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), data->size() - 10); On 2013/04/23 ...
7 years, 8 months ago (2013-04-25 23:02:44 UTC) #4
Peter Kasting
https://codereview.chromium.org/14317005/diff/3001/Source/core/platform/image-decoders/ImageDecoder.h File Source/core/platform/image-decoders/ImageDecoder.h (right): https://codereview.chromium.org/14317005/diff/3001/Source/core/platform/image-decoders/ImageDecoder.h#newcode297 Source/core/platform/image-decoders/ImageDecoder.h:297: // This method is used by animated images only. ...
7 years, 8 months ago (2013-04-25 23:22:32 UTC) #5
Stephen White
BitmapImage changes look good; I defer to Peter for the decoder changes.
7 years, 8 months ago (2013-04-26 17:11:32 UTC) #6
Alpha Left Google
> I understand what is going on now. My main problem was in misunderstanding the ...
7 years, 8 months ago (2013-04-26 20:43:08 UTC) #7
Alpha Left Google
https://codereview.chromium.org/14317005/diff/11001/Source/core/platform/image-decoders/gif/GIFImageDecoder.cpp File Source/core/platform/image-decoders/gif/GIFImageDecoder.cpp (left): https://codereview.chromium.org/14317005/diff/11001/Source/core/platform/image-decoders/gif/GIFImageDecoder.cpp#oldcode301 Source/core/platform/image-decoders/gif/GIFImageDecoder.cpp:301: m_reader.clear(); It is true that GIFImageReader is holding a ...
7 years, 8 months ago (2013-04-26 20:43:36 UTC) #8
Peter Kasting
> There won't be a gifComplete() event in the future so I'm moving towards having ...
7 years, 8 months ago (2013-04-27 00:51:00 UTC) #9
Alpha Left Google
On 2013/04/27 00:51:00, Peter Kasting wrote: > > There won't be a gifComplete() event in ...
7 years, 7 months ago (2013-05-02 23:02:43 UTC) #10
Peter Kasting
On 2013/05/02 23:02:43, Alpha wrote: > On 2013/04/27 00:51:00, Peter Kasting wrote: > > Actually, ...
7 years, 7 months ago (2013-05-02 23:15:25 UTC) #11
Alpha Left Google
> Well, we only get gifComplete() after we decode the last frame, not just after ...
7 years, 7 months ago (2013-05-03 00:12:24 UTC) #12
Alpha Left Google
$ ping -friendly
7 years, 7 months ago (2013-05-03 20:54:53 UTC) #13
Alpha Left Google
On 2013/05/03 20:54:53, Alpha wrote: > $ ping -friendly i mean --friendly
7 years, 7 months ago (2013-05-03 21:00:42 UTC) #14
Peter Kasting
LGTM with question. https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/image-decoders/ImageDecoder.cpp File Source/core/platform/image-decoders/ImageDecoder.cpp (right): https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/image-decoders/ImageDecoder.cpp#newcode123 Source/core/platform/image-decoders/ImageDecoder.cpp:123: if (m_frameBufferCache.size() <= index) Nit: This ...
7 years, 7 months ago (2013-05-03 22:03:19 UTC) #15
Alpha Left Google
https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/image-decoders/ImageDecoder.cpp File Source/core/platform/image-decoders/ImageDecoder.cpp (right): https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/image-decoders/ImageDecoder.cpp#newcode123 Source/core/platform/image-decoders/ImageDecoder.cpp:123: if (m_frameBufferCache.size() <= index) On 2013/05/03 22:03:19, Peter Kasting ...
7 years, 7 months ago (2013-05-06 17:43:24 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/hclam@chromium.org/14317005/38001
7 years, 7 months ago (2013-05-06 17:44:01 UTC) #17
commit-bot: I haz the power
Retried try job too often on blink_bare_presubmit for step(s) presubmit http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=blink_bare_presubmit&number=470
7 years, 7 months ago (2013-05-06 17:53:36 UTC) #18
Alpha Left Google
Ping senorblanco@ for owner approval. jamesr@ for approval of changes in GIFImageDecoderTest.cpp.
7 years, 7 months ago (2013-05-06 17:57:15 UTC) #19
jamesr
lgtm on test
7 years, 7 months ago (2013-05-06 17:59:03 UTC) #20
Alpha Left Google
ping senorblanco.
7 years, 7 months ago (2013-05-07 17:14:12 UTC) #21
Stephen White
On 2013/05/07 17:14:12, Alpha wrote: > ping senorblanco. LGTM for platform/graphics.
7 years, 7 months ago (2013-05-07 17:34:20 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/hclam@chromium.org/14317005/38001
7 years, 7 months ago (2013-05-07 17:36:31 UTC) #23
commit-bot: I haz the power
Change committed as 149883
7 years, 7 months ago (2013-05-07 18:38:21 UTC) #24
Noel Gordon
https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/image-decoders/ImageDecoder.cpp File Source/core/platform/image-decoders/ImageDecoder.cpp (right): https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/image-decoders/ImageDecoder.cpp#newcode123 Source/core/platform/image-decoders/ImageDecoder.cpp:123: if (m_frameBufferCache.size() <= index) On 2013/05/03 22:03:19, Peter Kasting ...
7 years, 7 months ago (2013-05-16 14:35:24 UTC) #25
Peter Kasting
7 years, 7 months ago (2013-05-16 21:37:53 UTC) #26
Message was sent while issue was closed.
https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/imag...
File Source/core/platform/image-decoders/ImageDecoder.cpp (right):

https://codereview.chromium.org/14317005/diff/29001/Source/core/platform/imag...
Source/core/platform/image-decoders/ImageDecoder.cpp:123: if
(m_frameBufferCache.size() <= index)
On 2013/05/16 14:35:24, Noel Gordon (Google) wrote:
> The GIF decoder overrides frameIsCompleteAtIndex to mean frame received so
> frameHasAlphaAtIndex could now expose a GIF image frame alpha before it fully
> decoded (FrameComplete).  Might that cause the same bugs we've seen for JPEG
in
> some cases?

I think this concern is valid, but I think it isn't about whether we've changed
the implementation of frameHasAlphaAtIndex(), but rather about the whole point
of this patch: the GIF decoder at least is now reporting that a frame is
"complete" when in fact the frame isn't complete in the same sense that we used
to mean that.  In theory, a caller might ask for any arbitrary information about
a frame at that point, and expect it to be accurate and authoritative.  We need
to ensure that either the answers are correct, or that callers don't ask.

So not just for alpha, but for anything else the caller might ask about this
frame, are we ensuring that if the GIF decoder wants to report "complete"
earlier, that it will correctly answer all other such queries?  I suspect that
addressing this probably requires overriding frameHasAlphaAtIndex() in the GIF
decoder to actually decode all the pixels in the "frame complete, but haven't
decoded" case so it can properly check for alpha.

Incidentally, your comment makes me note another issue: if
frameHasAlphaAtIndex() assumes that frameIsCompleteAtIndex() implies the
existence of m_frameBufferCache[index] -- as we've updated it to do here -- then
it's problematic if a subclass overrides frameIsCompleteAtIndex() to violate
that guarantee, and does not also override frameHasAlphaAtIndex() to not rely on
it.  We could address this by adding comments to this effect, or by adding an
ASSERT and comments, or by recoding the functions to not rely on each other and
then adding comments about why they can't rely on each other.  All these
solutions have problems, and while the third sounds initially more appealing,
the fact that practically speaking anyone who overrides frameIsCompleteAtIndex()
must override frameHasAlphaAtIndex() in order to avoid problems like the one
initially discussed above makes me think that we might as well leave things as
they are but add comments to the header noting that subclasses who override the
former function should almost certainly override the latter, and why.

Powered by Google App Engine
This is Rietveld 408576698