Closed Bug 1126038 Opened 9 years ago Closed 9 years ago

Finish decoding off-main-thread

Categories

(Core :: Graphics: ImageLib, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla38
Tracking Status
firefox37 --- fixed
firefox38 --- fixed

People

(Reporter: seth, Assigned: seth)

References

Details

Attachments

(1 file, 1 obsolete file)

Right now, Decoder::Finish only runs on the main thread.

This is problematic for two reasons:

1. It wastes main thread resources, because much of the work in Decoder::Finish can actually be done off-main-thread.

2. More seriously, it can cause deadlock, because for some image formats we don't call Decoder::PostFrameStop (which is responsible for calling imgFrame::Finish) until we call Decoder::Finish, and if the main thread is blocked in imgFrame::WaitUntilComplete, waiting for that imgFrame::Finish call on the same frame... kaboom.

So let's fix this.

I actually think the whole decoder shutdown sequence needs a complete refactoring (we have Decoder::Finish, Decoder::FinishInternal, RasterImage::OnDecodingComplete, RasterImage::FinalizeDecoder... too much, and in this bug I'll make it worse) and I intend to file a bug to do that soon, but I think this particular issue should be fixed separately. For one thing, it's blocking the landing of bug 1125490, but it's also generally important and I don't want it to get backed out if I make a mistake in the subsequent refactoring.
Component: Layout: Images → ImageLib
Attached patch Finish decoding off-main-thread (obsolete) — Splinter Review
Here's the patch.
Attachment #8554849 - Flags: review?(tnikkel)
Blocks: 1079627
The tests there look good except for a devtools failure which is caused by us
failing to print a error to the console for a corrupt image. This seems to be
because the code in CompleteDecode() considers the image usable and calls
PostFrameStop(), PostDecodeDone(), etc., so we don't enter the similar |if|
branch in Finish(). This version of the patch is the same except that I've added
a flag to remember that we should report an error to the console in Finish().

New Linux-only try job here, to verify that this fixes the problem:

https://tbpl.mozilla.org/?tree=Try&rev=016dd3de7eaf
Attachment #8554953 - Flags: review?(tnikkel)
Attachment #8554849 - Attachment is obsolete: true
Attachment #8554849 - Flags: review?(tnikkel)
Attachment #8554953 - Flags: review?(tnikkel) → review+
https://hg.mozilla.org/mozilla-central/rev/00f4c6c6f553
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Comment on attachment 8554953 [details] [diff] [review]
Finish decoding off-main-thread

Approval Request Comment
[Feature/regressing bug #]: Part of fix for bug 1125272 and bug 1119938.
[User impact if declined]: Already approved.
[Describe test coverage new/current, TreeHerder]: In 38 for a long time.
[Risks and why]: Low risk; in 38 for a long time.
[String/UUID change made/needed]: None.
Attachment #8554953 - Flags: approval-mozilla-aurora?
Comment on attachment 8554953 [details] [diff] [review]
Finish decoding off-main-thread

Aurora approval previously granted for a collection of ImageLib related bugs that Seth worked on and QE verified before uplift.
Attachment #8554953 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: