Closed Bug 1070340 Opened 6 years ago Closed 6 years ago

Avoid interacting with the observer service from imgFrame during XPCOM shutdown


(Core :: ImageLib, defect)

Not set





(Reporter: seth, Assigned: seth)




(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:

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+
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.