jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.52k stars 4.02k forks source link

Switch back from Chromium to PhantomJS? #6567

Closed jdubois closed 6 years ago

jdubois commented 6 years ago

We switched from PhantomJS to Chromium in #6377 by @PierreBesson

This is of course the future, but at the moment I have at least 2 feedbacks from clients where it doesn't work:

As we had none of those issues with PhantomJS (it works for both clients), I think it's too early to have Chromium, and we should switch back to PhantomJS.

Thoughts, ideas, comments?

PierreBesson commented 6 years ago

I personnaly think that keeping PhantomJS is not viable in the long term. The current best practice is definitely to use a headless browser. Current options are Chrome (>= v59) adn Firefox (>= v56).

I'm aware some people have issues with it but afaik they have not opened issues to report and document those. So for me there are currently no open bugs on Chromium headless.

jdubois commented 6 years ago

Yes I know people didn't send any bug reports: I guess they don't care about Karma tests. Or, as it is easy to change, they just do the change and don't tell us: this is quite common for "easy" issues, people solve the problem for themselves and don't report anything back to us.

Let's keep this open a couple of days and get some feedback. If nobody comments, let's close this.

applecool commented 6 years ago

@PierreBesson Were you able to run the karma tests using chrome headless on linux? If yes, could you please share your karma config. I am trying to fix this issue from a very long time and I am unable to get it work. The log says, starting chrome headless and it just stays there until the browseractivitytimeout is passed and then disconnects without executing any tests. I didnt had this problem on Mac. It just works seamlessly on OSX. Any of your suggestions would make my problem much clearer. Thank you.

deepu105 commented 6 years ago

BTW this also introduced the side effect that the Protractor tests are also run in the headless mode now. Some people like to see them running as they may using screen capture tools etc on them

jdubois commented 6 years ago

Yes @deepu105 I also had that problem -> now if you run Protractor you miss the whole "wow" effect that people love. And that's important if you want them to use the tool.

mraible commented 6 years ago

+1 for adding the "wow" back in!

PierreBesson commented 6 years ago

@applecool Yes I had this working on Linux. Can you give more details about your setup ?

@deepu105 I also liked the wow effect but it is accessory. Also puppeteer let's you take screenshot from chrome headless (new chrome feature). Then I think it's still possible to use a non headless browser for protractor tests.

applecool commented 6 years ago

@PierreBesson This is my config.

module.exports = function (config) {
    config.set({
        basePath: 'build/',
        frameworks: ['jasmine'],
        plugins: [
            require('karma-jasmine'),
            require('karma-chrome-launcher'),
        ],
        files: ['tests.js'],
        autoWatch: false,
        browsers: ['ChromeHeadless'],
        singleRun: true,
        browserNoActivityTimeout: 120000,
        urlRoot: '/build/'
    })
}
gmarziou commented 6 years ago

We also had issues on Linux Centos 7 for our Jenkins build where installer did not work and we had to install gtk3 libs and others

deepu105 commented 6 years ago

We had issues in our Linux Jenkins serup with chrome as well due to missing libs

On 21 Oct 2017 11:52 am, "Gaël Marziou" notifications@github.com wrote:

We also had issues on Linux Centos 7 for our Jenkins build where installer did not work and we had to install gtk3 libs and others

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/6567#issuecomment-338379532, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlFxAvo8l3cN3bLzNO6ua1wgvXvgssks5sub7ggaJpZM4QAbVG .

PierreBesson commented 6 years ago

@applecool This doesn't look like code generated by a recent JHipster version. Can you open a stackoverflow post with full yo-rc.json and details of what you are trying to do.

Ok so far we have the following issues with Chrome Headless :

Reverting to PhantomJS is still an option but I think having a real browser is much better.

hdurix commented 6 years ago

I also had this kind of troubles using Chromium Headless with Continuous Integration (Gitlab CI + Docker image openjdk:8). The Linux distribution was missing some libraries for launching Chromium Headless (for instance libXss).

I spent some time trying to resolve the issue and finally went back to PhantomJS as I didn't have too much time to spend on.

jdubois commented 6 years ago

I'm sorry @PierreBesson but for me that's a lot of people and a lot of projects having issues. We just can't provide something that doesn't work out of the box - I know we're "hipsters" and do all the latest cool techs, but here this is just failing for too many people, on too many different systems.

gmarziou commented 6 years ago

@PierreBesson I just checked with my colleague and he put this on hold as he could not get it to work on CentOS after few hours. Ironically, it works fine on Windows 7

PierreBesson commented 6 years ago

@hdurix, Did your karma config had the --no-sandbox flag, I think this would fix the issue. The openjdk docker image is based on debian, the related issue is this one: https://github.com/GoogleChrome/puppeteer/issues/290 @gmarziou What was your setup on Windows. Did you use git bash ?

I found the canonical documentation to troubleshoot pupeteer: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md According to this docs, it should work fine on linux systems if you install some dependencies.

