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

Chromium is not closed when calling "driver.quit()" #1507

Open
2uanDM opened this issue Aug 24, 2023 · 11 comments
Open

Chromium is not closed when calling "driver.quit()" #1507

2uanDM opened this issue Aug 24, 2023 · 11 comments

Comments

@2uanDM
Copy link

2uanDM commented Aug 24, 2023

Hi everybody, I has this problem with the newest version of uc:
image
This image is my option for creating the driver (That browser path is of chromium 114, since my current chrome version is 116)

After executing script, my is closed but I still see chromium active in task manager, and also used a lot of resouces (high cpu usage)

image

I have called driver.quit() at the end but it seem not work in this case. Can anyone help me this my problem ?

@vyanezz
Copy link

vyanezz commented Aug 24, 2023

After the last updates with chrome 116 the chrome instances do not close correctly, you can try with

subprocess.run(["taskkill", "/F", "/IM", "chrome.exe"], check=True)

This command is working for me with no problems and avoids cpu and ram saturation.

@2uanDM
Copy link
Author

2uanDM commented Aug 25, 2023

After the last updates with chrome 116 the chrome instances do not close correctly, you can try with

subprocess.run(["taskkill", "/F", "/IM", "chrome.exe"], check=True)

This command is working for me with no problems and avoids cpu and ram saturation.

Thank you very much, it also worked for me

@2uanDM 2uanDM closed this as completed Aug 25, 2023
@trestlesky
Copy link

So this is a problem with chrome 116? The proposed solution here isn't viable for me because sometimes I have multiple scripts running at once. If I use subprocess to kill chrome, I'd kill all my scripts.

@dangsonwheredidyoufindthis

I'm not quite sure which one of these arguments solves this issue, but this doesn't occur when launched with these:

options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-renderer-backgrounding")
options.add_argument("--disable-background-timer-throttling")
options.add_argument("--disable-backgrounding-occluded-windows")
options.add_argument("--disable-client-side-phishing-detection")
options.add_argument("--disable-crash-reporter")
options.add_argument("--disable-oopr-debug-crash-dump")
options.add_argument("--no-crash-upload")
options.add_argument("--disable-gpu")
options.add_argument("--disable-extensions")
options.add_argument("--disable-low-res-tiling")
options.add_argument("--log-level=3")
options.add_argument("--silent")

@trestlesky @2uanDM

@2uanDM
Copy link
Author

2uanDM commented Aug 29, 2023

So this is a problem with chrome 116? The proposed solution here isn't viable for me because sometimes I have multiple scripts running at once. If I use subprocess to kill chrome, I'd kill all my scripts.

I'm using chromium browser 114 and it can not always quit the chromium process when I called "driver.quit()". Since my script just running one process so that solution is just temporary

@2uanDM 2uanDM reopened this Aug 29, 2023
@2uanDM
Copy link
Author

2uanDM commented Aug 29, 2023

I'm not quite sure which one of these arguments solves this issue, but this doesn't occur when launched with these:

options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-renderer-backgrounding")
options.add_argument("--disable-background-timer-throttling")
options.add_argument("--disable-backgrounding-occluded-windows")
options.add_argument("--disable-client-side-phishing-detection")
options.add_argument("--disable-crash-reporter")
options.add_argument("--disable-oopr-debug-crash-dump")
options.add_argument("--no-crash-upload")
options.add_argument("--disable-gpu")
options.add_argument("--disable-extensions")
options.add_argument("--disable-low-res-tiling")
options.add_argument("--log-level=3")
options.add_argument("--silent")

@trestlesky @2uanDM

Thank you @trestlesky, let's me try this

@trestlesky
Copy link

I'm not quite sure which one of these arguments solves this issue, but this doesn't occur when launched with these:

options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-renderer-backgrounding")
options.add_argument("--disable-background-timer-throttling")
options.add_argument("--disable-backgrounding-occluded-windows")
options.add_argument("--disable-client-side-phishing-detection")
options.add_argument("--disable-crash-reporter")
options.add_argument("--disable-oopr-debug-crash-dump")
options.add_argument("--no-crash-upload")
options.add_argument("--disable-gpu")
options.add_argument("--disable-extensions")
options.add_argument("--disable-low-res-tiling")
options.add_argument("--log-level=3")
options.add_argument("--silent")

@trestlesky @2uanDM

Thank you @trestlesky, let's me try this

This does seem to be working for now, though I tried playing around with the different options, and like you I have no idea which options did the trick.

@Mister-Stein
Copy link

Unset the --no-sandbox Chrome argument, setting no_sandbox argument of uc.Chrome to False, because it is set to True by default. Example:

uc.Chrome(driver_executable_path=driver_executable_path, options=options, user_data_dir=user_data_dir, no_sandbox=False, user_multi_procs=True, use_subprocess=False)

But some things to consider:
Users say that undetected-chromedriver doesn't work without --no-sandbox Chrome argument on Windows 7 and lower, but works on Windows 8.1 and above. I didn't tested that for myself, but I think it's true.
Also, undetected-chromedriver most of the times doesn't work on Linux without --no-sandbox Chrome argument(when running test script as root user for example). So, that's because no_sandbox argument of uc.Chrome is set to True by default. Concluding that, set no_sandbox argument of uc.Chrome to False for Windows, and set to True for Linux.
But I warn that undetected-chromedriver has breached no_sandbox functionality, so --no-sandbox is always set, whether or not you set it to True or False. I've made pull request to fix it, so we need to wait until it is applied(or download my fork, and use as custom Python module). #1542

@11AnJo
Copy link

11AnJo commented Jan 11, 2024

@dangsonwheredidyoufindthis
I tested it and disable gpu is that one argument. No idea why its that tho
options.add_argument("--disable-gpu")

@0x1991
Copy link

0x1991 commented May 4, 2024

The only way I fixed this issue was calling close() before quit() like:

driver.close()
driver.quit()

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

8 participants
@0x1991 @11AnJo @trestlesky @2uanDM @Mister-Stein @vyanezz @dangsonwheredidyoufindthis and others