[🐛 Bug]: Selenium Grid 4.9.0 fails to start chrome in Linux when --headless=new is used with RemoteWebDriver
What happened?
When I specify the new --headless=new, browser is launched in windows via grid but not in linux using selenium grid. Grid is started with below commands:
--start hub java -Dwebdriver.http.factory=jdk-http-client -jar selenium-server-4.9.0.jar --ext selenium-http-jdk-client-4.9.0.jar hub
--start nodes java -Dwebdriver.http.factory=jdk-http-client -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.chrome.whitelistedIps= -jar selenium-server-4.9.0.jar --ext selenium-http-jdk-client-4.9.0.jar node --override-max-sessions true --max-sessions 20 --session-timeout 72000
When browser is launched in linux with --headless=new, I get
15:29:11.851 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "fde6cf6a55101cdddf564fc423dbbea4","eventTime": 1682519351629655785,"eventName": "Session request received by the Distributor","attributes": {"logger": "org.openqa.selenium.grid.distributor.local.LocalDistributor","request.payload": "[Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--remote-allow-origins=*, --headless=new, --start-maximized, --window-size=1920,1080, --enable-automation, --disable-infobars, --disable-extensions, --disable-gpu, --disable-dev-shm-usage, --no-sandbox, --disable-browser-side-navi..., --whitelisted-ips], excludeSwitches: [disable-popup-blocking], extensions: [], prefs: {download.default_directory: \u002fopt\u002finternal\u002fma\u002fjenkins\u002fwo...}}, goog:loggingPrefs: {browser: ALL, client: ALL, driver: ALL, performance: ALL, profiler: ALL, server: ALL}, pageLoadStrategy: normal}]"}}
15:29:11.851 WARN [SeleniumSpanExporter$1.lambda$export$1] - org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Host info: host: '', ip: '' Build info: version: '4.9.0', revision: 'd7057100a6' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.6.1.el7.x86_64', java.version: '17.0.5' Driver info: driver.version: unknown Build info: version: '4.9.0', revision: 'd7057100a6' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.6.1.el7.x86_64', java.version: '17.0.5' Driver info: driver.version: unknown Build info: version: '4.9.0', revision: 'd7057100a6' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.6.1.el7.x86_64', java.version: '17.0.5' Driver info: driver.version: unknown at org.openqa.selenium.grid.node.remote.RemoteNode.newSession(RemoteNode.java:150) at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession(LocalDistributor.java:645) at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession(LocalDistributor.java:564) at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest(LocalDistributor.java:818) at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1(LocalDistributor.java:779) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)
But if I set --headless only, browser launches in linux. I believe --headless=new was introduced around selenium 4.8.1 where it worked.
How can we reproduce the issue?
Start Selenium Grid 4.9.0 in linux
--start hub
java -Dwebdriver.http.factory=jdk-http-client -jar selenium-server-4.9.0.jar --ext selenium-http-jdk-client-4.9.0.jar hub
--start nodes
java -Dwebdriver.http.factory=jdk-http-client -Dwebdriver.chrome.driver=chromedriver -Dwebdriver.chrome.whitelistedIps= -jar selenium-server-4.9.0.jar --ext selenium-http-jdk-client-4.9.0.jar node --override-max-sessions true --max-sessions 20 --session-timeout 72000
Chrome is started using the following:
ChromeOptions options = new ChromeOptions();
options.setCapability(ChromeOptions.CAPABILITY, getCapabilities());
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
if(SharedConfigFileReader.getIsHeadlessRemoteBrowser()) {
options.addArguments("--headless=new"); // open headless browser
}
if(SharedConfigFileReader.getMaximzeBrowserWindow()) {
options.addArguments("--start-maximized"); // open browser in maximized mode
options.addArguments("--window-size=1920,1080"); // browser resolution
}
options.addArguments("--enable-automation");
options.addArguments("--disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-gpu"); // applicable to windows os only
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // bypass OS security model
options.addArguments("--disable-browser-side-navigation");
options.addArguments("--whitelisted-ips"); // bypass whitelisted ips
options.setExperimentalOption("excludeSwitches", new ArrayList<String>(Arrays.asList("disable-popup-blocking"))); // disable Pop-ups
options.setExperimentalOption("prefs", browserPrefs); // browser preferences
options.setAcceptInsecureCerts(true); // bypass SSL certs
driver = new RemoteWebDriver(new URL("http://localhost:4444"), options);
Relevant log output
16:06:34 Command: [null, newSession {capabilities=[Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--remote-allow-origins=*, --headless=new, --enable-automation, --disable-infobars, --disable-extensions, --disable-gpu, --disable-dev-shm-usage, --no-sandbox, --disable-browser-side-navi..., --whitelisted-ips], excludeSwitches: [disable-popup-blocking], extensions: [], prefs: {download.default_directory: /opt/internal/ma/jenkins/wo...}}, goog:loggingPrefs: org.openqa.selenium.logging..., pageLoadStrategy: normal}]}]
16:06:34 Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--remote-allow-origins=*, --headless=new, --enable-automation, --disable-infobars, --disable-extensions, --disable-gpu, --disable-dev-shm-usage, --no-sandbox, --disable-browser-side-navi..., --whitelisted-ips], excludeSwitches: [disable-popup-blocking], extensions: [], prefs: {download.default_directory: /opt/internal/ma/jenkins/wo...}}, goog:loggingPrefs: org.openqa.selenium.logging..., pageLoadStrategy: normal}
16:06:34 at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)
16:06:34 at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:94)
16:06:34 at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:68)
16:06:34 at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:165)
16:06:34 at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
Operating System
Linux
Selenium version
4.9.0
What are the browser(s) and version(s) where you see this issue?
Linux Chrome 112.0.5615.165
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 112.0.5615.49
Are you using Selenium Grid?
4.9.0
@vicozohili, 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!
A couple of questions:
- What happens if you use Selenium 4.8.3 and the same browser version and driver?
- What happens if you use Selenium 4.9.0 and the previous version of Chrome/ChromeDriver?
What happens if you use Selenium 4.8.3 and the same browser version and driver? Fails
What happens if you use Selenium 4.9.0 and the previous version of Chrome/ChromeDriver? Fails
--headless=new works in Windows without any problems using Grid. Cannot figure what might be the issue in Linux.
That is great input, which points to be an issue with Chrome/ChromeDriver on Linux. Can you please report this to the Chrome/ChromeDriver team and paste back the bug link? I will share some links below.
Hi, @vicozohili. 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.
Raised issue with chrome dev. https://bugs.chromium.org/p/chromedriver/issues/detail?id=4438
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.