question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

firefox fails when running in docker container

See original GitHub issue

Discussed in https://github.com/microsoft/playwright/discussions/13716

<div type='discussions-op-text'>

Originally posted by Nedilko April 24, 2022 I faced with problem when I run screenshot tests with matching snapshot (.toMatchSnapshot). I’m running tests on Apple M1, and screenshots renders under darwin. Everything okay, second attempt pf running test passes all tests. BUT! The problem when after this I run tests in my ci. Tests not pass because they run under another file system, and screenshots has different name:

  • screenshot_name-browser-linux - on CI
  • screenshot_name-browser-darwin - on Apple M1 So, I tried to use this instructions:
docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.21.0-focal /bin/bash
npm install
npx playwright test --update-snapshots

But unfortunately firefox tests fails: (btw, all firefox tests, not only screenshot tests)

pw:browser <launching> /ms-playwright/firefox-1322/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-rUXIAt -juggler-pipe -silent +0ms
  pw:browser <launched> pid=371 +3ms
  pw:browser [pid=371][err] *** You are running in headless mode. +424ms
  pw:browser [pid=371][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.658892) [GFX1-]: glxtest: libpci missing +228ms
  pw:browser [pid=371][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.658892) |[1][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.658951) [GFX1-]: glxtest: Unable to open a connection to the X server +0ms
  pw:browser [pid=371][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.658892) |[1][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.658951) |[2][GFX1-]: glxtest: libEGL initialize failed (t=0.658962) [GFX1-]: glxtest: libEGL initialize failed +0ms
  pw:browser [pid=371][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.658892) |[1][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.658951) |[2][GFX1-]: glxtest: libEGL initialize failed (t=0.658962) |[3][GFX1-]: No GPUs detected via PCI (t=0.658971) [GFX1-]: No GPUs detected via PCI +0ms
  pw:browser [pid=371][out]  +194ms
  pw:browser [pid=371][out] Juggler listening to the pipe +0ms
  pw:browser [pid=371][out] console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /tmp/playwright_firefoxdev_profile-rUXIAt/search.json.mozlz4", (void 0))) +41ms
