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

High CPU usage during cypress run #19491

Closed
stychu opened this issue Dec 29, 2021 · 35 comments
Closed

High CPU usage during cypress run #19491

stychu opened this issue Dec 29, 2021 · 35 comments

Comments

@stychu
Copy link

stychu commented Dec 29, 2021

Current behavior

I just wanted to try the latest version of the Cypress. I updated from 8.1.0 to 9.2.0 and I just got scared when I run my tests because my MacBook fans started to spin like crazy. Like a boeing 727 taking off..

There is clearly some issue regarding the new version of the Cypress (9.2.0) especially on the MacOS.

Screenshot 2021-12-29 at 12 32 21

Screenshot 2021-12-29 at 12 18 41

Screenshot 2021-12-29 at 12 24 49

Desired behavior

Tests running smoothly like on the version 8.1.0 without the HIGH CPU overhead.

Test code to reproduce

I've checked this with my repo and the default use-cases that cypress provides on fresh install

Cypress Version

9.2.0

Other

No response

@stychu
Copy link
Author

stychu commented Dec 29, 2021

This is with the version 8.1.0
It oscillates between 40-90 CPU

Screenshot 2021-12-29 at 13 18 45

Screenshot 2021-12-29 at 13 18 39

@Narretz
Copy link
Contributor

Narretz commented Dec 29, 2021

Interesting, because 9.2.0 was supposed to fix some instances of high CPU use.
Did you use open or run mode?
And did you check the intermediate versions to find the exact version where it started?

@sainthkh sainthkh added the stage: awaiting response Potential fix was proposed; awaiting response label Jan 10, 2022
@jkananen
Copy link

Same here in run mode, CPU reportedly at >200% (screenshot below), and some tests are failing due to timeouts.

Tried also open mode, which is OK; CPU hovers around 15-40%.

I updated from version 8.3.0 to 9.2.1 when noticing this. I've not tried any versions in between.

macOS Big Sur 11.6.

Screenshot 2022-01-15 at 17 35 13

@jkananen
Copy link

Looks to me that this happens after an update from 8.5.0 to 8.6.0.

@stychu
Copy link
Author

stychu commented Jan 17, 2022

Interesting, because 9.2.0 was supposed to fix some instances of high CPU use.
Did you use open or run mode?
And did you check the intermediate versions to find the exact version where it started?

It was during the run mode
I didn't check any intermediate version. Straight from 8.1.0 to 9.2.0 as I want to use the newest version of Cypress.

@fabouru1985
Copy link

same here with mac mini m1
cypress 9.3.1

image

@jkananen
Copy link

Occurs still with 9.5.2, only in run mode

Screenshot 2022-03-21 at 11 11 35

@cypress-bot cypress-bot bot added stage: backlog and removed stage: awaiting response Potential fix was proposed; awaiting response labels Apr 29, 2022
@stychu
Copy link
Author

stychu commented Jul 21, 2022

10.3.1 seems still to occur

@stychu
Copy link
Author

stychu commented Aug 10, 2022

10.4.0 seems to be working fine now. I can no longer see high CPU usage.

@stychu stychu closed this as completed Aug 10, 2022
@rjiang9
Copy link

rjiang9 commented Dec 2, 2022

