Disabling GPU Acceleration in Cypress
Asked Answered
B

1

17

I'm running Cypress in a Docker container in Jenkins.

This is my Dockerfile:

#Base image taken from:https://github.com/cypress-io/cypress-docker-images
FROM cypress/browsers:node14.17.0-chrome91-ff89
#Create the folder where our project will be stored
RUN mkdir /my-cypress-project
#We make it our workdirectory
WORKDIR /my-cypress-project
#Let's copy the essential files that we MUST use to run our scripts.
COPY ./package.json .
COPY ./cypress/tsconfig.json .
COPY ./cypress.config.ts .
COPY ./cypress ./cypress
RUN pwd
RUN ls
#Install the cypress dependencies in the work directory
RUN npm install
RUN npm audit fix
RUN npx cypress verify
RUN apt-get install -y xvfb
RUN google-chrome --disable-gpu --no-sandbox --headless
#Executable commands the container will use[Exec Form]
ENTRYPOINT ["npx","cypress","run"]
#With CMD in this case, we can specify more parameters to the last entrypoint.
CMD [""]    

I'm building it like this:

docker build -t my-cypress-image:1.1.0 .

and running like this:

docker run -v '$PWD':/my-cypress-project -t my-cypress-image:1.1.0 --spec cypress/e2e/pom/homeSauce.spec.js --headless --browser chrome --config-file=/my-cypress-project/cypress.config.ts

and I get this error in the console:

libva error: va_getDriverName() failed with unknown libva error,driver_name=(null)
[218:0822/100658.356057:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
Could not find a Cypress configuration file.

We looked but did not find a cypress.config.ts file in this folder: /my-cypress-project

Now as far as I know, this is due to the browser running with GPU acceleration... how do I disable that?

I tried pasting this in my index.js file:

// cypress/plugins/index.js
module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, launchOptions) => {
    console.log(launchOptions.args)

    if (browser.name == 'chrome') {
      launchOptions.args.push('--disable-gpu')
    }

    return launchOptions
  })
}

but I still get the exact same error...

Any help would be appreciated! Cheers

Bogard answered 22/8, 2022 at 10:26 Comment(9)
Maybe I'm wrong but it says: We looked but did not find a cypress.config.ts file in this folder: /my-cypress-project, do you have this config?Cockshy
@Cockshy , yes, the config file is correctly placed. I tried other Cypress commands to see if they work (like verifying) and they all work, its definitely the actual testing that causes the issue. Every thread I read about this exact error point towards disabling the GPU acceleration, but none state how to accomplish that...Bogard
Checked this out? github.com/cypress-io/github-action/issues/564Cockshy
@Cockshy yup, saw that too. Tried everything in it: Changing cypress version, specifying the config file, tried different docker base images... nothing.Bogard
Where exactly it fails? on RUN npx cypress verify?Cockshy
@Cockshy no, the image builds successfully. It fails when its running, with this command: docker run -v '$PWD':/my-cypress-project -t my-cypress-image:1.1.0 --spec cypress/e2e/pom/homeSauce.spec.js --headless --browser chrome --config-file=/my-cypress-project/cypress.config.tsBogard
I believe that if there was a way to get cypress to run chrome without the GPU acceleration setting, it should work. One would assume that running headless would disable this, but nope.Bogard
@TommyVDFN - did you manage to resolve this as I'm having similar issues on a vagrantbox :(Surcease
I have the same error, and it has nothing to do with Cypress directly. My Cypress runs immediately after this error. Chrome is only being run after the cypress.config initializes. Did you manage to find the solution?Chetchetah
S
0

Did you try using a different reporter ? (I m not sure this is the solution to your problem, but i think i remmember having this error before and switching the reporter to junit fixed).

To change the reporter just add --reporter junit in the cypress run command or in the cypress.config.ts : reporter: junit,

Spoilt answered 23/7, 2024 at 8:9 Comment(2)
The question does not appear to be about reporters.Saturnalia
Yes i know, but from what i remmember changing reporter fix this error, that's why i propose it, if it's not the expected answer they is no problem, i was just trying to help :)Spoilt

© 2022 - 2025 — McMap. All rights reserved.