Avoid interacting with the observer service from imgFrame during XPCOM shutdown

RESOLVED FIXED in mozilla35

Status

()

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: seth, Assigned: seth)

Tracking

unspecified
mozilla35
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments, 1 obsolete attachment)

Assignee

Description

5 years ago
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.
Assignee

Comment 1

5 years ago
This patch adds ShutdownTracker.
Attachment #8492485 - Flags: review?(tnikkel)
Assignee

Comment 2

5 years ago
We put ShutdownTracker to work immediately by avoiding imgFrame optimization during shutdown.
Attachment #8492486 - Flags: review?(tnikkel)
Assignee

Updated

5 years ago
Summary: Avoid interacting with the observer service during XPCOM shutdown → Avoid interacting with the observer service from imgFrame during XPCOM shutdown
Assignee

Comment 3

5 years ago
Trivial fix.
Attachment #8492493 - Flags: review?(tnikkel)
Assignee

Updated

5 years ago
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: 5 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.