I got in `open' mode for cypress v11.02

@rjiang9
Copy link

rjiang9 commented Dec 2, 2022

Screenshot 2022-12-02 at 9 25 38 AM

@sezginvarli
Copy link

I've same problem v11.2.0
When I run any test, even example test, cypress uses high CPU (approximately %40) and then 'not responding'.
Did you solve the problem.
Thanks

@rjiang9
Copy link

rjiang9 commented Dec 5, 2022

Not solve it yet. On my system Mac M1, the CPU usage actually reaches to 100% before 'not. responding' is displayed like this
image

@rjiang9
Copy link

rjiang9 commented Dec 5, 2022

Since this ticket is 'Closed', anybody knows how to reopen it?

@sezginvarli
Copy link

Since this ticket is 'Closed', anybody knows how to reopen it?

I don't know but this issue angries me

@stychu stychu reopened this Dec 6, 2022
@diogormendes
Copy link

Getting a high usage here as well.

M1 Max - Ventura
Cypress 11.2.0

Screenshot 2022-12-06 at 12 23 48

@sezginvarli
Copy link

Today, I upgraded v12.1.0 and unfortunately same problem continue.
High CPU usage and freeze

Help Us Please....

@rjiang9
Copy link

rjiang9 commented Dec 13, 2022

Today, I upgraded v12.1.0 and unfortunately same problem continue. High CPU usage and freeze

Help Us Please....

:) I am still fighting whether I should smash my M1. It is just fine on an Ubuntu box.

@sezginvarli
Copy link

I talked with my friend , she has no problem that uses previous versions. I've tried to alter my cypress version (like v9.1.) but I couln't. I want to learn cypress but can't run it.

Anyone help me ???

@mihhail-m
Copy link

We are running in abnormally high cpu usages in our pipelines. If anyone could share any suggestions on how to fix this, that would be great.

And to be fair, we have some parts of application to be memory intensive, but not like this 💀

Screenshot 2023-05-02 at 15 34 15

Screenshot 2023-05-02 at 15 36 00

@nagash77
Copy link
Contributor

nagash77 commented May 2, 2023

Hello @mihhail-m , based on your comment there is not enough to investigate. This issue is for a quite old version of Cypress and so far there have been no reproducible examples provided. As such I am going to close this issue.

A note for everyone following this ticket, that many performance enhancements and better support for M1 macs have occurred since version 9. Please try using the latest version of Cypress and if you are still encountering an issue, please open a new ticket with a reproducible example and etails and the Cypress team will be happy to investigate.

@nagash77 nagash77 closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2023
@mihhail-m
Copy link

hi @nagash77
Thanks for the quick response. Just fyi, we are using Cypress 12.9.0 with node 18.15.0. So, i think, issue might be still present just hardly reproducible.

@martin73h
Copy link

we have the same problem version 12.12.0 macbook m1, started to happen when initializing a new project locally, even with the test examples provided by cypress, however, the same thing does not happen with an old project that I upgraded to the same version.

@nagash77
Copy link
Contributor

@mihhail-m or @martin73h do either of you have reproducible examples of this behavior? A fork of Cypress Test Tiny is the best way to share an example repo that makes our debugging process much faster and more reliable.

@nagash77 nagash77 self-assigned this May 23, 2023
@nagash77 nagash77 removed their assignment May 24, 2023
@mihhail-m
Copy link

@nagash77 Sorry for the delayed response. Not sure what code pieces I can provide. I can just describe the setup we have and maybe this will help you reproduce.

This is the bit of cypress.config.ts that I think can be relevant:

    chromeWebSecurity: false,
    numTestsKeptInMemory: 0,
    // we enable retries only for some tests individually
    retries: {
      runMode: 0,
      openMode: 0,
    },
    video: true,
    videoCompression: false,
    // allows us to create new user for each test run and have clean environment
    testIsolation: false,
    screenshotOnRunFailure: false,
    defaultCommandTimeout: 90000,

As for the tests, they are simple cypress tests that involve authorising (via api calls), loading the page, navigating somewhere, clicking something, asserting something is present. Basic stuff.

And then we have CI environment. We are using Codefresh to run our pipelines and we do have limited control over docker containers. But it allows us to run test suites in parallel within designated containers. So each test suite of 10-20 tests would run headless in its own docker container, which is running on top of "larger" docker container (you can lookup codefresh docs for exact architecture). We usually allocate a little more resource (cores, memory) just to make sure everything is running smoothly. Most of the time it does. However we still see those crazy CPU (despite allocating 2 - 4 cores) spikes which lead to a lot of inconsistent tests and frustration as we are never sure what is the exact reason why tests are failing.

So, thats the setup. Hope that helps. We know that part of this behaviour could caused by the Codefresh pipelines, but for now there is no possibility for us to switch. But it also can be on the Cypress side as sometimes it is running fine and sometimes its CPU usages spikes as crazy.

@nagash77
Copy link
Contributor

nagash77 commented Jun 1, 2023

Hi @mihhail-m , thanks for this info. It appears you are setting things in a wqay that I would think would optimize for performance. Is there anyway you can share a fork of Cypress Test Tiny with an example of a test that shows this behavior? Are you seeing this behavior anywhere else besides in your Codefresh CI environment? I ask because we will not be able to replicate the codefresh environment internally to reproduce this behavior if that is the case. Does this behavior happen locally as well when using the same sized docker containers?

@nagash77 nagash77 self-assigned this Jun 1, 2023
@mihhail-m
Copy link

@nagash77 I will see what I can do about fork example. Might take time as its not the highest priority right now.

As for the other questions:

  • Yes, we are mostly seeing this behaviour in our CI environment.
  • Locally team mostly running on macOS M1 (not in containers). And we are running with Rosetta and arch x86_64 support to ensure compatibility between architectures.

@nagash77
Copy link
Contributor

nagash77 commented Jun 1, 2023

@mihhail-m would it be possible to try and run the example in the same docker container you use in CI on your local machine?

@nagash77 nagash77 removed their assignment Jun 8, 2023
@martin73h
Copy link

martin73h commented Aug 9, 2023

This keeps happening to us (v 12.17.3);

  1. we start a new project (npm init)
  2. install cypress (npm install cypress --save-dev)
  3. run with npx cypress open or via the path ./node_modules/.bin/cypress open
  4. run the test spect (provided by cypress)
  5. the app stops responding
    When checking the activity monitor we can see 100% cpu usage.
    Screenshot 2023-08-09 at 06 23 55
    we must force the app to close and we get the following in the terminal:
    `The Test Runner unexpectedly exited via a exit event with signal SIGKILL

