Closed
Bug 1284031
Opened 8 years ago
Closed 8 years ago
Make StreamingLexer read from a SourceBufferIterator directly
Categories
(Core :: Graphics: ImageLib, defect)
Core
Graphics: ImageLib
Tracking
()
RESOLVED
FIXED
mozilla50
Tracking | Status | |
---|---|---|
firefox50 | --- | fixed |
People
(Reporter: seth, Assigned: seth)
References
Details
(Whiteboard: [gfx-noted])
Attachments
(4 files, 2 obsolete files)
2.06 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
5.92 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
14.41 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
14.09 KB,
patch
|
Details | Diff | Splinter Review |
We want to support decoding animated images frame-by-frame, and to do that, StreamingLexer needs to support yielding - that is, returning from Lex() before all the data has been consumed. The problem is that if we implement that right now, the only way it can work is for us to buffer all the data that hasn't been consumed before the yield. In many cases that'll be the majority of the image, so this would result in a *lot* of copying, which is bad for performance. To avoid that, let's make StreamingLexer read from a SourceBufferIterator directly. We can then modify SourceBufferIterator's API to allow advancing through the SourceBuffer for a fixed number of bytes, instead of all at once, which will allow us to implement yielding efficiently.
Updated•8 years ago
|
Whiteboard: [gfx-noted]
Assignee | ||
Comment 1•8 years ago
|
||
Alright! We're ready to more deeply integrate StreamingLexer with SourceBufferIterator. This patches makes us advance the SourceBufferIterator passed to StreamingLexer for each state individually. Thanks to the changes in bug 1286175, this is cheap, because we're just reading from SourceBufferIterator's local buffer until we reach a chunk boundary and it has to talk to the underlying SourceBuffer. SourceBufferIterator also handles zero-length reads, which simplifies matters since we don't have to be too clever about when we advance the iterator. (This is tested in the SourceBuffer GTest suite; we'll test it at the StreamingLexer level in tests attached to this bug.) What's really amazing is how much this change cleans up the code! StreamingLexer is now drastically easier to understand. It's amazing how much complexity arose from only being able to advance in chunks of unpredictable size.
Attachment #8771219 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 2•8 years ago
|
||
Part 1a killed the old StreamingLexer API, so we need to remove the corresponding tests. (The coverage is the same; there was a version of each test for each API previously, so we're just removing the old API versions.)
Attachment #8771220 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 3•8 years ago
|
||
As promised, here are some extra tests for zero-length states in both buffered and unbuffered situations.
Attachment #8771221 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 4•8 years ago
|
||
This is just a little cleanup patch; since we got rid of the duplicated tests, the "FromSourceBuffer" suffix on the test names is no longer necessary.
Attachment #8771222 -
Flags: review?(n.nethercote)
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → seth
Assignee | ||
Comment 5•8 years ago
|
||
Owing to a rebase mistake, the original part 1a patch failed to update nsPNGDecoder and nsJPEGDecoder to use the new calling convention. Fixed.
Assignee | ||
Updated•8 years ago
|
Attachment #8771219 -
Attachment is obsolete: true
Attachment #8771219 -
Flags: review?(n.nethercote)
Assignee | ||
Updated•8 years ago
|
Attachment #8771238 -
Flags: review?(n.nethercote)
Updated•8 years ago
|
Attachment #8771222 -
Flags: review?(n.nethercote) → review+
Updated•8 years ago
|
Attachment #8771221 -
Flags: review?(n.nethercote) → review+
Comment 6•8 years ago
|
||
Comment on attachment 8771220 [details] [diff] [review] (Part 1b) - Remove StreamingLexer tests that use the old API. Review of attachment 8771220 [details] [diff] [review]: ----------------------------------------------------------------- ::: image/test/gtest/TestStreamingLexer.cpp @@ +96,5 @@ > + case TestState::THREE: > + CheckLexedData(aData, aLength, 9); > + return Transition::TerminateSuccess(); > + default: > + MOZ_CRASH("Unknown TestState"); UNBUFFERED, which is a known TestState, would trigger this default case. Change to "Unknown or unhandled TestState"?
Attachment #8771220 -
Flags: review?(n.nethercote) → review+
Comment 7•8 years ago
|
||
Comment on attachment 8771238 [details] [diff] [review] (Part 1a) - Advance SourceBufferIterator in Lex() per-state. Review of attachment 8771238 [details] [diff] [review]: ----------------------------------------------------------------- r=me because I see no problems, but I don't know the internals of StreamingLexer.h well and so it wasn't a good review.
Attachment #8771238 -
Flags: review?(n.nethercote) → review+
Assignee | ||
Comment 8•8 years ago
|
||
Thanks for the quick review! (In reply to Nicholas Nethercote [:njn] from comment #7) > r=me because I see no problems, but I don't know the internals of > StreamingLexer.h well and so it wasn't a good review. The good news is that you sort of didn't have to, since I almost totally rewrote it in this patch. =)
Assignee | ||
Comment 9•8 years ago
|
||
This new version clarifies the assertions mentioned in the review comments.
Assignee | ||
Updated•8 years ago
|
Attachment #8771220 -
Attachment is obsolete: true
Comment 10•8 years ago
|
||
Pushed by mfowler@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/656d5e742049 (Part 1) - Advance SourceBufferIterator in Lex() per-state. r=njn https://hg.mozilla.org/integration/mozilla-inbound/rev/0284587d752d (Part 2) - Add new StreamingLexer tests for zero-length states. r=njn https://hg.mozilla.org/integration/mozilla-inbound/rev/b1e09b3b77dd (Part 3) - Remove the FromSourceBuffer suffix from StreamingLexer test names. r=njn
Comment 11•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/656d5e742049 https://hg.mozilla.org/mozilla-central/rev/0284587d752d https://hg.mozilla.org/mozilla-central/rev/b1e09b3b77dd
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox50:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in
before you can comment on or make changes to this bug.
Description
•