Chromedriver frequently hangs when attempting to start a new session.
Using the standalone-chrome or node-chrome images, I often observe a timeout when attempting to launch a new Chrome session.
Steps to reproduce:
- launch a standalone chrome instance:
docker run -d --name chrome selenium/standalone-chrome:2.47.1 - build the test container:
docker build -t selenium/test:local ./Test - run the repeat test script:
./test-repeat.sh chrome - If necessary, repeat steps 1 and 3 until the problem is observed
Note:
In order to narrow the focus of the test to launching new sessions, you may want to temporarily modify Test/smoke-test.js to omit the part of the test that tries navigating to github.com after starting the session. After modifying the script, make sure to rebuild the selenium/test:local image to pick up the changes.
Expected results:
All 50 sessions launch and quit successfully - the test passes.
Actual results:
One of the session launch commands will hang indefinitely.
Docker host: boot2docker v1.7.0 (Tiny Core Linux)
I can reproduce this issue. My first run was actually clean, but it hung on the 41st attempt during my second run.
Here's a bit more detail about what I see happening on the system when the launch hangs.
The last line from the selenium-server stdout just says that it's launching a new Chrome session:
➜ ~ docker logs 9251a | tail -n 4
12:26:19.769 INFO - Executing: [new session: Capabilities [{platform=ANY, javascriptEnabled=true, browserName=chrome, version=}]])
12:26:19.771 INFO - Creating a new session for Capabilities [{platform=ANY, javascriptEnabled=true, browserName=chrome, version=}]
Starting ChromeDriver 2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961) on port 17315
Only local connections are allowed.
Inside of the container, I see that some Chrome processes are in fact running:
root@9251a325813b:/# ps auxww
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
seluser 1 0.1 0.1 17968 2796 ? Ss 12:25 0:00 /bin/bash /opt/bin/entry_point.sh
seluser 5 0.0 0.0 4448 1640 ? S 12:25 0:00 /bin/sh /usr/bin/xvfb-run --server-args=:99.0 -screen 0 1360x1020x24 -ac +extension RANDR java -jar /opt/selenium/selenium-server-standalone.jar
seluser 16 0.6 1.2 207472 26296 ? Sl 12:25 0:00 Xvfb :99 :99.0 -screen 0 1360x1020x24 -ac +extension RANDR -nolisten tcp -auth /tmp/xvfb-run.qPOeDR/Xauthority
seluser 27 17.2 5.6 3042680 116716 ? Sl 12:25 0:09 java -jar /opt/selenium/selenium-server-standalone.jar
root 241 0.1 0.1 18144 3376 ? Ss 12:26 0:00 bash
seluser 811 0.3 0.5 381852 11012 ? Sl 12:26 0:00 /opt/selenium/chromedriver-2.16 --port=17315
seluser 816 0.8 3.8 555444 79020 ? Sl 12:26 0:00 /opt/google/chrome/chrome --no-sandbox --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.HFdqNc/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12545 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.XIexPl data:,
seluser 824 0.0 0.0 4368 660 ? S 12:26 0:00 cat
seluser 825 0.0 0.0 4368 656 ? S 12:26 0:00 cat
seluser 827 0.0 1.9 347672 40388 ? S 12:26 0:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --no-sandbox --user-data-dir=/tmp/.com.google.Chrome.XIexPl
seluser 828 0.0 0.3 87176 6432 ? S 12:26 0:00 /opt/google/chrome/nacl_helper --no-sandbox
seluser 845 0.1 2.2 441212 46220 ? Sl 12:26 0:00 /opt/google/chrome/chrome --type=gpu-process --channel=816.0.1041773465 --enable-logging --log-level=0 --no-sandbox --user-data-dir=/tmp/.com.google.Chrome.XIexPl --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd --supports-dual-gpus=false --gpu-driver-bug-workarounds=2,45,57 --disable-accelerated-video-decode --gpu-vendor-id=0x0000 --gpu-device-id=0x0000 --gpu-driver-vendor --gpu-driver-version --user-data-dir=/tmp/.com.google.Chrome.XIexPl --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd --enable-logging --log-level=0
seluser 874 0.0 0.0 0 0 ? Z 12:26 0:00 [chrome] <defunct>
seluser 879 3.7 0.7 555444 15400 ? S 12:26 0:01 /opt/google/chrome/chrome --no-sandbox --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.HFdqNc/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12545 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.XIexPl data:,
I am a bit suspicious of the defunct proc there, but it doesn't seem to consistently appear along with the problem, so I'm not sure that it's related to the hang at all.
For what it's worth, I don't see anything out of the ordinary in the Chrome debug log:
root@9251a325813b:/# cat /tmp/.com.google.Chrome.XIexPl/chrome_debug.log
[816:816:0814/122620:ERROR:browser_main_loop.cc(185)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
[816:816:0814/122620:INFO:audio_manager_pulse.cc(258)] Failed to connect to the context. Error: Connection refused
[845:845:0814/122620:ERROR:sandbox_linux.cc(345)] InitializeSandbox() called with multiple threads in process gpu-process
[816:816:0814/122620:WARNING:password_store_factory.cc(346)] Using basic (unencrypted) store for password storage. See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for more information about password storage options.
[874:874:0814/122620:ERROR:renderer_main.cc(200)] Running without renderer sandbox
[874:874:0814/122635:INFO:child_thread_impl.cc(666)] ChildThreadImpl::EnsureConnected()
(Those errors appear even when the session launch succeeds.)
As a sort of control I've executed the same test (repeatedly launch/quit Chrome sessions) against an Ubuntu 14.04 VM that is set up just like the Docker images -- the same Chrome and chromedriver versions, using xvfb with the same screen geometry, etc... The session launches are successful there 100% of the time, as far as I can tell, so the problem does appear to be specific to running chromedriver within a container.
Happens to me on an Ubuntu 14.04 VM (not in a container):
chrome_debug.log:
[2854:2854:0825/123047:ERROR:nss_util.cc(97)] Failed to create /.pki/nssdb directory. [2891:2891:0825/123047:ERROR:sandbox_linux.cc(345)] InitializeSandbox() called with multiple threads in process gpu-process [2854:2854:0825/123047:WARNING:password_store_factory.cc(346)] Using basic (unencrypted) store for password storage. See http://code.google.com/p/chromium/wiki/LinuxPasswordStorage for more information about password storage options. [1:1:0825/123102:INFO:child_thread_impl.cc(666)] ChildThreadImpl::EnsureConnected()
Chrome process list:
selenium 1347 1 0 12:04 ? 00:00:11 /usr/bin/java -jar /usr/local/selenium/server/selenium-server-standalone.jar -role node -nodeConfig /usr/local/selenium/config/selenium_node.json -Dwebdriver.chrome.driver=/usr/local/selenium/drivers/chromedriver/chromedriver selenium 2848 1347 0 12:30 ? 00:00:00 /usr/local/selenium/drivers/chromedriver_linux64-2.18/chromedriver --port=22923 selenium 2854 2848 0 12:30 ? 00:00:00 /opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.oy5xLY/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12573 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.nwXnbU data:, selenium 2869 2854 0 12:30 ? 00:00:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --user-data-dir=/tmp/.com.google.Chrome.nwXnbU selenium 2870 2869 0 12:30 ? 00:00:00 /opt/google/chrome/nacl_helper selenium 2873 2869 0 12:30 ? 00:00:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --user-data-dir=/tmp/.com.google.Chrome.nwXnbU selenium 2891 2854 0 12:30 ? 00:00:00 /opt/google/chrome/chrome --type=gpu-process --channel=2854.0.384655797 --enable-logging --log-level=0 --user-data-dir=/tmp/.com.google.Chrome.nwXnbU --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd --supports-dual-gpus=false --gpu-driver-bug-workarounds=2,45,57 --disable-accelerated-video-decode --gpu-vendor-id=0x15ad --gpu-device-id=0x0405 --gpu-driver-vendor --gpu-driver-version --user-data-dir=/tmp/.com.google.Chrome.nwXnbU --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd --enable-logging --log-level=0 selenium 2916 2873 0 12:30 ? 00:00:00 [chrome] <defunct> selenium 2923 2854 0 12:30 ? 00:00:05 /opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --load-extension=/tmp/.com.google.Chrome.oy5xLY/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12573 --safebrowsing-disable-auto-update --safebrowsing-disable-download-protection --test-type=webdriver --use-mock-keychain --user-data-dir=/tmp/.com.google.Chrome.nwXnbU data:,
I have also experienced this and trying to discover the cause has not been very successful. If I switch our tests to run using firefox, I do not experience this issue. When using the selenium-node-chrome-debug, I can see the browser open and running tests. During a hang, however, the browser is only open on the task bar and not able to be interacted with.
I am also having this issue. This will prevent me to use docker-selenium. I need it to be stable so I can have continuous integration and monitoring over it. And I can't use firefox since I am using some chromeOptions.
Seeing this issue as well.
Checking in to report I am also seeing this issue. Google search led me here...
I am having these issues as well, I found that decreasing the memory available to docker reduced how frequently this happens.
Seeing this as well
Any progress here? I had this issues on rare occasions in previous releases, but after updating it occures so often that I can't run my tests anymore, no matter how often I try.
I am having similar issues that I haven't investigated closely yet.
Is there any reason to believe that the container should be running an init process? Lack of proper zombie killing is one reason containers can behave strangely, right?
I think I'll try to build a Chrome WebDriver container that uses Yelp's dumb_init (http://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html) and see if that helps. Otherwise I'll have to make a timeout on a higher level to force delete and recreate the containers.
This has definitely gotten worse in the last month or two. I can't run our tests at all now.
Have you guys seen the instructions in https://github.com/SeleniumHQ/docker-selenium#running-the-images? it says to make sure you mount /dev/shm on the container. It has already improved robustness for me greatly.
Yes, I have /dev/shm bind mounted.
My team has been seeing these issues as well and we're not using docker, just a regular grid setup based on Ubuntu 14.04, so perhaps this is not specifically related to docker? To reproduce, we wrote a simple selenium script that repeatedly opens Chrome, visits a generic web page and quits the browser. After about 50 iterations the script hangs trying to start a new Chrome session. This only happens using a RemoteWebDriver, though. Using a local Chrome instance we haven't seen it hanging. HTH
@sterago
wrote a simple selenium script that repeatedly opens Chrome
Is it with or without selenium grid? Probably simple node would work?
@Vanuan The script fails when using a browser handle obtained by contacting a selenium hub. Hub and node are running on the same machine.
So it's anywhere in this chain
hub -> node -> chromedriver -> chrome
|
hub <- node <- chromedriver <-----
According to the log:
04:44:24.140 INFO - Creating a new session for Capabilities [{rotatable=false, nativeEvents=false, browserName=chrome, takesScreenshot=false, javascriptEnabled=false, version=, platform=ANY, cssSelectorsEnabled=false}]
Starting ChromeDriver 2.20.353124 (035391233162d32c80f1dce587c8154a13830c3b) on port 20575
Only local connections are allowed.
the hub reaches the node, but the node is unable to reach chromedriver because this message isn't printed:
04:44:24.450 INFO - Done: [new session: Capabilities [{rotatable=false, nativeEvents=false, browserName=chrome, takesScreenshot=false, javascriptEnabled=false, version=, platform=ANY, cssSelectorsEnabled=false}]]
@Vanuan Yes, and considering that when using a local ChromeDriver instance on that same machine it never hung during our tests, one could assume that the chromedriver <-> chrome part of the chain can be excluded as, at least in isolation, it seems not to trigger the issue. Perhaps there is some kind of deadlock happening during the communication between node and chromedriver? The result of some quick tests we did strace'ing all the parts involved seemed to suggest something along those lines, but I wouldn't bet on it.
I've just reproduced it by directly connecting to the node (without a hub).