Please search Cypress documentation for possible solutions:

https://on.cypress.io

Check if there is a GitHub issue describing this crash:

https://github.com/cypress-io/cypress/issues

Consider opening a new issue.


Platform: darwin-arm64 (22.5.0)
Cypress Version: 12.17.3`

Node version v18.16.0
npm version 9.8.1

we solved this by downloading an old repository with Cypress 12.13.0 which worked, but I don't think this has to do with the version since if we install the mentioned version instead of the last one we have the same problem.

@nagash77
Copy link
Contributor

nagash77 commented Aug 9, 2023

@martin73h Sorry I am not quite following. You are seeing the problem only in 12.17.3 and not 12.13.0? Are you able to look at your debug logs and see what messages are in there? This sounds like some sort of infinite loop occurring somewhere. Are you using able to run https://github.com/cypress-io/cypress-test-tiny?

@mikepeceros
Copy link

mikepeceros commented Aug 9, 2023

I'm having a similar issue. I have two Windows machines where one of them works fine but the second is having issues during cypress open or cypress run. I don't need to choose a browser to continue with the test, cypress crashes before that. Also, sometimes I could run a single test but after 1min cypress crashes. This is just a new project so I just ran npm init and install cypress. These are my specs:

  • node: 20.5.0 (or LTS version)
  • cypress: 12.17.3
    image
    image

@martin73h
Copy link

@nagash77 I have this bug when installing any version, what I did was clone an old repository and edit it to create new tests, I didn't see anything strange in the logs, and everything seems to run fine, what should I do with https://github.com/cypress-io/cypress-test-tiny ? I have never used it.

@nagash77
Copy link
Contributor

@martin73h you should fork it and setup an example of a test that produces the behavior you are seeing on your local machine so that we may take it and run it ourselves to see if we see the same behavior.

@ryanrupp
Copy link

ryanrupp commented Jan 26, 2024

If anyone stumbles upon this issue, it stems from a bug where variants of it occurred in two ranges of versions. Only was reproducible in cypress run (not open) because that is what records video and the bug has to do with screen capture options in terms of how many frames are being captured by Electron (is my understanding at least) - without this option to reduce frequency this would peg the CPU.

Broken in 8.6.0 and fixed in 10.4.0 here - #23001
Broken again in 10.8.0 and fixed in 12.2.0 here - #23830 and #25189 (not backported to 10.x or 11.x)

@97145963868
Copy link

97145963868 commented Sep 26, 2024

Same as me: "cypress": "^13.14.2",. UI starts very slow, runs 2 or 3 times slow and then freezes computer. Need to reboot. This started recently, about 2 months ago. I was using version 11.2 of Cypress without any problems. The computer, Windows 11, is constantly updated by my company and I cannot downgrade it. I updated Cypress through all versions up to the current one, including downgrading to v. 10. No success. It improves a little if I use the UI without VSCode.

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