mach run and mach debug should pass in -foreground on Mac by default

RESOLVED FIXED in mozilla24

Status

RESOLVED FIXED
6 years ago
10 months ago

People

(Reporter: Ehsan, Assigned: Ehsan)

Tracking

Trunk
mozilla24
x86
Mac OS X

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [mach])

Attachments

(1 attachment)

(Assignee)

Description

6 years ago
Greg, if you agree I can write the patch.
I've never had to pass -foreground when running the app on OS X. What does it do? Why is it needed?
Component: mach → Build Config
Whiteboard: [mach]
"-foreground" prevents the app from being in the background on startup:
http://mxr.mozilla.org/mozilla-central/source/toolkit/xre/nsAppRunner.cpp#3080

If this is commonly needed then I agree it's a pain point we should fix, but I don't think making "mach run" pass more parameters is the best way to fix it.  Anyone running Firefox from an interactive shell probably wants it to go into the foreground by default (and that includes a much larger group than just Mozilla developers), so we should find a way to change the default behavior in that case.  For example, we could call SetFrontProcess by default if stdin is a TTY.

Adding parameters by default is annoying because most of these parameters have no built-in overrides, so we need to add more options if anyone wants to disable them (like bug 863709).
(Assignee)

Comment 3

6 years ago
Steven, would it make sense for you to do this by default?  I find it extremely annoying that Firefox goes to the background every time I launch it.  Chrome launches in the foreground by default.
Flags: needinfo?(smichaud)
If in doubt make the smallest change.

And I *am* in doubt.  For example it's conceivable that, under certain circumstances (debugging certain kinds of bugs) we might want Firefox to start in the background when run from a Terminal prompt (or from gdb running in a Terminal prompt).  In any case I'm so used to the current behavior that I hardly notice it anymore.  And on those few occasions when I actually need Firefox to start in the foreground, I call firefox with the -foreground flag.

So I'd vote for either making "mach run" pass a -foreground flag or for doing nothing at all.  In fact I'd prefer doing nothing at all.
Flags: needinfo?(smichaud)
(Assignee)

Comment 5

