Closed Bug 1070340 Opened 6 years ago Closed 6 years ago

Avoid interacting with the observer service from imgFrame during XPCOM shutdown

Categories

(Core :: ImageLib, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla35

People

(Reporter: seth, Assigned: seth)

References

Details

Attachments

(2 files, 1 obsolete file)

So bug 1069652 makes us call imgFrame::Optimize() during imgFrame::UnlockImageData(), which is almost always what we want, except for in one scenario: during XPCOM shutdown. In this situation, we can't let Optimize() run, because it calls getPlatform::GetPlatform(), which needs the observer service to be available. During shutdown, it's not, and we get this kind of failure:

https://tbpl.mozilla.org/php/getParsedLog.php?id=48431848&tree=Try#error1

This bug will add an imagelib-global service called ShutdownTracker which lets us know whether the 'xpcom-shutdown' notification has been delivered. It's preferable to do this in a single place because shutdown observers aren't free, and we don't want to add the additional logic everywhere we need it. (And I suspect we'll need it in more places.)

This bug also adds a call to ShutdownTracker::ShutdownHasStarted() in imgFrame::Optimize(), so we don't try to optimize during shutdown.
This patch adds ShutdownTracker.
Attachment #8492485 - Flags: review?(tnikkel)
We put ShutdownTracker to work immediately by avoiding imgFrame optimization during shutdown.
Attachment #8492486 - Flags: review?(tnikkel)
Summary: Avoid interacting with the observer service during XPCOM shutdown → Avoid interacting with the observer service from imgFrame during XPCOM shutdown
Trivial fix.
Attachment #8492493 - Flags: review?(tnikkel)
Attachment #8492486 - Attachment is obsolete: true
Attachment #8492486 - Flags: review?(tnikkel)
Comment on attachment 8492485 [details] [diff] [review]
(Part 1) - Add ShutdownTracker to imagelib

>+  /**
>+   * Check whether shutdown has started. Callers can use this to check whether
>+   * it's safe to access XPCOM services; if shutdown has started, such calls
>+   * must be avoided.
>+   *
>+   * @return true if shutdown has already started.
>+   */
>+  static bool ShutdownHasStarted();

This might be clearer if it was called GetHasShutdownStarted.
Attachment #8492485 - Flags: review?(tnikkel) → review+
Attachment #8492493 - Flags: review?(tnikkel) → review+
https://hg.mozilla.org/mozilla-central/rev/f7e8bda1300c
https://hg.mozilla.org/mozilla-central/rev/ac1a42852e62
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
Depends on: 1071217
You need to log in before you can comment on or make changes to this bug.