Support headless flag on Linux

RESOLVED FIXED in Firefox 55

Status

()

enhancement
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: bdahl, Assigned: bdahl)

Tracking

({dev-doc-needed})

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

Firefox Tracking Flags

(firefox55 fixed)

Details

Attachments

(7 attachments, 1 obsolete attachment)

Assignee

Description

2 years ago
Add a --headless flag on Linux that starts the browser in headless mode.
Assignee

Updated

2 years ago
Depends on: 1353938

Updated

2 years ago
Keywords: dev-doc-needed

Comment 1

2 years ago
Hopefully this is the right place, but it would be great to remove the pulse-audio dependency in headless mode. Pulseaudio carries a lot of baggage and getting rid of it on headless would make VM images much smaller.

Thanks for working on this btw.
Uhm pulseaudio can be useful to show video or audio so I think that is required also on headless, maybe is a topic for another ticket. I am not sure if Firefox can be build without pulseaudio but I think that in that case will be better :-)

Any news for this? Beucase I want to experiment on top of it and on Linux is very important to enable the support also to the embedded/IoT world.
Actually on Linux I get:

 $  MOZ_HEADLESS=1 /home/mte90/ffnightly/firefox
*** You are running in headless mode.
*** You are running in headless mode.

(firefox:9635): Gdk-CRITICAL **: gdk_x11_display_get_xdisplay: assertion 'GDK_IS_DISPLAY (display)' failed
ExceptionHandler::GenerateDump cloned child 9669
ExceptionHandler::SendContinueSignalToChild sent continue signal to child
ExceptionHandler::WaitForContinueSignal waiting for continue signal...


And this is the report on https://crash-stats.mozilla.com/report/index/bc227383-278d-4e48-a4f4-8f9380170424

Comment 4

2 years ago
(In reply to Daniele "Mte90" Scasciafratte from comment #2)
> Uhm pulseaudio can be useful to show video or audio so I think that is
> required also on headless, maybe is a topic for another ticket. I am not
> sure if Firefox can be build without pulseaudio but I think that in that
> case will be better :-)

It can be useful, but only if you want to hear something. I'm betting headless will more likely be used for automatic testing where you neither need to hear nor see anything. It would make sense to have a default null fallback that allows calls, but doesn't try to actually access a device. VLC does it and they are all about audio/video.
Assignee

Updated

2 years ago
Assignee: nobody → bdahl
Assignee

Comment 5

2 years ago
Adds support for a --headless flag for marionette to start
Firefox in headless mode. Also, adds a new task cluster
test group for the headless marionette tests.
Attachment #8864326 - Flags: review?(dburns)
Assignee

Comment 6

2 years ago
These are various fixes to get most of the headless
marionette tests working.
Attachment #8864327 - Flags: review?(jmuizelaar)
Assignee

Comment 7

2 years ago
Supports changing the size of a headless screen with
environment variables.
Attachment #8864328 - Flags: review?(kchen)
Assignee

Comment 8

2 years ago
Attachment #8864329 - Flags: review?(jmuizelaar)
Assignee

Comment 9

2 years ago
Alert dialogs trigger a call into gtk to get native sound which
crashes in headless.
Attachment #8864331 - Flags: review?(jmuizelaar)
Comment on attachment 8864328 [details] [diff] [review]
Part 3 - Add headless screen helper.

Review of attachment 8864328 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/headless/HeadlessScreenHelper.cpp
@@ +31,5 @@
> +
> +HeadlessScreenHelper::HeadlessScreenHelper()
> +{
> +  AutoTArray<RefPtr<Screen>, 4> screenList;
> +  LayoutDeviceIntRect rect = GetScreenRect();

The list always only has one element so this should be 1
Attachment #8864328 - Flags: review?(kchen) → review+
Comment on attachment 8864326 [details] [diff] [review]
Part 1 - Add headless marionette tests.

Review of attachment 8864326 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good. It might be worth speaking to the TC team to make sure they are aware of the increase in load.
Attachment #8864326 - Flags: review?(dburns) → review+
Attachment #8864327 - Flags: review?(jmuizelaar) → review+
Comment on attachment 8864329 [details] [diff] [review]
Part 4 - Support moving a headless window.

Review of attachment 8864329 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/headless/HeadlessWidget.cpp
@@ +86,5 @@
> +      mWindowType == eWindowType_dialog) {
> +      SetSizeMode(nsSizeMode_Normal);
> +  }
> +
> +  // Since a popup window's x/y coordinates are in relation to to

to to
Attachment #8864329 - Flags: review?(jmuizelaar) → review+
Attachment #8864331 - Flags: review?(jmuizelaar) → review+
Assignee

Comment 13

2 years ago
Some new marionette tests for windows size changes were added while I was on PTO.
Attachment #8867832 - Flags: review?(jmuizelaar)
Assignee

Comment 14

2 years ago
Hopefully the last part for this bug.
Attachment #8867943 - Flags: review?(jmuizelaar)
Attachment #8867832 - Flags: review?(jmuizelaar) → review+
Comment on attachment 8867943 [details] [diff] [review]
Part 7 - Add the --headless flag.

Review of attachment 8867943 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/xre/nsAppRunner.cpp
@@ +3147,5 @@
>    }
>  
> +  if (CheckArg("headless")) {
> +    PR_SetEnv("MOZ_HEADLESS=1");
> +  }

We should switch using a bool or something like gfxConfig instead of the environment variable directly. i.e. gfxPlatform::IsHeadless() shouldn't be checking the environment variables.
Attachment #8867943 - Flags: review?(jmuizelaar) → review-
Assignee

Comment 16

2 years ago
As discussed on IRC, IsHeadless is needed pretty early on startup before gfxConfig is initialized. We could add a gfxPlatform::EnableHeadless, but this would require each new process to call this. Just using an environment variable and caching it seems the simplest for now.
Attachment #8869092 - Flags: review?(jmuizelaar)
Assignee

Updated

2 years ago
Attachment #8867943 - Attachment is obsolete: true
Attachment #8869092 - Flags: review?(jmuizelaar) → review+

Comment 17

2 years ago
Pushed by bdahl@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/d7121e5ad806
Expand headless mode support for linux. r=automatedtester,jrmuizel,kanru

Comment 18

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/d7121e5ad806
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Assignee

Updated

2 years ago
Depends on: 1367227
Assignee

Updated

2 years ago
Component: General → Headless
You need to log in before you can comment on or make changes to this bug.