Skip to content

Commit

Permalink
Bug 1523609 - avoid triggering nsChromeRegistryChrome::CheckForNewChr…
Browse files Browse the repository at this point in the history
…ome (which does main thread I/O) during shutdown of system add-ons, r=kmag.

Differential Revision: https://phabricator.services.mozilla.com/D22380

--HG--
extra : moz-landing-system : lando
  • Loading branch information
fqueze committed Mar 22, 2019
1 parent d65d068 commit dbd7ac1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
6 changes: 5 additions & 1 deletion browser/extensions/formautofill/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ this.formautofill = class extends ExtensionAPI {
Services.mm.loadFrameScript("chrome://formautofill/content/FormAutofillFrameScript.js", true, true);
}

onShutdown() {
onShutdown(reason) {
if (reason == "APP_SHUTDOWN") {
return;
}

resProto.setSubstitution(RESOURCE_HOST, null);

this.chromeHandle.destruct();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let l10nManifest;

this.l10n = class extends ExtensionAPI {
onShutdown(reason) {
if (l10nManifest) {
if (reason !== "APP_SHUTDOWN" && l10nManifest) {
Components.manager.removeBootstrappedManifestLocation(l10nManifest);
}
}
Expand Down
7 changes: 7 additions & 0 deletions chrome/nsChromeRegistryChrome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "mozilla/Unused.h"
#include "mozilla/intl/LocaleService.h"

#include "nsIAppStartup.h"
#include "nsIObserverService.h"
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
Expand Down Expand Up @@ -273,6 +274,12 @@ nsChromeRegistryChrome::Observe(nsISupports* aSubject, const char* aTopic,

NS_IMETHODIMP
nsChromeRegistryChrome::CheckForNewChrome() {
nsCOMPtr<nsIAppStartup> appStartup = components::AppStartup::Service();
if (appStartup->GetShuttingDown()) {
MOZ_ASSERT(false, "checking for new chrome during shutdown");
return NS_ERROR_UNEXPECTED;
}

mPackagesHash.Clear();
mOverrideTable.Clear();

Expand Down
5 changes: 2 additions & 3 deletions toolkit/components/startup/public/nsIAppStartup.idl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

interface nsIToolkitProfile;

[scriptable, uuid(6621f6d5-6c04-4a0e-9e74-447db221484e)]

[scriptable, builtinclass, uuid(6621f6d5-6c04-4a0e-9e74-447db221484e)]
interface nsIAppStartup : nsISupports
{
/**
Expand Down Expand Up @@ -142,7 +141,7 @@ interface nsIAppStartup : nsISupports
/**
* True if the application is in the process of shutting down.
*/
readonly attribute boolean shuttingDown;
[infallible] readonly attribute boolean shuttingDown;

/**
* True if the application is in the process of starting up.
Expand Down
9 changes: 9 additions & 0 deletions toolkit/mozapps/extensions/AddonManagerStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "mozilla/ClearOnShutdown.h"
#include "mozilla/EndianUtils.h"
#include "mozilla/Components.h"
#include "mozilla/Compression.h"
#include "mozilla/LinkedList.h"
#include "mozilla/Preferences.h"
Expand All @@ -30,6 +31,7 @@
#include "nsAppRunner.h"
#include "nsContentUtils.h"
#include "nsChromeRegistry.h"
#include "nsIAppStartup.h"
#include "nsIDOMWindowUtils.h" // for nsIJSRAIIHelper
#include "nsIFileURL.h"
#include "nsIIOService.h"
Expand Down Expand Up @@ -692,6 +694,13 @@ RegistryEntries::Destruct() {
if (isInList()) {
remove();

// No point in doing I/O to check for new chrome during shutdown, return
// early in that case.
nsCOMPtr<nsIAppStartup> appStartup = components::AppStartup::Service();
if (!appStartup || appStartup->GetShuttingDown()) {
return NS_OK;
}

// When we remove dynamic entries from the registry, we need to rebuild it
// in order to ensure a consistent state. See comments in Observe().
RefPtr<nsChromeRegistry> cr = nsChromeRegistry::GetSingleton();
Expand Down

0 comments on commit dbd7ac1

Please sign in to comment.