Support headless mode on MacOS

RESOLVED FIXED in Firefox 56

Status

()

enhancement
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: bdahl, Assigned: bdahl)

Tracking

unspecified
Firefox 56
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox56 fixed)

Details

Attachments

(6 attachments)

Assignee

Description

2 years ago
No description provided.
Assignee

Updated

2 years ago
Blocks: 1355047
Assignee

Updated

2 years ago
Blocks: 1359374
Assignee

Updated

2 years ago
Component: General → Headless
Assignee

Updated

2 years ago
Assignee: nobody → bdahl
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Assignee

Comment 8

2 years ago
As for patch "Bug 1355147 - Change Firefox to a background application when headless." There's one downside to going from foreground to background in that the terminal very quickly looses and regains focus while the Firefox is being launched headlessly. I alternatively tried making Firefox a background application by default and changing it to the foreground for non-headless. However, this causes Firefox to not be focused by default. I could also force focus while making it foreground, but I was starting to think making Firefox a background app by default sounds a bit scary. Myk and I talked about potentially making another exe/bundle so that could be used to launch in the background by default, but I was curious to see if you had any other thoughts on this?
Flags: needinfo?(mstange)
Another bundle sounds like the right choice to me. Then you won't have to modify anything at runtime and won't affect regular Firefox.
Flags: needinfo?(mstange)
(In reply to Markus Stange [:mstange] from comment #9)
> Another bundle sounds like the right choice to me. Then you won't have to
> modify anything at runtime and won't affect regular Firefox.

Besides increasing Firefox's download size and Firefox bundle complexity (as the headless bundle would be contained within the Firefox bundle), this would make developers have to invoke a different executable to run Firefox headlessly on Mac.

It's critical not to affect regular Firefox, but I'm leery of complicating the developer ergonomics of headless mode.  We don't ship a separate executable for headless on Windows and Linux, nor does Chrome do so for headless on Mac (instead, it stays in the foreground).

So I'm inclined to prefer the temporary focus change, since it means I can tell developers to invoke the Firefox executable with the --headless flag to enter headless mode on all three platforms.
I see.

Have you tried if additionally calling [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited] avoids the focus change?

Comment 12

2 years ago
mozreview-review
Comment on attachment 8885844 [details]
Bug 1355147 - Add basic support for headless mode on macOS.

https://reviewboard.mozilla.org/r/156618/#review162208
Attachment #8885844 - Flags: review?(jmuizelaar) → review+

Comment 13

2 years ago
mozreview-review
Comment on attachment 8885845 [details]
Bug 1355147 - Expose IsHeadless on GfxInfo.

https://reviewboard.mozilla.org/r/156620/#review162210
Attachment #8885845 - Flags: review?(jmuizelaar) → review+

Comment 14

2 years ago
mozreview-review
Comment on attachment 8885849 [details]
Bug 1355147 - Use headless clipboard on macOS.

https://reviewboard.mozilla.org/r/156628/#review162212
Attachment #8885849 - Flags: review?(jmuizelaar) → review+
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Assignee

Updated

2 years ago
Attachment #8885846 - Flags: review?(dburns) → review?(hskupin)
Assignee

Updated

2 years ago
Attachment #8885848 - Flags: review?(dburns) → review?(hskupin)

Comment 19

2 years ago
mozreview-review
Comment on attachment 8885848 [details]
Bug 1355147 - Enable macOS headless marionette tests.

https://reviewboard.mozilla.org/r/156626/#review164048

::: taskcluster/ci/test/test-platforms.yml:198
(Diff revision 2)
>  
>  macosx64/debug:
>      build-platform: macosx64/debug
>      test-sets:
>          - macosx64-tests
> +        - headless

We are supporting it now for all platforms, right? Can't we move those tests to `common-tests` now? Or don't we want to run it for nightly builds?
Attachment #8885848 - Flags: review?(hskupin) → review+

Comment 20

2 years ago
mozreview-review
Comment on attachment 8885846 [details]
Bug 1355147 - Fix test moving to negative coordinates in headless mac.

https://reviewboard.mozilla.org/r/156622/#review164054
Attachment #8885846 - Flags: review?(hskupin) → review+

Comment 21

2 years ago
mozreview-review
Comment on attachment 8885847 [details]
Bug 1355147 - Change Firefox to a background application when headless.

https://reviewboard.mozilla.org/r/156624/#review166898

::: toolkit/xre/nsAppRunner.cpp:3178
(Diff revision 2)
>      Output(true, "Error: headless mode is not currently supported on this platform.\n");
>      return 1;
>  #endif
> +
> +#ifdef XP_MACOSX
> +  // To avoid taking focus when running in headless mode immediately

This needs to be indented two more spaces.
Attachment #8885847 - Flags: review?(mstange) → review+
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)
Assignee

Comment 28

2 years ago
mozreview-review
Comment on attachment 8885846 [details]
Bug 1355147 - Fix test moving to negative coordinates in headless mac.

https://reviewboard.mozilla.org/r/156622/#review167606

Carrying r+ forward.
Attachment #8885846 - Flags: review+
Assignee

Updated

2 years ago
Attachment #8885846 - Flags: review?(dburns)
Assignee

Comment 29

2 years ago
Comment on attachment 8885849 [details]
Bug 1355147 - Use headless clipboard on macOS.

There were some mac clipboard test failures with the previous way of using a singleton for the clipboard. I've updated the clipboard creation to make it a class that can be an instance. I'll also change the other platforms to do this in another bug.
Attachment #8885849 - Flags: review+ → review?(jmuizelaar)
Assignee

Comment 30

2 years ago
Comment on attachment 8885848 [details]
Bug 1355147 - Enable macOS headless marionette tests.

Carrying r+ forward from whimboo.
Attachment #8885848 - Flags: review?(dburns) → review+

Comment 31

2 years ago
mozreview-review
Comment on attachment 8885849 [details]
Bug 1355147 - Use headless clipboard on macOS.

https://reviewboard.mozilla.org/r/156628/#review167904
Attachment #8885849 - Flags: review?(jmuizelaar) → review+

Comment 32

2 years ago
Pushed by bdahl@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/1a4b6ccab14b
Add basic support for headless mode on macOS. r=jrmuizel
https://hg.mozilla.org/integration/mozilla-inbound/rev/803e1b08f00f
Expose IsHeadless on GfxInfo. r=jrmuizel
https://hg.mozilla.org/integration/mozilla-inbound/rev/19854c39011d
Fix test moving to negative coordinates in headless mac. r=whimboo
https://hg.mozilla.org/integration/mozilla-inbound/rev/a9e070c60d4b
Change Firefox to a background application when headless. r=mstange
https://hg.mozilla.org/integration/mozilla-inbound/rev/c18686139dbd
Enable macOS headless marionette tests. r=whimboo
https://hg.mozilla.org/integration/mozilla-inbound/rev/156623409e44
Use headless clipboard on macOS. r=jrmuizel
You need to log in before you can comment on or make changes to this bug.