William A. Law wrote:
> Attached is a patch that adds support for a new "-server" command-line
> switch for Win32. It will suppress opening the initial window (but not
> profile manager so it really only works properly if you have a single
> profile and don't normally see the profile manager dialog at startup).
>
> Launching Mozilla again will simply open a new window. There's a patch
> to the DDE server code to support that better; thanks to Brian
> ([EMAIL PROTECTED]) who provided that code for bug 50424.
>
> Opening the first navigator window takes 6-7 sec with mozilla already
> running in "server mode." That's versus 10-11 seconds starting from
> scratch.
>
> Subsequent windows take 2-3 seconds (once mozilla is running with a
> Navigator window open; "server mode" or not).
>
> We need to figure out what other services/libraries to load initially
> and figure out how to do that.
>
> This code might support the Mac without too much work. Linux is another
> story because it doesn't have any ipc mechanism for a second instance of
> the app to talk to the already running "server."
Not true. The wrapper script that I distribute with my rpms uses -remote to open new
windows. It works pretty well.
I don't actually launch the program until you try and open a window but it's a good
start.
--Chris
>
> Bill Law
>
> Chris McAfee wrote:
>
>> Sky wrote:
>>
>>> Saw this in a forum somewhere
>>>
>>> "I don't know all that much about coding myself, but I think that it
>>> would
>>> be interesting if someone were to create an optional preloader for
>>> Mozilla
>>> that ran when you started up Windows that loaded up
>>> some of the, uh, core files and stuff so that there wouldn't be so
>>> much of a
>>> wait every time you load Moz for the first time (not that it's the WORST
>>> wait in the world, I'm just saying there is room for
>>> improvement still, right?)
>>> "
>>
>>
>>
>> Yes, we have been thinking about this. CC-ing .performance.
>>
>> -Chris
>
>
>
> ------------------------------------------------------------------------
>
> Index: appshell/public/nsINativeAppSupport.h
> ===================================================================
> RCS file: /cvsroot/mozilla/xpfe/appshell/public/nsINativeAppSupport.h,v
> retrieving revision 1.1
> diff -u -r1.1 nsINativeAppSupport.h
> --- nsINativeAppSupport.h 2000/05/03 23:14:59 1.1
> +++ nsINativeAppSupport.h 2001/02/27 04:35:31
> @@ -137,6 +137,9 @@
> NS_IMETHOD ShowSplashScreen() = 0;
> NS_IMETHOD HideSplashScreen() = 0;
>
> + // Server mode.
> + NS_IMETHOD GetIsServerMode( PRBool *pResult ) = 0;
> + NS_IMETHOD SetIsServerMode( PRBool pServerMode ) = 0;
> }; // class nsINativeAppSupport
>
> #endif // nsINativeAppSupport_h__
> Index: bootstrap/nsAppRunner.cpp
> ===================================================================
> RCS file: /cvsroot/mozilla/xpfe/bootstrap/nsAppRunner.cpp,v
> retrieving revision 1.265
> diff -u -r1.265 nsAppRunner.cpp
> --- nsAppRunner.cpp 2001/02/26 00:31:44 1.265
> +++ nsAppRunner.cpp 2001/02/27 04:35:31
> @@ -63,6 +63,7 @@
> #include "nsBuildID.h"
> #include "nsWindowCreator.h"
> #include "nsIWindowWatcher.h"
> +#include "nsIBookmarksService.h"
>
> // Interfaces Needed
> #include "nsIXULWindow.h"
> @@ -681,6 +682,24 @@
> if (NS_FAILED(rv))
> return rv;
>
> + // If native app in server mode, we don't need any windows.
> + nsCOMPtr<nsIAppShellService> appShellService(do_GetService(kAppShellServiceCID));
> + if (appShellService)
> + {
> + nsCOMPtr<nsINativeAppSupport> nativeApp;
> + appShellService->GetNativeAppSupport(getter_AddRefs(nativeApp));
> + if (nativeApp)
> + {
> + PRBool serverMode = PR_FALSE;
> + if (NS_SUCCEEDED(nativeApp->GetIsServerMode(&serverMode))&&serverMode)
> + {
> + // Force bookmarks to load in this sceanario.
> + nsCOMPtr<nsIBookmarksService>
>bookmarks(do_GetService(NS_BOOKMARKS_SERVICE_CONTRACTID));
> + return NS_OK;
> + }
> + }
> + }
> +
> nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
>
> if (NS_SUCCEEDED(windowMediator->GetEnumerator(nsnull,
>getter_AddRefs(windowEnumerator))))
> Index: bootstrap/nsNativeAppSupportBase.h
> ===================================================================
> RCS file: /cvsroot/mozilla/xpfe/bootstrap/nsNativeAppSupportBase.h,v
> retrieving revision 1.1
> diff -u -r1.1 nsNativeAppSupportBase.h
> --- nsNativeAppSupportBase.h 2000/05/10 22:05:43 1.1
> +++ nsNativeAppSupportBase.h 2001/02/27 04:35:31
> @@ -45,6 +45,17 @@
> NS_IMETHOD ShowSplashScreen();
> NS_IMETHOD HideSplashScreen();
>
> + NS_IMETHOD GetIsServerMode( PRBool *pResult ) {
> + NS_ENSURE_ARG( pResult );
> + *pResult = mIsServerMode;
> + return NS_OK;
> + }
> +
> + NS_IMETHOD SetIsServerMode( PRBool serverMode ) {
> + mIsServerMode = serverMode;
> + return NS_OK;
> + }
> +
> NS_IMETHOD CreateSplashScreen( nsISplashScreen **splash );
>
> // nsISupports methods
> @@ -54,5 +65,6 @@
>
> nsrefcnt mRefCnt;
> nsISplashScreen *mSplash;
> + PRBool mIsServerMode;
> }; // class nsSplashScreenWin
>
> Index: bootstrap/nsNativeAppSupportWin.cpp
> ===================================================================
> RCS file: /cvsroot/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp,v
> retrieving revision 1.16
> diff -u -r1.16 nsNativeAppSupportWin.cpp
> --- nsNativeAppSupportWin.cpp 2000/10/28 22:17:32 1.16
> +++ nsNativeAppSupportWin.cpp 2001/02/27 04:35:31
> @@ -228,7 +228,7 @@
> // Utility function to handle a Win32-specific command line
> // option: "-console", which dynamically creates a Windows
> // console.
> - static void CheckConsole();
> + void CheckConsole();
>
> private:
> static HDDEDATA CALLBACK HandleDDENotification( UINT uType,
> @@ -470,6 +470,14 @@
> }
> // Don't bother doing this more than once.
> break;
> + } else if ( strcmp( "-server", __argv[i] ) == 0
> + ||
> + strcmp( "/server", __argv[i] ) == 0 ) {
> + // Start in server mode (and suppress splash screen).
> + SetIsServerMode( PR_TRUE );
> + __argv[i] = "-nosplash"; // Hack, but it works!
> + // Ignore other args.
> + break;
> }
> }
> return;
> @@ -479,8 +487,9 @@
> // Create and return an instance of class nsNativeAppSupportWin.
> nsresult
> NS_CreateNativeAppSupport( nsINativeAppSupport **aResult ) {
> + nsNativeAppSupportWin *native = 0;
> if ( aResult ) {
> - *aResult = new nsNativeAppSupportWin;
> + *aResult = native = new nsNativeAppSupportWin;
> if ( *aResult ) {
> NS_ADDREF( *aResult );
> } else {
> @@ -491,7 +500,7 @@
> }
>
> // Check for dynamic console creation request.
> - nsNativeAppSupportWin::CheckConsole();
> + native->CheckConsole();
> return NS_OK;
> }
>
> @@ -847,6 +856,8 @@
> #if MOZ_DEBUG_DDE
> printf( "Unknown request [%s]\n", (char*) request );
> #endif
> + // If all else fails, open new browser window.
> + (void)OpenWindow( "chrome://navigator/content/", 0 );
> }
>
> }
> @@ -1020,20 +1031,33 @@
> &jsContext );
> if ( NS_SUCCEEDED( rv ) ) {
> void *stackPtr;
> - jsval *argv = JS_PushArguments( jsContext,
> - &stackPtr,
> - "ssss",
> - urlstr,
> - "_blank",
> - "chrome,dialog=no,all",
> - args );
> + jsval *argv;
> + if (args) {
> + argv = JS_PushArguments( jsContext,
> + &stackPtr,
> + "ssss",
> + urlstr,
> + "_blank",
> + "chrome,dialog=no,all",
> + args );
> + } else {
> + argv = JS_PushArguments( jsContext,
> + &stackPtr,
> + "sss",
> + urlstr,
> + "_blank",
> + "chrome,dialog=no,all" );
> + }
> if( argv ) {
> nsCOMPtr<nsIDOMWindowInternal> newWindow;
> rv = hiddenWindow->OpenDialog( jsContext,
> argv,
> - 4,
> + args ? 4 : 3,
> getter_AddRefs( newWindow ) );
> JS_PopArguments( jsContext, stackPtr );
> + #ifdef MOZ_DEBUG_DDE
> + printf( "OpenDialog %s for [%s] returned rv=0x%08X\n", urlstr, args
>? args : "", (int)rv );
> + #endif
> }
> } else {
> #ifdef MOZ_DEBUG_DDE
> patch.serverMode
>
> Content-Type:
>
> text/plain
> Content-Encoding:
>
> 7bit
--
------------
Christopher Blizzard
http://people.redhat.com/blizzard/
mozilla.org - We're on a mission from God. Still.
------------