Closed Bug 1356681 Opened 3 years ago Closed 3 years ago

Support headless flag on Linux

Categories

(Firefox :: Headless, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Firefox 55
Tracking Status
firefox55 --- fixed

People

(Reporter: bdahl, Assigned: bdahl)

References

Details

(Keywords: dev-doc-needed)

Attachments

(7 files, 1 obsolete file)

Add a --headless flag on Linux that starts the browser in headless mode.
Depends on: 1353938
Keywords: dev-doc-needed
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
(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: nobody → bdahl
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)
These are various fixes to get most of the headless
marionette tests working.
Attachment #8864327 - Flags: review?(jmuizelaar)
Supports changing the size of a headless screen with
environment variables.
Attachment #8864328 - Flags: review?(kchen)
Attachment #8864329 - Flags: review?(jmuizelaar)
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+
Some new marionette tests for windows size changes were added while I was on PTO.
Attachment #8867832 - Flags: review?(jmuizelaar)
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-
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)
Attachment #8867943 - Attachment is obsolete: true
Attachment #8869092 - Flags: review?(jmuizelaar) → review+
Pushed by bdahl@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/d7121e5ad806
Expand headless mode support for linux. r=automatedtester,jrmuizel,kanru
https://hg.mozilla.org/mozilla-central/rev/d7121e5ad806
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Depends on: 1367227
Component: General → Headless
You need to log in before you can comment on or make changes to this bug.