@jdubois Agree, if we are not able to find satisfying fixes before the next release let's roll back. I'm will submit a PR to upgrade puppeteer and try it on different OSes.

jdubois commented 6 years ago

Thanks @PierreBesson -> yes let's try to upgrade, and provide better documentation

hdurix commented 6 years ago

@PierreBesson here an example you could run to reproduce the error:

docker run -v ~/workspace/moni-sync:/moni-sync -it openjdk:8 moni-sync/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome

Or you the flags:

docker run -v ~/workspace/moni-sync:/moni-sync -it openjdk:8 moni-sync/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome --no-sandbox --disable-setuid-sandbox

Both lead to the following error:

moni-sync/node_modules/puppeteer/.local-chromium/linux-497674/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory

I can do some other tests if you want.

PierreBesson commented 6 years ago

@hdurix Did you try to install the libs described in troubleshooting.md ?

hdurix commented 6 years ago

@PierreBesson I'll try this as soon as I've got some time (probably tomorrow).

pascalgrimaud commented 6 years ago

I spent a couple of hours tonight on this. In fact, we currently have the same issue in our jhipster/jhipster image.

To resolve, I needed to follow these instructions: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker

Then, here my karma.conf.js configuration:

    browsers: ['ChromiumHeadless'],
        customLaunchers: {
            'ChromiumHeadless': {
                base: 'Chrome',
                flags: [
                    '--no-sandbox',
                    '--headless',
                    '--disable-gpu',
                    // Without a remote debugging port, Google Chrome exits immediately.
                    '--remote-debugging-port=9222'
                ],
                debug: true
            }
        },
PierreBesson commented 6 years ago

@pascalgrimaud Yes but you would need yo install chrome in your docker image and not using the chromium binary provided by pupetteer.

hamark commented 6 years ago

Hi all,

I had the same problem on my continuous integration system (Jenkins on a centos7), I finally made it work. To do so, I have :

$ yum -y install google-chrome-stable.x86_64
$ yum -y install liberation-mono-fonts  liberation-narrow-fonts liberation-sans-fonts  liberation-serif-fonts
pascalgrimaud commented 6 years ago

Although the PR by @PierreBesson is merged, there are still some issues which isn't resolved, so I'm reopening this

pascalgrimaud commented 6 years ago

Here all the issues I encounter, when launching yarn test, which means in production profile:

It's too much issue for no real value immediatly, excepting PhantomJS will be deprecated or is not maintained anymore.

As @jdubois, I would suggest to switch back to PhantomJS. Then, work step by step in a branch to replace PhantomJS by Chromium, check and test if it works for Docker, GitLab, Jenkins, CentOS, Windows7 etc.

jdubois commented 6 years ago

Hi all, so again this is not solved (and I'm suffering from Puppeteer at the moment as I'm on the train and this takes a huge amount of bandwith!!!).

-> does everyone agree? who would want to take some of those tasks?

Tcharl commented 6 years ago

No way to fix every Puppeteer Issues? Working for a temporary does not look to be the best one

PierreBesson commented 6 years ago

I have written some docs on how to fix common chrome headless issues. It also has instruction on how to set up phantomjs. Most issues are actually environment issues where you need some dependencies like libxss to install chrome.

About the wow effect, you should be able to bring it back simply by switching karma from ChromeHeadless to Chrome.

Then if we decide to switch back to Phantomjs I would understand as it impacts a lot of setup.

pascalgrimaud commented 6 years ago

@jdubois : I can work on reverting to PhantomJS (unless you already started it)

Then, with @PierreBesson we can start a branch to prepare the migration to ChromeHeadless, and tested all CICD

jdubois commented 6 years ago

Yes @pascalgrimaud go ahead!

pascalgrimaud commented 6 years ago

Soon day work... I'll try to do it before the end of day

jdubois commented 6 years ago

BTW I have an entity with a ZonedDateTime: the test is failing today with Chromium and I'm pretty sure this was working before - I hope it will still fail with PhantomJS :-)

thomastardy commented 6 years ago

Just for information if anybody tries to run the current version with ChromiumHeadless on CentOS 7, you have to install the packages chromium-libs and gtk3. This solved the problem for us.

BitFlipp3r commented 6 years ago

Has #6675 been reverted? I'm using v5 beta and get the same chromium error:

25 05 2018 13:56:42.892:ERROR [launcher]: ChromiumHeadless stdout: 
25 05 2018 13:56:42.892:ERROR [launcher]: ChromiumHeadless stderr: /builds/PentestManager/pentest-manager-gateway/node_modules/puppeteer/.local-chromium/linux-536395/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
pascalgrimaud commented 6 years ago

Yes @BitFlipp3r : a lot of things has changed. Here the history:

Tarekajaj commented 6 years ago

@pascalgrimaud is there a workaround right now for developer using v5 beta? we are facing the same error as @BitFlipp3r when using Gitlab-CI

pascalgrimaud commented 6 years ago

@Tarekajaj : you can have a look at the official doc: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

But here some solutions: