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

[🐛 Bug]: Chrome sessions not being closed properly #14076

Closed
Harrier-Du-Bois opened this issue Jun 4, 2024 · 15 comments
Closed

[🐛 Bug]: Chrome sessions not being closed properly #14076

Harrier-Du-Bois opened this issue Jun 4, 2024 · 15 comments
Labels
G-chromedriver Requires fixes in ChromeDriver I-defect I-logging Applied to issues where logging information would help troubleshoot

Comments

@Harrier-Du-Bois
Copy link

Harrier-Du-Bois commented Jun 4, 2024

What happened?

I'm using Selenium and Pytest under Windows 11 to run a sequence of testcases, usually in headless mode. Each testcase starts a browser session, does its thing and then ends the session using quit(). Then the next one starts a fresh session in the same way and so on.

The last time this has been verified as working was on 29/4/2024, using Selenium 4.19 and chromedriver 123.0.6312.122 and Chrome version 123.0.6312.106.

Since then, the Chrome version has been updated to 124.0.6367.208.

I've been trying Selenium 4.19 and 4.21 (which downloaded chromedriver 124.0.6367.207) but with both the issue remains.

ISSUE: When running this test sequence, browser sessions don't get closed properly and remain in Windows task manager. The next session gets started and they stack up to the point where the CPU is constantly at 100% load and becomes unresponsive. While running, a browser instance usually generate 2-5% CPU load but when they idle after having been quit (or not quite), they take up about 8-10% CPU each and once there'S about 10 of them, CPU goes brrr.

What I also noticed is that since this issue exists, I get an info displayed in the console that I hadn't seen before: "Created TensorFlow Lite XNNPACK delegate for CPU." No idea if this is related to the issue tho, just an observation.

I found these other users who've reported similar issues, but as there was no feedback or progress, I thought I'd open a ticket:
https://groups.google.com/g/selenium-users/c/M9BJY5Ow_zQ

There is also this issue, which might be related?
#13850
OP description sounded a bit different, but commenter (#13850 (comment)) sounded same(ish).

I'm available if you need any more info, sorry if this is considered a dub.

How can we reproduce the issue?

can't share

Relevant log output

let me know if needed

Operating System

Windows 11

Selenium version

Python 4.19 and 4.21

What are the browser(s) and version(s) where you see this issue?

Chrome 124.0.6367.208

What are the browser driver(s) and version(s) where you see this issue?

chromedriver 123.0.6312.122 and 124.0.6367.207

Are you using Selenium Grid?

nope

Copy link

github-actions bot commented Jun 4, 2024

@Harrier-Du-Bois, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@titusfortner titusfortner added the I-logging Applied to issues where logging information would help troubleshoot label Jun 4, 2024
@titusfortner
Copy link
Member

titusfortner commented Jun 4, 2024

Usually this happens when something prevents the driver.quit command from executing. Turn on logging to ensure that the command is getting sent properly.

Copy link

github-actions bot commented Jun 4, 2024

We need more information about this issue in order to troubleshoot.

Please turn on logging and re-run your code. Information on how to adjust logs for your language can be found in our
Troubleshooting documentation.

@Moez-BenAissa
Copy link

Hello, I had the same pb when upgrading the chromeDriver from 122 to 125 to fit the version to my installed chrome version.
I tried to upgrade too to the latest version 4.21.0 of SeleniumServer, but with no change.
Once we launch one test chrome over consume the CPU. Once the test is fichiched and browser is closed, the process continue to work and consuming CPU and Memory.

It's not a solution but once I did that, it fixed the pb :
I just try to kill process with cmd : taskkill /F /IM chrome.exe /T
And from this moment all is back to normal. So I think that it was an access pb or some think else that I can't understand right now.
I update if I have more information.

@Harrier-Du-Bois
Copy link
Author

Usually this happens when something prevents the driver.quit command from executing. Turn on logging to ensure that the command is getting sent properly.

Thank you for your swift reply.

I also brute forced my way around the issue for now by killing the windows PID at the end of each browser session, similar to @Moez-BenAissa 's workaround.

I'll revert those changes and create a log with the issue happening when I get a chance, maybe tomorrow.

Harrier

@titusfortner
Copy link
Member

Yes, the driver should be killing that process when it receives the driver.quit and if that isn't happening for some reason, we need to investigate why. Thanks.

@DeLaphante
Copy link

DeLaphante commented Jun 9, 2024

We're having the same issue and its more easily reproducible when you are running tests in parallel - we are running over 200 tests where 32 threads are spawned simultaneously but for some reason some chrome instances are not being killed which is hogging the memory and cpu. This is not happening when we run the same set of tests against Firefox.

Also the same issue happens on Edge as both it and Chrome are based off Chromium.

@titusfortner
Copy link
Member

To be clear, this is Chrome and Edge browser processes that are not being closed when the driver is closed?
If the same thing isn't happening with Firefox, than this would indicate that it is a Google bug.

@titusfortner titusfortner added G-chromedriver Requires fixes in ChromeDriver and removed needs-triaging labels Jun 11, 2024
Copy link

Hi, @Harrier-Du-Bois.
This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team.
Feel free to comment the issues that you raise back in this issue. Thank you.

@Moez-BenAissa
Copy link

I upgraded my platform to the next version 126 ( chromeDirver, and chrome Borwser) And all the pbs are fixed.
thank you

@Harrier-Du-Bois
Copy link
Author

Thank you all for your feedback, great to hear that this issue seems to have been resolved.
Looking forward to my organisation providing me with the working Chrome version.

@Harrier-Du-Bois
Copy link
Author

Just like @DeLaphante I sadly keep getting this error with newer Chrome versions.

I understand that this must be a Chrome issue as it doesn't happen under Firefox, but I have to stick with Chrome.

Would you happen to know if/how I could bring this to the attention of Chrome devs?

@DeLaphante
Copy link

DeLaphante commented Jul 8, 2024

@Harrier-Du-Bois - remove all chrome options arguments that you apply and the issue will resolve itself. There seems to be an issue/bug with passing the "--no sandbox" argument....I've raised it with the chrome team but as i was able to resolve it by removing the arguments I'm not sure if they're going to fix the main issue.

@Harrier-Du-Bois
Copy link
Author

@Harrier-Du-Bois - remove all chrome options arguments that you apply and the issue will resolve itself. There seems to be an issue/bug with passing the "--no sandbox" argument....I've raised it with the chrome team but as i was able to resolve it by removing the arguments I'm not sure if they're going to fix the main issue.

Hi @DeLaphante and thank you for your helpful reply. I had indeed always been using the --nosandbox argument and removing it did fix the issue, so thank you again for sharing your findings.

Copy link

github-actions bot commented Aug 7, 2024

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
G-chromedriver Requires fixes in ChromeDriver I-defect I-logging Applied to issues where logging information would help troubleshoot
Projects
None yet
Development

No branches or pull requests

4 participants