Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox 68.x won't run (from inside docker) #104

Closed
davidkarlsen opened this issue Aug 9, 2019 · 49 comments
Closed

Firefox 68.x won't run (from inside docker) #104

davidkarlsen opened this issue Aug 9, 2019 · 49 comments

Comments

@davidkarlsen
Copy link

I've used FirefoxHeadless inside docker just fine for a long time - but with v68 of ffox it just won't work.

19:02:46 �[32m09 08 2019 17:02:44.991:INFO [launcher]: �[39mStarting browser FirefoxHeadless
19:03:54 �[33m09 08 2019 17:03:45.123:WARN [launcher]: �[39mFirefoxHeadless have not captured in 60000 ms, killing.
19:03:54 �[32m09 08 2019 17:03:45.598:INFO [launcher]: �[39mTrying to start FirefoxHeadless again (1/2).
19:04:54 �[33m09 08 2019 17:04:45.602:WARN [launcher]: �[39mFirefoxHeadless have not captured in 60000 ms, killing.
19:04:54 �[32m09 08 2019 17:04:45.724:INFO [launcher]: �[39mTrying to start FirefoxHeadless again (2/2).
19:05:50 �[33m09 08 2019 17:05:45.855:WARN [launcher]: �[39mFirefoxHeadless have not captured in 60000 ms, killing.
19:05:50 �[91m09 08 2019 17:05:47.109:ERROR [launcher]: �[39mFirefoxHeadless failed 2 times (timeout). Giving up.

Karma config:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

//https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
const isDocker = require('is-docker')();


module.exports = function (config) {
  config.set({
    concurrency: 1, // avoid clash when ffox and chrome run at the same time
    customLaunchers: {
      ChromeCustom: {
        base: 'ChromeHeadless',
        // We must disable the Chrome sandbox when running Chrome inside Docker (Chrome's sandbox needs
        // more permissions than Docker allows by default)
        flags: isDocker ? ['--no-sandbox'] : []
      }
    },
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-coverage'),
      require('karma-coverage-istanbul-reporter'),
      require('karma-chrome-launcher'),
      require('karma-firefox-launcher'),
      require('karma-junit-reporter'),
      //require('karma-remap-istanbul'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    files: [
    ],
    preprocessors: {
      './src/app/**/*.ts': ['coverage']
    },
    coverageReporter: {
      type:'lcov',
      dir:'target/coverage'
    },
    mime: {
      'text/x-typescript': ['ts','tsx']
    },
    angularCli: {
      config: './angular-cli.json',
      environment: 'dev'
    },
    reporters: config.angularCli && config.angularCli.codeCoverage
              ? ['progress', 'junit','coverage-istanbul','coverage']
              : ['progress', 'junit'],
    junitReporter: {
      outputDir: 'target/junit-reports'
      //outputDir: 'target/junit-dir: require('path').join(__dirname, 'coverage'), reports'
    },
    port: 9876,
    colors: true,
    autoWatch: true,
    browsers: ['FirefoxHeadless','ChromeCustom'],
    singleRun: false
  });
};

Image I am using:
https://hub.docker.com/r/evryfs/node-dev-docker/ (node12 tag)

@birtles
Copy link
Collaborator

birtles commented Aug 10, 2019

I'll have to try that image later to see what's going on.

There's no problem with docker, per se, however. See #93 (comment) for an example of some steps to run karma-firefox-launcher in docker that worked for me recently with Firefox 68.

@davidkarlsen
Copy link
Author

In issue #93 it runs with xvfb instead of headless. Here is some more logging:

20:49:46 �[36m09 08 2019 18:49:45.541:DEBUG [web-server]: �[39mserving: /app/node_modules/karma/static/karma.js
20:49:46 �[36m09 08 2019 18:49:46.165:DEBUG [web-server]: �[39mserving: /app/node_modules/karma/static/favicon.ico
20:50:25 �[33m09 08 2019 18:50:19.098:WARN [launcher]: �[39mFirefoxHeadless have not captured in 60000 ms, killing.
20:50:25 �[36m09 08 2019 18:50:19.104:DEBUG [launcher]: �[39mBEING_CAPTURED -> BEING_KILLED
20:50:25 �[36m09 08 2019 18:50:19.427:DEBUG [launcher]: �[39mProcess FirefoxHeadless exited with code null and signal SIGTERM
20:50:25 �[36m09 08 2019 18:50:19.427:DEBUG [temp-dir]: �[39mCleaning temp dir /tmp/karma-92895928
20:50:25 �[32m09 08 2019 18:50:19.450:INFO [launcher]: �[39mTrying to start FirefoxHeadless again (1/2).
20:50:25 �[36m09 08 2019 18:50:19.450:DEBUG [launcher]: �[39mBEING_KILLED -> RESTARTING
20:50:25 �[36m09 08 2019 18:50:19.450:DEBUG [launcher]: �[39mRESTARTING -> FINISHED
20:50:25 �[36m09 08 2019 18:50:19.450:DEBUG [launcher]: �[39mFINISHED -> FINISHED
20:50:25 �[36m09 08 2019 18:50:19.451:DEBUG [launcher]: �[39mRestarting FirefoxHeadless
20:50:25 �[36m09 08 2019 18:50:19.451:DEBUG [launcher]: �[39mFINISHED -> BEING_CAPTURED
20:50:25 �[36m09 08 2019 18:50:19.451:DEBUG [temp-dir]: �[39mCreating temp dir at /tmp/karma-92895928
20:50:25 �[36m09 08 2019 18:50:19.452:DEBUG [launcher]: �[39mfirefox http://localhost:9876/?id=92895928 -profile /tmp/karma-92895928 -no-remote -wait-for-browser -headless --start-debugger-server 6000
20:50:40 �[36m09 08 2019 18:50:38.522:DEBUG [web-server]: �[39mserving (cached): /app/node_modules/karma/static/client.html
20:51:27 �[33m09 08 2019 18:51:20.007:WARN [launcher]: �[39mFirefoxHeadless have not captured in 60000 ms, killing.
20:51:27 �[36m09 08 2019 18:51:20.071:DEBUG [launcher]: �[39mBEING_CAPTURED -> BEING_KILLED
20:51:27 �[36m09 08 2019 18:51:20.430:DEBUG [launcher]: �[39mProcess FirefoxHeadless exited with code null and signal SIGTERM
20:51:27 �[36m09 08 2019 18:51:20.437:DEBUG [temp-dir]: �[39mCleaning temp dir /tmp/karma-92895928
20:51:27 �[32m09 08 2019 18:51:20.447:INFO [launcher]: �[39mTrying to start FirefoxHeadless again (2/2).
20:51:27 �[36m09 08 2019 18:51:20.447:DEBUG [launcher]: �[39mBEING_KILLED -> RESTARTING
20:51:27 �[36m09 08 2019 18:51:20.447:DEBUG [launcher]: �[39mRESTARTING -> FINISHED
20:51:27 �[36m09 08 2019 18:51:20.448:DEBUG [launcher]: �[39mFINISHED -> FINISHED
20:51:27 �[36m09 08 2019 18:51:20.448:DEBUG [launcher]: �[39mRestarting FirefoxHeadless
20:51:27 �[36m09 08 2019 18:51:20.448:DEBUG [launcher]: �[39mFINISHED -> BEING_CAPTURED
20:51:27 �[36m09 08 2019 18:51:20.448:DEBUG [temp-dir]: �[39mCreating temp dir at /tmp/karma-92895928
20:51:27 �[36m09 08 2019 18:51:20.448:DEBUG [launcher]: �[39mfirefox http://localhost:9876/?id=92895928 -profile /tmp/karma-92895928 -no-remote -wait-for-browser -headless --start-debugger-server 6000
20:51:27 �[36m09 08 2019 18:51:25.934:DEBUG [web-server]: �[39mserving (cached): /app/node_modules/karma/static/client.html
20:51:49 �[36m09 08 2019 18:51:45.751:DEBUG [web-server]: �[39mserving (cached): /app/node_modules/karma/static/karma.js
20:51:49 �[36m09 08 2019 18:51:46.379:DEBUG [web-server]: �[39mserving (cached): /app/node_modules/karma/static/favicon.ico
20:52:21 �[33m09 08 2019 18:52:20.447:WARN [launcher]: �[39mFirefoxHeadless have not captured in 60000 ms, killing.
20:52:21 �[36m09 08 2019 18:52:20.448:DEBUG [launcher]: �[39mBEING_CAPTURED -> BEING_KILLED
20:52:21 �[36m09 08 2019 18:52:20.593:DEBUG [launcher]: �[39mProcess FirefoxHeadless exited with code null and signal SIGTERM
20:52:21 �[36m09 08 2019 18:52:20.594:DEBUG [temp-dir]: �[39mCleaning temp dir /tmp/karma-92895928
20:52:21 �[91m09 08 2019 18:52:20.605:ERROR [launcher]: �[39mFirefoxHeadless failed 2 times (timeout). Giving up.
20:52:21 �[36m09 08 2019 18:52:20.615:DEBUG [launcher]: �[39mBEING_KILLED -> FINISHED
20:52:21 �[36m09 08 2019 18:52:20.615:DEBUG [launcher]: �[39mFINISHED -> FINISHED
Cancelling nested steps due to timeout

what is odd is that the same test runs fine on my mac (e.g. not in docker)

@davidkarlsen
Copy link
Author

davidkarlsen commented Aug 10, 2019

@birtles
Same image just ffox 67 works: https://github.com/evryfs/node-dev-docker/compare/test - exact same code & setup running - this must be directly tied to ffox version and the fact it's running in docker.

@birtles
Copy link
Collaborator

birtles commented Aug 12, 2019

There were a few changes to startup discussed on dev-platform in March but most of those seemed to land in Firefox 67 (e.g. bug 1535144 and bug 1535021).

The next step is probably to look through bugs in the Startup and Profile System component that landed in the 68 timeframe. Maybe @Mossop might have some pointers about where to start.

@davidkarlsen
Copy link
Author

@birtles but why does it work fine outside of docker on my Mac?

@Mossop
Copy link

Mossop commented Aug 12, 2019

If it is working with xvfb but not headless then this is likely a headless widget issue, probably accidentally depending on a windowing system existing somwhere. @brendandahl might have ideas.

@birtles but why does it work fine outside of docker on my Mac?

Inside docker you have no windowing system and are presumably running the linux version of Firefox. Outside you have a windowing system and are running the osx version. Those are two very different situations.

@brendandahl
Copy link

I'm not familiar with karma-runner, but is there a way to capture the startup output of Firefox in the docker image? That would probably tells us where it's crashing.

Alternatively, you could just try to start firefox inside your docker image in headless mode
firefox --headless --profile <some empty folder>.

@davidkarlsen
Copy link
Author

@brendandahl see comment above for debug log output

@brendandahl
Copy link

It doesn't look like that is capturing all of stdout/stderr from Firefox. There should hopefully be a message You are running in headless mode. I suppose it's possible it's crashing even before that though.

@birtles
Copy link
Collaborator

birtles commented Aug 13, 2019

@davidkarlsen I tried debugging your image today but it seems to work for me (had to disable the proxy however).

Steps I ran:

> docker pull evryfs/node-dev-docker:node12
> docker run -i -t evryfs/node-dev-docker:node12 /bin/bash
docker> firefox --headless --profile /tmp
*** You are running in headless mode.
(No errors show. Let's try with arguments more similar to what karma-firefox-launcher uses.)
^C
docker> firefox -headless -profile /tmp -no-remote -wait-for-browser --start-debugger-server 6000
*** You are running in headless mode.
(No errors show)
^C
docker> git clone https://github.com/karma-runner/karma-firefox-launcher.git
Cloning into 'karma-firefox-launcher'...
fatal: unable to access 'https://github.com/karma-runner/karma-firefox-launcher.git/': Failed to connect to proxy.evry.com port 8080: Connection refused
docker> unset HTTP_PROXY
docker> unset HTTPS_PROXY
docker> unset http_proxy
docker> unset https_proxy
docker> git clone https://github.com/karma-runner/karma-firefox-launcher.git
docker> cd karma-firefox-launcher
docker> yarn install
docker> apt-get install nano
docker> nano karma.conf.js
(Remove 'Firefox' entry, leaving only 'FirefoxHeadless')
docker> yarn test
yarn run v1.17.3
$ karma start --single-run
13 08 2019 03:18:45.457:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9876/
13 08 2019 03:18:45.460:INFO [launcher]: Launching browsers FirefoxHeadless with concurrency unlimited
13 08 2019 03:18:45.464:INFO [launcher]: Starting browser FirefoxHeadless
13 08 2019 03:18:47.679:INFO [Firefox 68.0.0 (Linux 0.0.0)]: Connected on socket lH-3IYR2_YaEygz1AAAA with id 93797292
.
Firefox 68.0.0 (Linux 0.0.0): Executed 1 of 1 SUCCESS (0.003 secs / 0.001 secs)
Done in 3.39s.

@davidkarlsen
Copy link
Author

How strange - I'll do some other testing myself.
Linking a similar issue: DevExpress/testcafe#4031

@davidkarlsen
Copy link
Author

davidkarlsen commented Aug 14, 2019

OK, on my desktop (MacOS) in runs fine, on CI server it stalls at:

yarn test
yarn run v1.17.3
$ karma start --single-run
14 08 2019 21:45:39.178:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9876/
14 08 2019 21:45:39.180:INFO [launcher]: Launching browsers FirefoxHeadless with concurrency unlimited
14 08 2019 21:45:39.186:INFO [launcher]: Starting browser FirefoxHeadless

it runs docker:

docker version
Client:
 Version:         1.13.1
 API version:     1.26
 Package version: docker-1.13.1-94.gitb2f74b2.el7.x86_64
 Go version:      go1.10.8
 Git commit:      b2f74b2/1.13.1
 Built:           Mon Feb 25 14:45:39 2019
 OS/Arch:         linux/amd64

Server:
 Version:         1.13.1
 API version:     1.26 (minimum version 1.12)
 Package version: docker-1.13.1-94.gitb2f74b2.el7.x86_64
 Go version:      go1.10.8
 Git commit:      b2f74b2/1.13.1
 Built:           Mon Feb 25 14:45:39 2019
 OS/Arch:         linux/amd64
 Experimental:    false

@davidkarlsen
Copy link
Author

A bit impatient, it got further but eventually failed:

yarn test
yarn run v1.17.3
$ karma start --single-run
14 08 2019 21:45:39.178:INFO [karma-server]: Karma v4.2.0 server started at http://0.0.0.0:9876/
14 08 2019 21:45:39.180:INFO [launcher]: Launching browsers FirefoxHeadless with concurrency unlimited
14 08 2019 21:45:39.186:INFO [launcher]: Starting browser FirefoxHeadless
14 08 2019 21:46:39.326:WARN [launcher]: FirefoxHeadless have not captured in 60000 ms, killing.
14 08 2019 21:46:40.099:INFO [launcher]: Trying to start FirefoxHeadless again (1/2).
14 08 2019 21:47:23.907:INFO [Firefox 68.0.0 (Linux 0.0.0)]: Connected on socket n4o2_4kwR-_xm8J-AAAA with id 4482926
14 08 2019 21:47:56.170:WARN [Firefox 68.0.0 (Linux 0.0.0)]: Disconnected (0 times)reconnect failed before timeout of 2000ms (ping timeout)
Firefox 68.0.0 (Linux 0.0.0) ERROR
  Disconnectedreconnect failed before timeout of 2000ms (ping timeout)
Firefox 68.0.0 (Linux 0.0.0): Executed 0 of 0 DISCONNECTED (32.25 secs / 0 secs)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@birtles
Copy link
Collaborator

birtles commented Aug 15, 2019

So, just to check, on your desktop you're also running it inside docker, right? I thought docker was supposed to help creating a reproducible environment ;)

That's certainly an older version of docker but I wonder if CI is setting environment variables or otherwise interacting with the container in a way that might affect the runtime environment.

I've seen karma-firefox-launcher just not respond and timeout when it can't find the firefox binary so if CI is clobbering your PATH or something in a manner that affects 68 but not 67, I guess that's possible.

@stevenhair
Copy link

stevenhair commented Aug 15, 2019

I had the same problem with Firefox 68.0.1, but 68.0.2 seems to work.

Edit: I should mention that I already had the shm set to 2gb. 68.0.1 failed to launch, 68.0.2 seems to be ok.

@davidkarlsen
Copy link
Author

@birtles yes, docker on desktop too, CI does not alter env.

@birtles
Copy link
Collaborator

birtles commented Aug 15, 2019

If the same image running the same steps is producing different results, then there must be something different about the environment, even if it's the docker version, network speed, etc. but without access to your CI setup I'm not sure there's much I can do to help other than dig through changes made in 68.

If 68.0.2 is indeed working then that might provide a clue. Digging through the changes since 68.0.1, the most obvious candidate is Bug 1567614 but that should only affect Windows as far as I can tell.

@davidkarlsen
Copy link
Author

68.0.2 fails as well, 67.0.4 works fine - it is definitely tied to ffox version.

@davidkarlsen
Copy link
Author

Note for anyone testing the images: the master / node12 tag is now on a downgraded ffox version, while the tag ffoxbroken tag points at latest ffox (which is malfunctioning).

@birtles
Copy link
Collaborator

birtles commented Aug 16, 2019

@glandium Are you aware of any changes to launching Firefox on Debian introduced in 68?

This is about karma-firefox-launcher which apparently has stopped working for various folks using it in Docker in CI as of Firefox 68. In this particular instance, the docker image appears to be Debian-based (based on node:12.8-stretch).

@glandium
Copy link

Not aware of anything.

@davidkarlsen
Copy link
Author

The thing I notice is that it just seems incredibly slow - it hogs CPU and runs on close to 100% CPU but still takes an age to get running - and fails due to this it seems. Was anything changed in use of libraries, or other capabilities docker might slow down?

@davidkarlsen
Copy link
Author

I am also seeing this:

16 08 2019 08:01:24.483:INFO [launcher]: Starting browser FirefoxHeadless

16 08 2019 08:04:51.187:ERROR [launcher]: Cannot start FirefoxHeadless

	*** You are running in headless mode.

[Parent 134, Gecko_IOThread] WARNING: pipe error: Broken pipe: file /builds/worker/workspace/build/src/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 727



16 08 2019 08:04:51.342:ERROR [launcher]: FirefoxHeadless stdout: 

16 08 2019 08:04:51.344:ERROR [launcher]: FirefoxHeadless stderr: *** You are running in headless mode.

[Parent 134, Gecko_IOThread] WARNING: pipe error: Broken pipe: file /builds/worker/workspace/build/src/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 727



16 08 2019 08:04:51.905:INFO [launcher]: Trying to start FirefoxHeadless again (1/2).

16 08 2019 08:05:24.194:INFO [Firefox 68.0.0 (Linux 0.0.0)]: Connected on socket c8jqifCmOpVt7xaUAAAB with id 54449045

16 08 2019 08:05:55.838:WARN [Firefox 68.0.0 (Linux 0.0.0)]: Disconnected (0 times)reconnect failed before timeout of 2000ms (ping timeout)

Firefox 68.0.0 (Linux 0.0.0) ERROR

  Disconnectedreconnect failed before timeout of 2000ms (ping timeout)





16 08 2019 08:05:56.128:INFO [launcher]: Starting browser ChromeHeadless

16 08 2019 08:05:57.057:INFO [HeadlessChrome 76.0.3809 (Linux 0.0.0)]: Connected on socket NCI_VirZUOQzr0S3AAAC with id 92170417

@birtles
Copy link
Collaborator

birtles commented Aug 19, 2019

I am also seeing this:

16 08 2019 08:01:24.483:INFO [launcher]: Starting browser FirefoxHeadless

16 08 2019 08:04:51.187:ERROR [launcher]: Cannot start FirefoxHeadless

	*** You are running in headless mode.

[Parent 134, Gecko_IOThread] WARNING: pipe error: Broken pipe: file /builds/worker/workspace/build/src/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 727

Oh, that's super helpful. So know we now that at least it is finding the binary.

Digging into related issues, this seems really promising:

Specifically, it points to problems with shared memory affecting firefox running in docker containers and includes:

Why did this happen in the move from FF 67 to FF 68? Because I did disable SHM usage in FF by disabling E10s using user_pref("browser.tabs.remote.autostart", false);, but as this bug (https://bugzilla.mozilla.org/show_bug.cgi?id=1548941) says, support for this flag was removed in FF 68.

karma-firefox-launcher likewise includes user_pref("browser.tabs.remote.autostart", false) (and user_pref("browser.tabs.remote.autostart.2", false)).

The solution seems to be running docker with --shm-size 2g or mounting -v /dev/shm:/dev/shm.

See:

Ultimately, though it seems like this is tracked by:

@davidkarlsen
Copy link
Author

I have also seen those issues and tried running with shm_size 2g but the problem persist

@birtles
Copy link
Collaborator

birtles commented Aug 19, 2019

Ok, I suggest trying some of those other solutions. I don't think there's anything more we can do here for now.

@brendandahl
Copy link

Would someone be able to try a debug build of Firefox?

@davidkarlsen
Copy link
Author

@brendandahl

20:55:12 �[32m19 08 2019 18:55:11.424:INFO [karma-server]: �[39mKarma v4.2.0 server started at http://0.0.0.0:9876/
20:55:12 �[32m19 08 2019 18:55:11.428:INFO [launcher]: �[39mLaunching browsers FirefoxHeadless, ChromeCustom with concurrency 1
20:55:12 �[32m19 08 2019 18:55:11.431:INFO [launcher]: �[39mStarting browser FirefoxHeadless
20:55:39 �[32m19 08 2019 18:55:36.666:INFO [Firefox 68.0.0 (Linux 0.0.0)]: �[39mConnected on socket OOa9F7ZjnZljlxFWAAAA with id 35543876
20:56:11 �[33m19 08 2019 18:56:06.686:WARN [Firefox 68.0.0 (Linux 0.0.0)]: �[39mDisconnected (0 times), because no message in 30000 ms.
20:56:11 Firefox 68.0.0 (Linux 0.0.0) ERROR
20:56:11   Disconnected, because no message in 30000 ms.
20:56:11 
20:56:11 

@davidkarlsen
Copy link
Author

hang on!
That actually got further. I had some bad config. It might actually fail on a bad test.

@davidkarlsen
Copy link
Author

@brendandahl
Copy link

That's unfortunate, I was hoping we could get a backtrack from where it's crashing.

@davidkarlsen
Copy link
Author

Hm - seems it is still flaky - got a few green passes yesterday - but today it broke again:

09:02:13 �[32m20 08 2019 07:02:12.658:INFO [karma-server]: �[39mKarma v4.2.0 server started at http://0.0.0.0:9876/
09:02:13 �[32m20 08 2019 07:02:12.660:INFO [launcher]: �[39mLaunching browsers FirefoxHeadless, ChromeCustom with concurrency 1
09:02:13 �[32m20 08 2019 07:02:12.663:INFO [launcher]: �[39mStarting browser FirefoxHeadless
09:03:21 �[33m20 08 2019 07:03:12.671:WARN [launcher]: �[39mFirefoxHeadless have not captured in 60000 ms, killing.
09:03:21 �[32m20 08 2019 07:03:12.747:INFO [launcher]: �[39mTrying to start FirefoxHeadless again (1/2).
09:04:18 �[32m20 08 2019 07:04:09.615:INFO [Firefox 68.0.0 (Linux 0.0.0)]: �[39mConnected on socket yKM9nZMIyi3iOk7LAAAA with id 29498625
09:04:40 �[33m20 08 2019 07:04:39.656:WARN [Firefox 68.0.0 (Linux 0.0.0)]: �[39mDisconnected (0 times), because no message in 30000 ms.
09:04:40 Firefox 68.0.0 (Linux 0.0.0) ERROR
09:04:40   Disconnected, because no message in 30000 ms.
09:04:40 

should there be more debug?

@brendandahl
Copy link

I'd expect more output from a debug build, they're pretty noisy. Are you logging stdout and stderr?

@davidkarlsen
Copy link
Author

I run it as docker-compose run --rm node yarn test
where the compose file is:

version: '3'
services:
  node:
    image: fsnexus.evry.com:8085/evryfs/node-dev-docker:node12
    command: "yarn install"
    working_dir: /app
    environment:
     - CI=true
     - GOSU_USER=${UID}:${GID}
     - GOSU_CHOWN=/home/node
     - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
    volumes:
     - ./:/app

@Neonox31
Copy link

Hello,

Same problem for us, all was fine during a lot of monthes and since previous friday (13/09) karma fails with the FirefoxHeadless have not captured in 60000 ms message.
On my local machine using docker all is fine but not on our Gitlab runner. I could observe the problem using 69 and 68 versions of firefox but 67 seems to work well.

@birtles
Copy link
Collaborator

birtles commented Sep 19, 2019

This is basically blocked by Firefox bug 1464690. I expect something else in your config caused you to start hitting out-of-memory conditions triggering this bug.

@gcp
Copy link

gcp commented Nov 14, 2019

This is basically blocked by Firefox bug 1464690.

I don't understand.

The solution seems to be running docker with --shm-size 2g

This is the correct solution (why is it not the default in the first place?). Anything else will be a gross hack and workaround in the browser basically duplicating a pile of glibc code to put shared memory exactly in the wrong place.

Is there a reason why fixing this bug in docker is not possible? I'm considering whether it's possible to make Firefox spew out warnings when it detects this docker misconfiguration. But if the above docker switch doesn't help, that's no use.

@birtles
Copy link
Collaborator

birtles commented Nov 15, 2019

This is basically blocked by Firefox bug 1464690.

I don't understand.

That's just saying we're waiting to see what the outcome is of the analysis in that bug (and bug 1245239) to know if there's anything that can be done on the karma-firefox-launcher side. Comment 22 in particular suggested the handling there may change.

I think the warning for a docker misconfiguration would be helpful. We have one report that --shm-size 2g works and one that it doesn't. In the case where it did help, the report also mentioned that when using docker-compose they failed to set shm-size so it may be that failing report also suffered the same issue.

@gcp
Copy link

gcp commented Nov 15, 2019

Comment 22 in particular suggested the handling there may change.

Yes, anything can change but that won't help Firefox 68.x -> 72.x who allocate shared memory in the way a Linux application should, i.e. by using shmem_open() which will create a mapping in /dev/shm.

jld told me he's restarting memfd_create() work, so I'll hold off to see if we can get that working (Chromium seems to have given up on it, hmmm...).

But again, as long as docker/kubernetes misconfigure /dev/shm, it's going to be misery for applications that use shared memory. The fix here is to fix the misconfiguration, not hope that a potential Firefox change ends up working around the brokenness.

@lazka
Copy link

lazka commented Apr 6, 2020

Facing the same problem with gitlab-ci using firefox-esr 68 from debian buster.

Setting MOZ_FORCE_DISABLE_E10S=true made things work again.

@AlexVild
Copy link

AlexVild commented Apr 20, 2020

Facing the same problem with Firefox 68+ and karma-firefox-launcher 1.3

@amudh
Copy link

amudh commented Jul 7, 2020

I am running pretty much the same setup and receiving the same error, with firefox 77. Although, it works if the docker container is run as a root user. I am aware of the fact that running containers as root is a bad idea. I have tried setting --cap-add=NET_ADMIN, but that did not work. I am happy to share more info on docker files and/or Jenkins file.

Environment
Jenkins as CI server
Docker container with node and firefox. Build and Test steps are run inside the container
This is an angularJS app with karma and karma firefox launcher

When I run as a root user, I see these lines the debug log

DEBUG [launcher]: �[39mfirefox http://0.0.0.0:9876/?id=44967420 -profile /tmp/karma-44967420 -no-remote -wait-for-browser -headles
DEBUG [karma-server]: �[39mA browser has connected on socket lH2YmR69_PtlcAt2AAAA
...
INFO [Firefox 77.0 (Linux x86_64)]: �[39mConnected on socket lH2YmR69_PtlcAt2AAAA with id 44967420

When the container is not run as a root user, this is what I see

�[36m06 07 2020 23:49:04.771:DEBUG [launcher]: �[39mfirefox http://localhost:9876/?id=18019231 -profile /tmp/karma-18019231 -no-remote -headless
WARN [launcher]: �[39mFirefox have not captured in 60000 ms, killing.
DEBUG [launcher]: �[39mBEING_CAPTURED -> BEING_KILLED
DEBUG [launcher]: �[39mProcess Firefox exited with code null and signal SIGTERM

aduprat added a commit to aduprat/esn-frontend-inbox that referenced this issue Aug 27, 2020
aduprat added a commit to aduprat/esn-frontend-inbox that referenced this issue Aug 27, 2020
aduprat added a commit to aduprat/esn-frontend-inbox that referenced this issue Aug 27, 2020
@gcp
Copy link

gcp commented Aug 28, 2020

We keep getting questions about this, so I want to make this very clear: the problem is that docker by default misconfigures shared memory.

You have to fix this in the docker config by specifying --shm-size 2g. (And be careful when using docker-compose: #104 (comment))

See also: #104 (comment)

MOZ_FORCE_DISABLE_E10S=true only hides the problem, it will disable multiprocessing, ruining your performance and won't even work in recent Firefox versions, so it will just break on you. Do not do this. Fix the Docker config.

@gcp
Copy link

gcp commented Aug 28, 2020

I am running pretty much the same setup and receiving the same error, with firefox 77. Although, it works if the docker container is run as a root user. I am aware of the fact that running containers as root is a bad idea. I have tried setting --cap-add=NET_ADMIN, but that did not work. I am happy to share more info on docker files and/or Jenkins file.

Can you try the fix that has been indicated? If you're sure your Docker instance has sufficient shared memory, it might be worth filing a separate issue to look into the non-root problem. This one is far too generic ("won't run") and the majority of the discussion revolves around the SHM size bug.

@Wissiak
Copy link

Wissiak commented Oct 8, 2020

I've mounted the /dev/shm to the host directory via docker-compose but I'm still getting this issue. See the /dev/shm inside of the docker container should have enough space:

Filesystem     1K-blocks  Used Available Use% Mounted on
tmpfs            3955856   100   3955756   1% /dev/shm

Here is the output I get (Click to expand)
[... Test] Test Suite
=========================================== ? Connected to localhost on port 4444 (6039ms). Using: firefox (68.9.0) on linux 3.10.0-1127.13.1.el7.x86_64 platform.

Running: Test ...
POST /session/f2a528ea-9a6c-463d-8178-72c74380309c/url - ECONNRESET
Error: socket hang up
Error while running .navigateTo() protocol action: Error ECONNRESET: socket hang up

POST /session/f2a528ea-9a6c-463d-8178-72c74380309c/elements - ECONNRESET
Error: socket hang up
Error while running .locateMultipleElements() protocol action: Error ECONNRESET: socket hang up

? Timed out while waiting for element <...> to be present for 20000 milliseconds. - expected "visible" but got: "not found" (100147ms)
at Object.Test ... (/var/jenkins_home/workspace/...)

FAILED: 1 assertions failed and 1 errors (3m 20s / 200204ms)
Error while running .sessionAction() protocol action: Tried to run command without establishing a connection


If I run the command with export MOZ_FORCE_DISABLE_E10S=true the tests are executed but the extended size of /dev/shm doesn't seem to help.

Any suggestions?

@gcp
Copy link

gcp commented Oct 27, 2020

Any suggestions?

There's nothing more in your log than just the message that the connection is reset. Hard to debug what's up just from that.

Something that catches my attention is that you're running a 3.10 kernel, which dates back to 2013. I don't know the reasons for that, but more recent kernels will definitely improve performance.

@gcp
Copy link

gcp commented Oct 27, 2020

Firefox 84 (current Nightly) and later will bypass /dev/shmem for shared memory allocation on a new enough kernel [1] and thus end up working around the reports in this bug that were caused by improperly sized shared memory under docker/kubernetes/etc. It is a large enough change that it doesn't look like it can make it into an ESR 78 update though.

[1] memfd support was added in kernel 3.17, released in October 2014.

@gcp
Copy link

gcp commented Dec 18, 2020

Firefox 84 with the workarounds is now shipping in release.

@birtles
Copy link
Collaborator

birtles commented Oct 18, 2022

I haven't heard of any new reports of this and various fixes have landed in Firefox as mentioned by @gcp (notably bug 1440203 in Firefox 84 and also bug 1582954 in Firefox 80). Those fixes should now be in Firefox ESR 91 and 102 too so I'm closing this for now.

@birtles birtles closed this as completed Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests