Bug 1399646: Part 1 - Destroy BackgroundPageThumbs instance at shutdown. r?Gijs
During extremely short sessions (such as the ones triggered by many tests),
the code run by BackgroundPageThumbs during shutdown can trigger
hard-to-diagnose issues, among the most serious being a deadlock in the
service worker registrar.
Calling the (currently unused) _destroy() method at the start of shutdown
seems to prevent the majority of these problems.
MozReview-Commit-ID: Go7OLzVM24G
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -201,16 +201,26 @@ const BackgroundPageThumbs = {
};
webProgress.addProgressListener(this._listener, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
wlBrowser.loadURI("chrome://global/content/backgroundPageThumbs.xhtml", 0, null, null, null);
this._windowlessContainer = wlBrowser;
return false;
},
+ _init() {
+ Services.obs.addObserver(this, "profile-before-change");
+ },
+
+ observe(subject, topic, data) {
+ if (topic == "profile-before-change") {
+ this._destroy();
+ }
+ },
+
/**
* Destroys the service. Queued and pending captures will never complete, and
* their consumer callbacks will never be called.
*/
_destroy() {
if (this._captureQueue)
this._captureQueue.forEach(cap => cap.destroy());
this._destroyBrowser();