Bug 1533708: Properly shut down the remote service before launching Firefox again. r=jmathies
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 11 Mar 2019 14:58:08 +0000
changeset 521393 fdd61e6fb911
parent 521392 a14fcb229ddd
child 521394 67d5e0187652
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies
bugs1533708
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533708: Properly shut down the remote service before launching Firefox again. r=jmathies The main changes here are to stop checking if we're shutting down when we already know we are shutting down and making sure the windows remote server shuts down properly. I also spotted that nsINativeAppSupport.quit is now unused so I removed it. Differential Revision: https://phabricator.services.mozilla.com/D22771
toolkit/components/remote/nsWinRemoteServer.h
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsINativeAppSupport.idl
toolkit/xre/nsNativeAppSupportBase.cpp
--- a/toolkit/components/remote/nsWinRemoteServer.h
+++ b/toolkit/components/remote/nsWinRemoteServer.h
@@ -10,17 +10,17 @@
 
 #include "nsRemoteServer.h"
 
 #include <windows.h>
 
 class nsWinRemoteServer final : public nsRemoteServer {
  public:
   nsWinRemoteServer() = default;
-  ~nsWinRemoteServer() override = default;
+  ~nsWinRemoteServer() override { Shutdown(); }
 
   nsresult Startup(const char* aAppName, const char* aProfileName) override;
   void Shutdown() override;
 
  private:
   HWND mHandle;
 };
 
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1577,18 +1577,16 @@ static void SetupLauncherProcessPref() {
 
 #endif  // XP_WIN
 
 // If aBlankCommandLine is true, then the application will be launched with a
 // blank command line instead of being launched with the same command line that
 // it was initially started with.
 static nsresult LaunchChild(nsINativeAppSupport* aNative,
                             bool aBlankCommandLine = false) {
-  aNative->Quit();  // destroy message window
-
   // Restart this process by exec'ing it into the current process
   // if supported by the platform.  Otherwise, use NSPR.
 
 #ifdef MOZ_JPROF
   // make sure JPROF doesn't think we're E10s
   unsetenv("JPROF_SLAVE");
 #endif
 
@@ -4688,24 +4686,24 @@ int XREMain::XRE_main(int argc, char* ar
       rv == NS_SUCCESS_RESTART_APP_NOT_SAME_PROFILE) {
     appInitiatedRestart = true;
 
     // We have an application restart don't do any shutdown checks here
     // In particular we don't want to poison IO for checking late-writes.
     gShutdownChecks = SCM_NOTHING;
   }
 
-  if (!mShuttingDown) {
 #if defined(MOZ_HAS_REMOTE)
-    // shut down the x remote proxy window
-    if (mRemoteService) {
-      mRemoteService->ShutdownServer();
-    }
+  // Shut down the remote service. We must do this before calling LaunchChild
+  // if we're restarting because otherwise the new instance will attempt to
+  // remote to this instance.
+  if (mRemoteService) {
+    mRemoteService->ShutdownServer();
+  }
 #endif /* MOZ_WIDGET_GTK */
-  }
 
   mScopedXPCOM = nullptr;
 
 #if defined(XP_WIN)
   mozilla::widget::StopAudioSession();
 #endif
 
   // unlock the profile after ScopedXPCOMStartup object (xpcom)
--- a/toolkit/xre/nsINativeAppSupport.idl
+++ b/toolkit/xre/nsINativeAppSupport.idl
@@ -46,13 +46,12 @@
 
 interface nsIXULWindow;
 
 [scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
 interface nsINativeAppSupport : nsISupports {
     // Startup/shutdown.
     boolean start();
     void    enable();
-    void    quit();
 
     void onLastWindowClosing();
     void ReOpen();
 };
--- a/toolkit/xre/nsNativeAppSupportBase.cpp
+++ b/toolkit/xre/nsNativeAppSupportBase.cpp
@@ -17,15 +17,12 @@ nsNativeAppSupportBase::Start(bool *resu
   *result = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeAppSupportBase::Enable() { return NS_OK; }
 
 NS_IMETHODIMP
-nsNativeAppSupportBase::Quit() { return NS_OK; }
-
-NS_IMETHODIMP
 nsNativeAppSupportBase::ReOpen() { return NS_OK; }
 
 NS_IMETHODIMP
 nsNativeAppSupportBase::OnLastWindowClosing() { return NS_OK; }