```</div>

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jvsantencommented, May 3, 2022

I’m running into (what I assume is) this same issue.

I’m using the docker image to run tests on Jenkins. Chrome and Webkit both work, but Firefox always goes to a 30 second timeout. The same issue occurs with or without xvfb-run.

Logs with xvfb-run:

xvfb-run --auto-servernum --server-args=-screen 0 1920x1080x24 npx playwright test --project=firefox

Running 1 test using 1 worker
  pw:browser <launching> /ms-playwright/firefox-1322/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-AuJuOz -juggler-pipe -silent +0ms 
  pw:browser <launched> pid=293 +7ms 
  pw:browser [pid=293][err] *** You are running in headless mode. +34ms 
  pw:browser [pid=293][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.0936868) [GFX1-]: glxtest: libpci missing +51ms 
  pw:browser [pid=293][err] Unable to revert mtime: /ms-playwright/firefox-1322/firefox/fonts +65ms 
  pw:browser [pid=293][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +64ms 
  pw:browser [pid=293][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +4ms 
  pw:browser [pid=293][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +0ms 
  pw:browser [pid=293][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +1ms 
  pw:browser [pid=293][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +6ms 
T pw:browser [pid=293] <kill> +30s 
  pw:browser [pid=293] <will force kill> +0ms 
  pw:browser [pid=293] starting temporary directories cleanup +0ms 
  pw:browser [pid=293] finished temporary directories cleanup +2ms 

 Slow test file: [firefox] › dos.spec.ts (30s)
 Consider splitting slow test files to speed up parallel execution

Logs without xvfb-run:

npx playwright test --project=firefox

Running 1 test using 1 worker
  pw:browser <launching> /ms-playwright/firefox-1322/firefox/firefox -no-remote -headless -profile /tmp/playwright_firefoxdev_profile-GyjCum -juggler-pipe -silent +0ms 
  pw:browser <launched> pid=279 +8ms 
  pw:browser [pid=279][err] *** You are running in headless mode. +24ms 
  pw:browser [pid=279][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.0687107) [GFX1-]: glxtest: libpci missing +35ms 
  pw:browser [pid=279][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.0687107) |[1][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.0687859) [GFX1-]: glxtest: Unable to open a connection to the X server +0ms 
  pw:browser [pid=279][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.0687107) |[1][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.0687859) |[2][GFX1-]: glxtest: libEGL initialize failed (t=0.068797) [GFX1-]: glxtest: libEGL initialize failed +0ms 
  pw:browser [pid=279][out] Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.0687107) |[1][GFX1-]: glxtest: Unable to open a connection to the X server (t=0.0687859) |[2][GFX1-]: glxtest: libEGL initialize failed (t=0.068797) |[3][GFX1-]: No GPUs detected via PCI (t=0.0688209) [GFX1-]: No GPUs detected via PCI +0ms 
  pw:browser [pid=279][err] Unable to revert mtime: /ms-playwright/firefox-1322/firefox/fonts +29ms 
  pw:browser [pid=279][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +60ms 
  pw:browser [pid=279][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +1ms 
  pw:browser [pid=279][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +2ms 
  pw:browser [pid=279][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +1ms 
  pw:browser [pid=279][err] JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +7ms 
T pw:browser [pid=279] <kill> +30s 
  pw:browser [pid=279] <will force kill> +0ms 
  pw:browser [pid=279] starting temporary directories cleanup +0ms 
  pw:browser [pid=279] finished temporary directories cleanup +2ms 

 Slow test file: [firefox] › dos.spec.ts (30s)
 Consider splitting slow test files to speed up parallel execution

(Had some weird formatting from the Jenkins logs so I’ve tried to clear that up as best I can)

Running with the same settings on my Linux workstation the image performs flawlessly, but it seems something in the docker image is still dependent on the host when it comes to running Firefox.

1reaction
Nedilkocommented, Apr 30, 2022

Thanks for the response! Actually I was watching video where you was showing new features of playwright v1.20 and noticed I have a reply on this issue form you 😃

tests just failed again… output below:

root@docker-desktop:/work# xvfb-run npx playwright test --update-snapshots

Running 10 tests using 2 workers

  ✓  [chromium] › homepage.test.js:8:3 › main text › heading has text (10s)
  ✘  [firefox] › homepage.test.js:8:3 › main text › heading has text (30s)
  ✓  [chromium] › homepage.test.js:15:3 › screenshot › homepage (868ms)
/work/e2e/homepage.test.js-snapshots/screenshot-homepage-1-chromium-linux.png is missing in snapshots, writing actual.
  ✓  [webkit] › homepage.test.js:8:3 › main text › heading has text (985ms)
  ✓  [webkit] › homepage.test.js:15:3 › screenshot › homepage (2s)
/work/e2e/homepage.test.js-snapshots/screenshot-homepage-1-webkit-linux.png is missing in snapshots, writing actual.
  ✓  [Mobile Chrome] › homepage.test.js:8:3 › main text › heading has text (488ms)
  ✓  [Mobile Chrome] › homepage.test.js:15:3 › screenshot › homepage (840ms)
/work/e2e/homepage.test.js-snapshots/screenshot-homepage-1-Mobile-Chrome-linux.png is missing in snapshots, writing actual.
  ✓  [Mobile Safari] › homepage.test.js:8:3 › main text › heading has text (829ms)
  ✓  [Mobile Safari] › homepage.test.js:15:3 › screenshot › homepage (934ms)
/work/e2e/homepage.test.js-snapshots/screenshot-homepage-1-Mobile-Safari-linux.png is missing in snapshots, writing actual.
  ✘  [firefox] › homepage.test.js:15:3 › screenshot › homepage (30s)


  1) [firefox] › homepage.test.js:8:3 › main text › heading has text ===============================

    Timeout of 30000ms exceeded in beforeEach hook.

      1 | const { test, expect } = require('@playwright/test')
      2 |
    > 3 | test.beforeEach(async ({ page }) => {
        |      ^
      4 |   await page.goto('/')
      5 | })
      6 |

        at /work/e2e/homepage.test.js:3:6

  2) [firefox] › homepage.test.js:15:3 › screenshot › homepage =====================================

    Timeout of 30000ms exceeded in beforeEach hook.

      1 | const { test, expect } = require('@playwright/test')
      2 |
    > 3 | test.beforeEach(async ({ page }) => {
        |      ^
      4 |   await page.goto('/')
      5 | })
      6 |

        at /work/e2e/homepage.test.js:3:6

  Slow test file: [firefox] › homepage.test.js (1m)
  Consider splitting slow test files to speed up parallel execution

  2 failed
    [firefox] › homepage.test.js:8:3 › main text › heading has text ================================
    [firefox] › homepage.test.js:15:3 › screenshot › homepage ======================================
  8 passed (1m)

Maybe it’s a good idea to create own container with all needs. e.g. based on ubuntu image with installed all libraries, and of course playwright browsers… maybe something wrong with image which is build on Apple M1… I don’t know… I thought it’s a good idea to use VSCode remote development in containers, so that I need to configure docker file and after install all need dependencies and that’s it… And then I can configure ci to run e2e tests on exactly same system using same container. But I think the idea of image mcr.microsoft.com/playwright:v1.21.0-focal was pretty much same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

headless Firefox in Docker Container without root fails to start
3276.0 Safari/537.36 Steps to reproduce: I have a Firefox installed in a CentOS Docker Image. ``` FROM centos:7 USER root #needed for headless...
Read more >
selenium - Cannot open firefox in Docker container
I am trying to run a selenium test inside a Docker container. I created the image on top of a base image of...
Read more >
Firefox in Docker, failed in isolation
While experimenting with docker, I realized I can run a browser in a container for improved security. I managed to start with a...
Read more >
How to run firefox inside docker container
Generally, if you run firefox inside docker container you will get the below error. [root@1c3a22e43538 /]# firefox Failed to open connection ...
Read more >
Use the TestCafe Docker Image | Advanced Guides
TestCafe provides a preconfigured Docker image with Chromium and Firefox installed. ... Use the docker run command to run TestCafe in the Docker...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found