Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Two questions: (1) launching a separate intance of firefox.exe, and (2) programmatically closing a window

61 views
Skip to first unread message

Mike Morearty

unread,
Nov 15, 2006, 8:40:28 PM11/15/06
to dev-apps...@lists.mozilla.org
I'm new to this alias...

Adobe Flex Builder has a debugger which is used for debugging Flex
(Flash) apps. The way it works is, it launches your browser, and then
the debugger and the Flash player connect to each other and begin
talking.

There are a couple of problems I've run into when doing this with
Firefox:

(1) It would be helpful to me if there was a way to launch multiple,
separate instances of Firefox.

Firefox only allows a single instance of the executable at a time. E.g.
on Windows, if firefox.exe is already running, and I create a new
firefox.exe, the second one just passes control to the first one.

The reason this is a problem is that if you hit a breakpoint in your
Flex app, then your browser is completely hung, so you can't do any
other browsing you might want to do, e.g. looking something up on the
web. Your only option is to either fire up some other browser, or stop
your debugging session.

If I could somehow tell Firefox, when I launch it, NOT to pass control
to an existing Firefox process, then I'd be set. I did find an
environment variable, MOZ_NO_REMOTE, which prevented it from passing
control to an existing instance; but that didn't work the way I wanted,
because it instead just displayed an error message to the user.

Is there some way to do this? If not, would it make sense for me to log
an enhancement request?

(2) It would be great if there was a way to programmatically tell
Firefox to close a particular window.

After the user is done with a debugging session, he typically clicks
Terminate in our debugger. At that point, I would like to close the
Firefox window that has the Flex app.

I couldn't figure out any way to tell Firefox to close a particular
window. (On Mac, I was able to figure out some AppleScript for both
Safari and Camino to close the window, but I couldn't figure out
Firefox.)

Again, is there some way to do this? If not, would it make sense for me
to log an enhancement request?

Thanks.

- Mike Morearty
Software developer
Adobe Flex Builder

Myk Melez

unread,
Nov 15, 2006, 9:06:16 PM11/15/06
to
Mike Morearty wrote:

> (1) It would be helpful to me if there was a way to launch multiple,
> separate instances of Firefox.

...


> If I could somehow tell Firefox, when I launch it, NOT to pass control
> to an existing Firefox process, then I'd be set. I did find an
> environment variable, MOZ_NO_REMOTE, which prevented it from passing
> control to an existing instance; but that didn't work the way I wanted,
> because it instead just displayed an error message to the user.

MOZ_NO_REMOTE should do what you want. What error message did it
display? If the message was about not being able to run two instances
of Firefox against the same profile, then the variable wasn't working
properly.

Perhaps you simply need to specify a different profile, however, using
the -P (/P on Windows, I think) command-line flag to firefox.exe? You
can't run separate processes against the same profile; you need separate
profiles for each process.


> (2) It would be great if there was a way to programmatically tell
> Firefox to close a particular window.
>
> After the user is done with a debugging session, he typically clicks
> Terminate in our debugger. At that point, I would like to close the
> Firefox window that has the Flex app.

Hmm, not sure about this one.

-myk

Tony Mechelynck

unread,
Nov 16, 2006, 4:23:42 PM11/16/06
to

The main command-line arguments (including -P ) can be displayed by invoking
the following from the shell (or Dos Box) prompt:

firefox -h |more

The redirection is necessary on some platforms (such as Windows) otherwise
there will be no output at all.


Best regards,
Tony.

Mike Morearty

unread,
Nov 16, 2006, 5:55:55 PM11/16/06
to dev-apps...@lists.mozilla.org
Myk Melez wrote:

> MOZ_NO_REMOTE should do what you want. What error message did it
> display? If the message was about not being able to run two
> instances
> of Firefox against the same profile, then the variable wasn't working
> properly.

On Windows, the message is, "Firefox is already running, but is not
responding. To open a new window, you must first close the existing
Firefox process, or restart your system."

On Mac, the message is, "A copy of Firefox is already open. Only one
copy of Firefox can be open at a time." (Actually, on Mac there are
other issues related to launch that I won't go into right now.)

I'm pretty sure this is in fact related to the fact that the profile is
already in use.

We did consider using a different profile, e.g. create one called "Flex
Builder Debugger" or something. It does actually work, so the issue
does seem to be that Firefox allows one firefox.exe *per profile*.

But unfortunately, that caused other problems. When a user is
debugging, he may need access to various things in his user profile,
e.g. some of his bookmarks.

I'd love it is MOZ_NO_REMOTE worked, allowing multiple copies of
firefox.exe to work with a single profile. Of course perhaps there are
synchronization issues there; I am guessing that, since firefox prevents
two instances of the app from accessing the same profile, once the app
is running it "owns" the entire profile, and doesn't have to worry about
synchronizing file access.

