Skip to content

Update __init__.py#1542

Open
Mister-Stein wants to merge 2 commits intoultrafunkamsterdam:masterfrom
Mister-Stein:master
Open

Update __init__.py#1542
Mister-Stein wants to merge 2 commits intoultrafunkamsterdam:masterfrom
Mister-Stein:master

Conversation

@Mister-Stein
Copy link
Copy Markdown

@Mister-Stein Mister-Stein commented Sep 4, 2023

Delete the line that breaks the ability to choose whether to use Chrome's "--no-sandbox" argument or not. That functionality is already, and supposed to be achieved through "no_sandbox" argument in the "init" method of the UC's Chrome class.
It may solve these issues: #1507 #1445 #1270
@ultrafunkamsterdam you should apply this commit as soon as possible, so people can use UC on Windows safely.

Delete the line that breaks the ability to choose whether to use Chrome's "--no-sandbox" argument or not. That functionality is supposed to be achieved through "no_sandbox" argument in the "__init__" method of the UC's Chrome class.
@Mister-Stein
Copy link
Copy Markdown
Author

Many people are frustrated by the common issue on Windows: UC is eating up all the resources because of zombie/dangling chrome.exe processes, that appear after invoking driver.quit() method. I was researching pretty long to find the solution, and I found it. The root cause is Chrome's --no-sandbox argument. It's appliance controlled through no_sandbox argument of uc.Chrome class. no_sandbox is set to True by default, because most of the times UC doesn't work on Linux without --no-sandbox Chrome argument(when running test script as root user for example). We should set no_sandbox to False, and no zombie processes will remain after driver.quit():

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)

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.
Concluding all that information, set no_sandbox argument of uc.Chrome to False for Windows, and set to True for Linux.
But even more, undetected-chromedriver has breached no_sandbox functionality, so --no-sandbox is always set, whether or not you set it to True or False. This PR is fixing that issue, and people should know to use --no-sandbox with extreme caution on Windows.
This is why users report that when they used Selenium everything was fine, but when they switched to UC everything is crashed. That happens because of the breached no_sandbox functionality in UC. Selenium doesn't apply --no-sandbox by default obviously, but UC does.

Remove some comments.
@STRATZ-Ken
Copy link
Copy Markdown

I am on Windows 10, and I can confirm setting this to True or False will not help with the driver.quit() or driver.close(). At this point I am just taskkill chome on my pc every 10 minutes.

@yuryprogl
Copy link
Copy Markdown

it helps, no_sandbox=False i used. And dont use driver.quit() or driver.close(), it will automatically 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

Successfully merging this pull request may close these issues.

3 participants