Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I specify "executablePath" when calling Puppeteer #2000

Open
dcc82 opened this issue Nov 16, 2021 · 5 comments
Open

How do I specify "executablePath" when calling Puppeteer #2000

dcc82 opened this issue Nov 16, 2021 · 5 comments
Labels

Comments

@dcc82
Copy link

dcc82 commented Nov 16, 2021

I'm trying to run it on a Raspberry PI, but it gives me an error saying "Failed to launch chrome".

To make it work, I have to manually add "executablePath: '/usr/bin/chromium-browser'" to gl-context.js

Is it possible to add an option for users to run a different headless browser? Thanks.

@dcc82 dcc82 added the bug label Nov 16, 2021
@welcome
Copy link

welcome bot commented Nov 16, 2021

Thanks for opening your first issue here! This space is protected by our Code of Conduct - and we're here to help.
Please follow the issue template to help us help you 👍🎉😄
If you have screenshots to share demonstrating the issue, that's really helpful! 📸 You can make a gif too!
Don't forget to join our PublicLab Gitter channel and our ImageSequencer Gitter Channel for some brainstorming discussions.

@jywarren
Copy link
Member

Ah, hmm, it's supposed to run headless actually! We have CLI based tests too...

https://github.com/publiclab/image-sequencer/blob/main/test/cli/saveSequence.js

I think it's supposed to simply skip GL acceleration if it's not available. What sequence are you trying to run? Let me try to reproduce.

As to different headless browser, we do use Puppeteer, which i believe now supports firefox headless. I'm not sure where we can specify that but we should be able to pass in an option, i think... were you more interested in how to NOT rely on a headless browser at all, or in how to rely on a non-Chrome headless browser?

@dcc82
Copy link
Author

dcc82 commented Jan 18, 2022

The sequence is "fisheye-gl". My environment is NodeJS v16, DietPi (Raspberry Pi 4). There's no GUI.

When I ran this particular sequence to fix distorted images, it would try to launch a headless Chrome (via Puppeteer) to process them. Since Chome is not available on Raspberry Pi, I needed to manually add "executablePath: '/usr/bin/chromium-browser'" to gl-context.js (src/modules/_nomodule/gl-context.js: line 12) so that it can invoke the correct browser which is Chromium. It seemed to use Chrome by default.

Does it mean "fisheye-gl" must require a headless browser? If so, how can I run this sequence in an environment without Chrome? If you could just pass in an option for people to specify a different headless browser, that would be great. Is it possible? Thanks.

@jywarren
Copy link
Member

jywarren commented Jan 25, 2022

fisheye-gl requires a GPU. I think that's what you're tweaking in gl-context... but ok, great, so let's try to find a place to put a configurable flag. Tracing the call, your modification was here:

puppeteer.launch({headless: true, args:['--no-sandbox', '--disable-setuid-sandbox']}).then(function(browser) {

So we would pass in the option to the three modules that use it. I think we can do something like we do with the useWasm option:

let sequencer = ImageSequencer({headlessBrowserExecutablePath: '/usr/bin/chromium-browser'})

Then we'd insert that on line 12 of gl-context.js, like:

  let puppeteerOptions = {
    headless: true,
    args: ['--no-sandbox', '--disable-setuid-sandbox']
  }
  if (options.headlessBrowserExecutablePath) puppeteerOptions. executablePath = options.headlessBrowserExecutablePath;
  puppeteer.launch(puppeteerOptions).then(function(browser) { 

Plus we'd want to add to the README a note just below the useWasm section

@jywarren
Copy link
Member

How does that sound? Do you have any interest or capacity to give this a try, or would you like my support in getting this going? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants