Docker-selenium: selenium/standalone-chrome "error: session deleted because of page crash\nfrom tab crashed\n"

Created on 13 Dec 2017  ยท  7Comments  ยท  Source: SeleniumHQ/docker-selenium

Meta -

Image(s):
standalone-chrome
Docker-Selenium Image Version(s):
selenium/standalone-chrome:3.4 or selenium/standalone-chrome:3.8.1
Docker Version:
Version 17.09.1-ce-mac42 (21090)
Channel: stable
3176a6af01
OS:
At least OSX and Gitlab

Expected Behavior -

Does not Crash

Actual Behavior -

Frequently Crashes (not 100% of the time but roughly 50% of the time)

I'm running an applitools test using behave python. I open and quit webdriver in before_all and after_all hooks because I only want to have to get by authentication for our site once so switching to driver.quit in between every test is not a fix like it was for https://github.com/SeleniumHQ/docker-selenium/issues/510.

My test is basically go to a page, take a screenshot, open a menu, take another screenshot, close eyes, then repeat this on 10 pages at 3 different page widths. Seems to crash right around the 14th test. Which is weird that it's getting a too many tabs error as they should all be using same browser just with 14 driver.get()'s. It's a pretty basic test but could see it taking up a lot of space due to all the screenshots it takes.

The test works fine if I run it locally with a pip install of selenium and chromedriver. But get this error when running against a hub started with docker run -p 4444:4444 selenium/standalone-chrome:3.8.1

22:36:38.602 INFO - Handler thread for session 27b4d977bc74125ce85a73af86f13f92 (chrome): Executing POST on /session/27b4d977bc74125ce85a73af86f13f92/execute (handler: ServicedSession)
22:36:38.602 INFO - To upstream: {"sessionId": "27b4d977bc74125ce85a73af86f13f92", "args": [], "script": "var doc = document.documentElement; var x = window.scrollX || ((window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0)); var y = window.scrollY || ((window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0));return [x, y]"}
22:36:38.660 INFO - To downstream: {"sessionId":"27b4d977bc74125ce85a73af86f13f92","status":13,"value":{"message":"unknown error: session deleted because of page crash\nfrom tab crashed\n  (Session info: chrome=63.0.3239.84)\n  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.9.49-moby x86_64)"}}
22:36:38.667 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@4422fcd2โ€

There seems to be a workaround of increasing shm size https://github.com/elgalu/docker-selenium/issues/20 which is fine for local docker but not easily fixable for a gitlab runner.

This is the setup for chromedriver.

    def get_headless_chrome(self):
        self.desired_capabilities = webdriver.DesiredCapabilities.CHROME
        self.desired_capabilities['loggingPrefs'] = {'browser': 'ALL'}
        self.chrome_options = webdriver.ChromeOptions()
        self.chrome_options.add_argument(
            "--disable-plugins --disable-instant-extended-api \
            --headless")
        self.desired_capabilities.update(self.chrome_options.to_capabilities())
        self.browser = webdriver.Remote(
            command_executor='http://localhost:4444/wd/hub',
            desired_capabilities=self.desired_capabilities
        )
        set_defaults(self.browser)
        return self.browser
R-awaiting-answer

Most helpful comment

Hi @Jiff21,

To have a workaround for that issue, to increase the shm is the only option. Which can be done by sharing the /dev/shm/ or setting --shm-size=2g at the docker run command.

Are those options not possible in gitlab runner?

All 7 comments

Hi @Jiff21,

To have a workaround for that issue, to increase the shm is the only option. Which can be done by sharing the /dev/shm/ or setting --shm-size=2g at the docker run command.

Are those options not possible in gitlab runner?

Hi,

So you can't just add a flag to the gitlab-ci.yml from what I can tell. The documentation seems to have a way to do this to the whole runner, so I'm waiting on internal bureaucracy to see if we can turn it up for our instance which has a cost attached to it. I'll update when I find out.

But my thoughts on not waiting till then to file an issue was that if this is really some sort of memory leak, then as test grow we'll keep running into this and keep having to dial shm_size up. So if the shm_size is reallt a workaround, wouldn't it make sense to still fix the underlying issue?

If I find time I'll try to write up something that can reproduce it that I can actually share.

Seems that you can mount a volume, right? https://docs.gitlab.com/runner/configuration/advanced-configuration.html#example-2-mount-a-host-directory-as-a-data-volume, but I am not 100% sure if the effect is the expected one since I've never used GitLab runner.

Mounting the shared memory is a workaround to the situation where the default shm value in docker is 64MB (many other images need the same workaround). Chrome and Firefox need more than that to run properly, we clarify this a bit in the README.

Closing this issue since the OP didn't report any more activity.

Here some activity :-)

Can we re-open ? It's really annoying to have to change the whole Gitlab runner configuration for the whole company to be able to run Selenium docker image ...

@JalilArfaoui it is really needed to share the shm with the container, otherwise Chrome/Firefox won't run properly. More info at https://github.com/SeleniumHQ/docker-selenium#running-the-images

OK thank you @diemol

I made it work with the shm option on the runner.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jdiprizio picture jdiprizio  ยท  5Comments

vikramvi picture vikramvi  ยท  6Comments

geekdave picture geekdave  ยท  4Comments

peterstory picture peterstory  ยท  4Comments

achung89 picture achung89  ยท  4Comments