sibbl / hass-lovelace-kindle-screensaver

This tool generates a png from a Home Assistant Lovelace view, which can be displayed on a Kindle device which has the Online Screensaver plugin installed.
MIT License
311 stars 71 forks source link

failed to start browser in docker #101

Open crom80 opened 6 months ago

crom80 commented 6 months ago

I 've installed the docker image. But if I start the image i can see in the logs that there is a problem to start the browser. What i doing wrong?


> hass-lovelace-kindle-screensaver@1.0.5 start

> node index.js

Starting browser...

/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:214

            reject(new Errors_js_1.TimeoutError(`Timed out after ${timeout} ms while trying to connect to the browser! Only Chrome at revision r${preferredRevision} is guaranteed to work.`));

                   ^

TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r901912 is guaranteed to work.

    at Timeout.onTimeout (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:214:20)

    at listOnTimeout (node:internal/timers:559:17)

    at processTimers (node:internal/timers:502:7)

npm notice 

npm notice New major version of npm available! 8.19.4 -> 10.2.5

npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.5>

npm notice Run `npm install -g npm@10.2.5` to update!

npm notice 
Flashbrick commented 5 months ago

You may take a look at your base url. Mine defaulted to https:// and when I changed it to http:// it worked. Keep in mind I am using the Addon so it may not work but my log looked similar.

crom80 commented 5 months ago

Thanks for your hint. It was set at http:// the whole time. so this wasn't the problem. Here is my portainer stack config:

version: "3.8"

services:
  app:
    image: sibbl/hass-lovelace-kindle-screensaver:1.0.5
    environment:
      - HA_BASE_URL=http://192.168.178.82:8123
      - HA_SCREENSHOT_URL=/handy-dashboard/home
      - HA_ACCESS_TOKEN=eyJhM0TyTV3YKwrIfmZD.........removed................removed......
      - CRON_JOB=* * * * *
      - RENDERING_TIMEOUT=120000
      - RENDERING_DELAY=0
      - RENDERING_SCREEN_HEIGHT=800
      - RENDERING_SCREEN_WIDTH=600
      - GRAYSCALE_DEPTH=8
      - OUTPUT_PATH=/output/cover.png
      - LANGUAGE=en
      - ROTATION=0
      - SCALING=1
      - BROWSER_LAUNCH_TIMEOUT=120000
    ports:
      - 5555:5000
    volumes:
      - /volume1/docker/kindle:/output
sibbl commented 5 months ago

Which device is your docker container running on? Although the timeouts of 120s look large enough, there might be some incompatibility of the image / browser / device combination which we don't know about yet.

crom80 commented 5 months ago

Hello sibbl, I have a Synology DS223j. For me it is the first experience with docker. I 've installed portainter and I 'm using paperless with this device and docker. I was thinking, that docker has no incompatibilities or dependencies with hardware or images. thats why I haven't installed some other things. Can I check something else?

sibbl commented 5 months ago

Could you please check the CPU/RAM usage when starting the container?

I can only confirm that it's working with a Synology which has an Intel CPU. Your Synology seems to have a Realtek ARMv8 CPU, which I have no experiences with. Ideally it should work out of the box with the ARMv8 build - which we basically support.

I have the feeling that the machine is not able to handle it properly and starting a browser is too much work load - which in the end results in the timeout being reached, unfortunately.

You should see this in the CPU/RAM usages. If so, you could check whether you might be able to stop other services and give it another try. If not, we might be able to check what else could be the reason.

crom80 commented 5 months ago

Hi Sibbl, today, for the first time, i 've started the stack an it began to create images. it creates some picture. But there are some issues. For my case its okay, if there are pictures each 15 minutes. so its okay for me.

for the CPU usage, its not more than 10 %, but the system seems slow.

Bildschirmfoto vom 2024-01-21 20-47-46

andyb2000 commented 4 months ago

I get this occasionally when starting the container, not sure why but the browser doesn't start. This is on a raspberry pi running hassos. If I stop/start the addon a couple of times it will start, so it looks like something is causing the browser not to load with the same error:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[14:15:05] INFO: Loading config...
[14:15:12] INFO: Loading additional environment variables...
[14:15:13] INFO: Using HA_BASE_URL: http://192.168.X.X:8123
[14:15:13] INFO: Starting server...

> hass-lovelace-kindle-screensaver@1.0.7 start
> node index.js

Starting browser...
/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:214
            reject(new Errors_js_1.TimeoutError(`Timed out after ${timeout} ms while trying to connect to the browser! Only Chrome at revision r${preferredRevision} is guaranteed to work.`));
                   ^

TimeoutError: Timed out after 30000 ms while trying to connect to the browser! Only Chrome at revision r901912 is guaranteed to work.
    at Timeout.onTimeout (/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:214:20)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Node.js v18.19.1
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

I did up the BROWSER_LAUNCH_TIMEOUT to 60000 but looking at the above that wasn't honoured. I'm looking into another issue at the moment on my test env so I'll see if I can spot this also.

sibbl commented 4 months ago

@andyb2000 thanks for the hint, BROWSER_LAUNCH_TIMEOUT was missing in the config. I guess as soon as this will be released as part of version 1.0.7 it should respect the 60s, which I guess should be a good timeout for your system.