6 years ago
Hmm, sigh.  I have developed muscle memory for typing in "-foreground".  This is how annoying it is for me... :(
Out of curiosity, Ehsan, why do you always (or mostly) use "-foreground" when running Firefox from a Terminal prompt?

Is it just because you have to click on the browser window to foreground the app?  But you have to click on the browser window anyway to do anything in it.  The only thing it would make any difference for is menu commands (or their shortcuts).
Another thing:

When I start Firefox from a Terminal prompt, it's usually because I'm running a debug-logging build, and the output appears in Terminal.  In these cases I actually want Firefox to start in the background.
(In reply to Steven Michaud from comment #4)
> If in doubt make the smallest change.
> 
> And I *am* in doubt.  For example it's conceivable that, under certain
> circumstances (debugging certain kinds of bugs) we might want Firefox to
> start in the background when run from a Terminal prompt (or from gdb running
> in a Terminal prompt).

The default behavior should be the one that is desired most frequently -- if we can identify what that is.  If we do change the default to "foreground" then we can easily add a "-background" argument for use cases that need it.

On the other hand, opening in the background is a general problem with *all* GUI apps launched from the Mac terminal, and maybe Firefox should not try to be different here...

(In reply to Steven Michaud from comment #6)
> Is it just because you have to click on the browser window to foreground the
> app?  But you have to click on the browser window anyway to do anything in
> it.

That's not always easy, since the browser window might be obscured by the terminal.  And if you work on multiple platforms, you tend to expect apps to open in the foreground as they do on Windows and Linux.
> The default behavior should be the one that is desired most
> frequently -- if we can identify what that is.  If we do change the
> default to "foreground" then we can easily add a "-background"
> argument for use cases that need it.

Fair enough.

>> Is it just because you have to click on the browser window to
>> foreground the app?  But you have to click on the browser window >
>> anyway to do anything in it.
>
> That's not always easy, since the browser window might be obscured
> by the terminal.

Once again, fair enough.  I'd missed this.

> And if you work on multiple platforms, you tend to expect apps to
> open in the foreground as they do on Windows and Linux.

I don't think this should count for much.  But then I do 95+% of my
work on OS X.

So far I think this question (whether -foreground or -background
should be the default when running from the command line) seems
largely one of personal preference.  It seems to be difficult to come
up with "objective" reasons for preferring one or the other.

And frankly I could pretty easily live with either alternative :-)
(Assignee)

Comment 10

6 years ago
I'm a keyboard user, so I rarely need to use the mouse when I'm debugging Firefox, and the app going into the background breaks the workflow of keyboard users pretty horribly:

1. You run Firefox, and if you have a large terminal window you wonder what happened, since you don't even see Firefox!  ;-) If not, you see that it opened up.
2. You press Cmd+Tab to switch to it, and it's the _last_ entry in that menu, so you have to press Tab a variable number of times depending on how many apps you have open at that moment in time.
3. If you make a mistake (press Cmd+Tab 9 times instead of 10, for example) then you switch to an app that you did not intend to, and at that point your train of thought is wrecked!

Also, not every Mac app behaves this way, Chrome doesn't, for example.

I think how much this annoys you depends on how much stuff you do from the terminal.  For somebody who lives in the terminal like me, this is a huge pain that one needs to deal with every single day.  (Note that I've never even browsed my objdir in Finder, let alone having run my local builds by clicking on the icon!)
(Assignee)

Comment 11

6 years ago
Steven, it would be great if you could give us a yay or nay on this.  I'd like to explore other avenues to fix this issue if you don't like this behavior, as this issue is hurting me every day (but I don't mean to pressure you into saying yes, I just want us to reach a decision here.)

Thanks!
Flags: needinfo?(smichaud)
Ehsan, you've made it clear enough that *you'd* like the Firefox binary to default to running in the foreground when it's invoked from the command line.  But so far we haven't heard from anyone else.

I'm still convinced this question is entirely subjective.  But if a clear majority of developer types prefers changing the default, I'm fine with that.  I'd even be fine with it if a significant but noisy minority prefers this -- as long as there isn't another significant but noisy minority on the other side :-)

As I've said above, my own preference is for the current behavior, though I don't feel strongly about that.  But if we do make "-foreground" the default, we must provide a "-background" parameter that makes Firefox run in the background when it's run from the command line (we must make the current behavior still an option).

Bugzilla isn't the place to ask people what they think should be the default (-foreground or -background).  Maybe one of the mozilla.dev groups?
Flags: needinfo?(smichaud)
(Assignee)

Comment 13

6 years ago
(In reply to comment #12)
> Bugzilla isn't the place to ask people what they think should be the default
> (-foreground or -background).  Maybe one of the mozilla.dev groups?

Sure, I'll ask on dev.platform.  Thanks!
At this point the vote is heavily in favor of making -foreground the default:

https://groups.google.com/forum/?fromgroups#!topic/mozilla.dev.platform/ayEbEWT_DL0

So I think we should do it.  But some questions remain.

1) Should we add a parameter to "mach run", or should we change how the firefox binary behaves?

It'd be a lot easier to do the first.  The firefox binary's current behavior has been around for a long time, so there's a lot of code in the tree that depends on it.  Some of it's easy to find -- search the tree for "-foreground" to find code that explicitly makes firefox launch in the foreground.  But it'll be harder to find code that silently assumes the current behavior.

2) Should we create an additional, permanent setting that allows users to change the default back to the current behavior?

This wouldn't be hard, and I think we should do it.

If we're just changing how "mach run" behaves, we could (presumably) do this with an about:config setting.  But if we're changing how the firefox binary behaves, we'd probably need to use an environment variable.
(Assignee)

Comment 15

6 years ago
(In reply to comment #14)
> At this point the vote is heavily in favor of making -foreground the default:
> 
> https://groups.google.com/forum/?fromgroups#!topic/mozilla.dev.platform/ayEbEWT_DL0
> 
> So I think we should do it.  But some questions remain.
> 
> 1) Should we add a parameter to "mach run", or should we change how the firefox
> binary behaves?
> 
> It'd be a lot easier to do the first.  The firefox binary's current behavior
> has been around for a long time, so there's a lot of code in the tree that
> depends on it.  Some of it's easy to find -- search the tree for "-foreground"
> to find code that explicitly makes firefox launch in the foreground.  But it'll
> be harder to find code that silently assumes the current behavior.

I'll do the former, as it's a lot easier, and I don't want to spend a lot of time on this.  :-)

> 2) Should we create an additional, permanent setting that allows users to
> change the default back to the current behavior?

If you mean mach's default, then sure.  If you mean Firefox's, I don't think we should.

> This wouldn't be hard, and I think we should do it.
> 
> If we're just changing how "mach run" behaves, we could (presumably) do this
> with an about:config setting.  But if we're changing how the firefox binary
> behaves, we'd probably need to use an environment variable.

For mach, it's a lot easier, we will just pass -foreground by default, the same way as we pass -no-remote by default.
(Assignee)

Comment 16

6 years ago
Created attachment 756093 [details] [diff] [review]
Patch (v1)
Assignee: nobody → ehsan
Status: NEW → ASSIGNED
Attachment #756093 - Flags: review?(ted)
Attachment #756093 - Flags: review?(ted) → review+
(Assignee)

Comment 17

6 years ago
https://hg.mozilla.org/mozilla-central/rev/a167dfaa105b
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24

Updated

10 months ago
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.