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 render TimeoutError: Navigation timeout of 60000 ms exceeded #119

Open Cornmeister opened 2 months ago

Cornmeister commented 2 months ago

Hi,

I'm not able to use your tool, It starts, and after trying (and failing) to connect, it shuts down itself, Sometimes it is able to render an image, but fails most of the time.

It happens with both the HA addon and the standalone docker, running on a proxmox VMs with 16GB ram and 4 CPU cores assigned on a gen10 i7 host

any suggestions ?

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
[20:10:40] INFO: Loading config...
[20:10:41] INFO: Loading additional environment variables...
[20:10:41] INFO: Setting UNSAFE_IGNORE_CERTIFICATE_ERRORS to true
[20:10:41] INFO: Using HA_BASE_URL: https://192.168.0.29
[20:10:41] INFO: Starting server...

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

Starting browser...
Visiting 'https://192.168.0.29' to login...
Adding authentication entry to browser's local storage...
Starting first render...
Rendering https://192.168.0.29/kiosk-mode/0?kiosk to image...
Failed to render TimeoutError: Navigation timeout of 60000 ms exceeded
    at /app/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111
Converting rendered screenshot of https://192.168.0.29/kiosk-mode/0?kiosk to grayscale...
/app/node_modules/gm/lib/command.js:301
          err = new Error('Command failed: ' + stderr);
                ^

Error: Command failed: convert: unable to open image 'output/cover.png.temp': No such file or directory @ error/blob.c/OpenBlob/3569.
convert: no decode delegate for this image format `TEMP' @ error/constitute.c/ReadImage/746.
convert: no images defined `output/cover.png' @ error/convert.c/ConvertImageCommand/3354.

    at ChildProcess.onExit (/app/node_modules/gm/lib/command.js:301:17)
    at ChildProcess.emit (node:events:517:28)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5) {
  code: 1,
  signal: null
}

Node.js v18.20.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
HA_BASE_URL: https://192.168.0.29
HA_SCREENSHOT_URL: /kiosk-mode/0?kiosk
HA_ACCESS_TOKEN: *******
LANGUAGE: en
CRON_JOB: "* * * * *"
RENDERING_TIMEOUT: "60000"
RENDERING_DELAY: 5000
RENDERING_SCREEN_HEIGHT: 825
RENDERING_SCREEN_WIDTH: 1200
BROWSER_LAUNCH_TIMEOUT: 300
ROTATION: "0"
SCALING: "1"
GRAYSCALE_DEPTH: "8"
IMAGE_FORMAT: png
COLOR_MODE: GrayScale
REMOVE_GAMMA: true
PREFERS_COLOR_SCHEME: light
HA_BATTERY_WEBHOOK: set_kindle_battery_level
ADDITIONAL_ENV_VARS:
  - name: UNSAFE_IGNORE_CERTIFICATE_ERRORS
    value: "true"
sibbl commented 2 months ago

Hey, thanks for reaching out!

Navigation timeout of 60000 ms exceeded sounds like the Browser was not able to settle rendering of the page after one minute. The timeout looks quite reasonable for the hardware specs, but maybe you can check what's on your dashboard and maybe try rendering some lovelace page first, which maybe has one default entity on it? Just to be sure that the URL etc works and can then try to narrow it down on maybe some part of the content.

Unfortunately this doesn't seem to be a very straight forward advise, but it's the best I can tell from just the logs. The browser isn't very "talkative" when it comes to finding the reasons why navigation failed after 60s.

Cornmeister commented 2 months ago

Strange, a simple lovelace dashboard with one card renders fine. After switching back to the original dashboard, it still runs :D

no clue why, it works for now, will reopen issue if it returns.

thanks

Cornmeister commented 2 months ago

:( It rendered once, but now it will only render simple lovelace dashboards with one card, larger dashboards result in timeouts.

Cornmeister commented 2 months ago

did some testing, without an Apex Chart card, it runs fine. takes too much time/resources I guess.

sibbl commented 2 months ago

Technically the only option we have is to just enforce rendering, even after the timeout error was raised. It may result in broken screenshots but even this might be more helpful than an exception in the logs...

I'll think about this and let you know once I'll give this a try.

Thanks for the hint with the Apex Chart card! It's something I can try to use for reproducing the issue and fiddling around with timeout handling.

beeh5 commented 1 month ago

@Cornmeister @sibbl maybe it has to do with hardware graphic acceleration in the virtualized environment? maybe headless Chrome tries to access that, but fails to get enough of it from Proxmox... Did you allocate any GPU to your VM?

However much you put on that dashboard, your CPU config should be able to handle that...