Closed Bug 1160423 Opened 9 years ago Closed 9 years ago

Deliver the results of a size decode without using a runnable

Categories

(Core :: Graphics: ImageLib, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: seth, Assigned: seth)

References

Details

Attachments

(2 files)

It happens quite frequently that we uselessly decode the headers of an image twice. This happens because we will finish a size decode for the image off-main-thread, but before we can notify the main thread that that happened using a runnable, Necko delivers OnStopRequest to the main thread. Since we are required to send the load event from the OnStopRequest callback, and we cannot send the load event without knowing the image's size, we end up doing a second synchronous size decode in the OnImageDataComplete.

Especially after bug 1160422, an image's size decode should virtually always have finished before OnStopRequest gets delivered. We should just deliver the size decode results by updating RasterImage's members directly, under a mutex. We can use wait / notify to ensure that we always get the values, even if the main thread gets ahead.
Blocks: 1120511
(It's possible that we should bound the amount of time we wait, and then revert to a synchronous size decode. But I think we should try the simple thing first.)
This part adds the necessary locking for RasterImage::SetSize(). Since
RasterImage::mSize and RasterImage::mOrientation are now protected by a lock, we
need to take the lock everywhere we read or write them.

That's unfortunately a large number of places. I'm not wild about that; it may
be necessary, but I'm going to experiment with an alternative approach before
requesting review on this.
Here's part 2, which makes us actually deliver the size to RasterImage from
off-main-thread. These changes enable some additional refactoring, but I'll save
that for a followup.

(And I want to explore that alternative approach I mentioned above first.)
See Also: → 1163856
I think we're going to end up going with bug 1163856, so I'm resolving this for now. If we change our minds about bug 1163856, we can always reopen this one.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
No longer blocks: 1120511
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: