symfony / panther

A browser testing and web crawling library for PHP and Symfony
MIT License
2.94k stars 222 forks source link

Chromium not starting in latest version #262

Closed petermanders89 closed 3 years ago

petermanders89 commented 5 years ago

I am using panther for a while now, and it is working nicely. However since I updated to 0.60.0 chromium is not launching anymore. I am using a docker image php:7-fpm-buster.

Previously chromium 76 was installed. When running the tests and inspecting the docker container I could see that indeed chromium was started. Since the latest version, using chromium 78, it does not launch at all. I verified that chromium 78 is installed in the container. The odd thing is that I do not get any error or timeout. I let it run for 15 minutes, and no message. Inspecting the container shows that phpunit is running and php is started.

Running on the latest version of Symfony (4.3.8) in combination with PHPunit 8.3.5.

petermanders89 commented 5 years ago

Slight update, my test did finish in the end, but it took almost 23 minutes. Before it only took about a minute.

dunglas commented 5 years ago

Could you try to use a recent version of Chromedriver? Maybe should we just bump the version we ship with Panther.

guillaume-perreal commented 5 years ago

Well, the ChromeDriver has to be version-compatible with Chrome/Chromium (see https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection). This become annoying if you distribute the browser using a pre-built Docker image but ChromeDriver comes from the Composer package. They quickly get out of sync.

I've worked around this problem by providing both the browser and the driver in the image and use the environment variables to have Panther use them both. E.g. :

# Install Google Chrome somehow

# Install the version of Chromedriver that is compatible with the installed google-chrome 
RUN CHROME_VERSION=`google-chrome --version | cut -d' ' -f3 | cut -d. -f1-3` \
    && CHROMEDRIVER_VERSION=`curl -sSL https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}` \
    && curl -sSL https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip -o /tmp/chromedriver.zip \
    && unzip /tmp/chromedriver.zip \
    && mv chromedriver /usr/local/bin/chromedriver \
    && rm /tmp/chromedriver.zip

# Tell Panther to use the downloaded Chromedriver
ENV PANTHER_NO_SANDBOX=1 \
    PANTHER_CHROME_DRIVER_BINARY=/usr/local/bin/chromedriver

This should probably work with Chromium.

petermanders89 commented 5 years ago

The above helped out, thanks for that.

However it did not totally solve my issue. I did a fresh Symfony installation in a docker, and there were no issues. So I compared it to my own configuration. It turned out to be the custom light hack provided in https://github.com/symfony/panther/issues/8 to implement code coverage. Removing this decreased my time drastically. I went from 23 minutes to 45 seconds. I did not have this issue with the older version (panther 0.58.0 and chromium 76) though. But this is not officially supported yet so I feel like this is issue can be closed.

stof commented 5 years ago

@petermandersvin was code coverage working before the upgrade ? Maybe the slowdown is because code coverage started to work.

petermanders89 commented 5 years ago

@stof It was working before for sure, without issues. It was a bit slower, than without but it was working. Even the issue in https://github.com/symfony/panther/issues/235 is not occurring anymore without the codecoverage hack.