From 7318dd5ba0e054ed12c4a4960510d48dd2ab5e09 Mon Sep 17 00:00:00 2001 From: Doug Thayer Date: Tue, 27 Apr 2021 00:15:05 +0000 Subject: [PATCH] Bug 1553399 - Unlock nsRemoteService before launching child r=mossop This fixes the issue for me. I can't think of any problems with doing this here? However I am not an expert in the remote service. As part of this I also cover the case where the user encounters the profile lock dialogue and selects to kill the existing instance of Firefox. This can result in a slow startup in a similar way as far as I've been able to observe. Differential Revision: https://phabricator.services.mozilla.com/D113054 --- toolkit/xre/nsAppRunner.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 3a9928cee452..eadc97fe5218 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -285,6 +285,9 @@ static const char gToolkitVersion[] = MOZ_STRINGIFY(GRE_MILESTONE); extern const char gToolkitBuildID[]; static nsIProfileLock* gProfileLock; +#if defined(MOZ_HAS_REMOTE) +static nsRemoteService* gRemoteService; +#endif int gRestartArgc; char** gRestartArgv; @@ -2451,6 +2454,12 @@ static ReturnAbortOnError ProfileLockedDialog(nsIFile* aProfileDir, SaveFileToEnv("XRE_PROFILE_PATH", aProfileDir); SaveFileToEnv("XRE_PROFILE_LOCAL_PATH", aProfileLocalDir); +#if defined(MOZ_HAS_REMOTE) + if (gRemoteService) { + gRemoteService->UnlockStartup(); + gRemoteService = nullptr; + } +#endif return LaunchChild(false, true); } } else { @@ -2553,7 +2562,12 @@ static ReturnAbortOnError ShowProfileManager( gRestartArgv[gRestartArgc++] = const_cast("-os-restarted"); gRestartArgv[gRestartArgc] = nullptr; } - +#if defined(MOZ_HAS_REMOTE) + if (gRemoteService) { + gRemoteService->UnlockStartup(); + gRemoteService = nullptr; + } +#endif return LaunchChild(false, true); } @@ -4480,6 +4494,7 @@ int XREMain::XRE_mainStartup(bool* aExitFlag) { mRemoteService = new nsRemoteService(gAppData->remotingName); if (mRemoteService && !mDisableRemoteServer) { mRemoteService->LockStartup(); + gRemoteService = mRemoteService; } #endif #if defined(MOZ_WIDGET_GTK) @@ -5261,6 +5276,7 @@ nsresult XREMain::XRE_mainRun() { if (mRemoteService && !mDisableRemoteServer) { mRemoteService->StartupServer(); mRemoteService->UnlockStartup(); + gRemoteService = nullptr; } #endif /* MOZ_WIDGET_GTK */