But, it sounds like you say MOZ_NO_REMOTE is supposed to do what I want?

(And Tony, thanks for the tip on piping "firefox -h" to "more".)

- Mike

> _______________________________________________
> dev-apps-firefox mailing list
> dev-apps...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-apps-firefox
>

Peter Kasting

unread,
Nov 16, 2006, 6:22:40 PM11/16/06
to Mike Morearty, dev-apps...@lists.mozilla.org
Mike Morearty wrote:
> I'd love it is MOZ_NO_REMOTE worked, allowing multiple copies of
> firefox.exe to work with a single profile. Of course perhaps there are
> synchronization issues there; I am guessing that, since firefox prevents
> two instances of the app from accessing the same profile, once the app
> is running it "owns" the entire profile, and doesn't have to worry about
> synchronizing file access.

The profiles are not at all multi-process safe. Thus, regardless of the
setting of MOZ_NO_REMOTE, you cannot open the same profile in more than
one process at once.

Fixing this would probably be fairly tricky but might make possible (or
easier) features like a profile that lives on the network and is shared
among multiple machines.

> But, it sounds like you say MOZ_NO_REMOTE is supposed to do what I want?

It only cancels the remoting to an existing running process. The only
way to actually run multiple instances is to use MOZ_NO_REMOTE in
combination with separate profiles per instance.

PK

Gijs Kruitbosch ("Hannibal")

unread,
Nov 16, 2006, 6:24:16 PM11/16/06
to
Mike Morearty wrote:
> It does actually work, so the issue
> does seem to be that Firefox allows one firefox.exe *per profile*.

Correct. And I don't see that changing very soon, either, due to the
synchronization reasons you mentioned. As it turns out, it's even pretty
hard (or at least used to be pretty hard) to copy or move a profile
without screwing things up, because several things in extension
installation and such refer to (each)other using paths, which screws up
if you move/copy things around.

Your bookmarks are easily copied though, as are your preferences. Then
you get to the reinstalling all the themes and extensions bit, and/or
possibly saved passwords and certs, which is where things get harder. I
think.

So, to be honest, I don't think there's much you can do about it. What I
don't get is why the debugging profile actually needs anything from the
old profile. I can see why you'd want it to have its own set of
bookmarks to whatever it is you're debugging, perhaps. And maybe its own
set of developer extensions. But that's about it, right?

-- Gijs

Shadow2531

unread,
Nov 16, 2006, 6:39:01 PM11/16/06
to Mike Morearty, dev-apps...@lists.mozilla.org
On 11/16/06, Mike Morearty <mmor...@adobe.com> wrote:

> Myk Melez wrote:
>
> > MOZ_NO_REMOTE should do what you want.

Slightly off-topic, but Thank You. I've been trying to load 2
instances of Firefox for a long, long, long time.

I've asked a zillion people (even on forums.mozillazine.org) before
and no one has ever had a good answer. It was always, "Firefox only
allows one instance to run, even if you use different profiles.",
which I always thought sucked big time because with Opera, I can run
40 different builds at once if I want.

Anyway, with MOZ_NO_REMOTE, here's how I load 2 instances of Firefox
and it works great:

MOZ_NO_REMOTE=1 for an enviroment variable
firefox.exe -p defaultprofile
firefoxtrunk.exe -p trunkprofile

--
burnout426

alta88

unread,
Nov 17, 2006, 2:51:13 PM11/17/06
to
with Fx2, you no longer need to set the win env var. simply
\firefox.exe -no-remote [-P profilename]. looks like it was omitted
from the -help output.

multiple instances of Fx with the same profile would be a significant
improvement in flexibility. multiprocess safe bookmarks are only the
first big item. spelling dictionaries, adblock filters, chrome/content
stylings, etc etc...

the other problem with multiple instances/profiles is that -no-remote
will obviously stop all communication with, say, Thunderbird. so
mailto: or rss subscribing etc etc will no longer work (will give Tb is
already running).

i've worked around this by having a main profile run without -no-remote,
and several profiles each started with -no-remote. however, it's still
not optimal; the Fx design here is weak. undoubtedly, the
'lowest-common-denominator' would be the excuse..

kevin...@bellsouth.net

unread,
Dec 2, 2006, 11:37:26 PM12/2/06
to
Yes, we have problems utilizing some of the features that exist in
Netscape and IE as well. When I need to do what you are doing I always
use IE.

We are currently wrestling with some problems, where we are trying to
create an application using FF2 (it used to be based upon netscape,
years ago. We have to decide to either fix some of the existing FF
bugs ourselves to get correct behaviour, or just switch to Netscape,
which also has some funkiness we were hoping to avoid. Tough call.

0 new messages