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

Fix Viewport resizing upon page.screenshot #125

Merged
merged 1 commit into from
May 22, 2024

Conversation

beeh5
Copy link
Contributor

@beeh5 beeh5 commented May 22, 2024

Issue
Currently, Puppetteer resizes the viewport when page.screenshot(...) is being triggered. On modern development hardware, you barely notice it in non-headless mode, unless for example you manually throttle Chromium (await page.emulateCPUThrottling(6);). The issue with the viewport resizing is that in HomeAssistant, some dashboards reload / redraw themselves upon resize action. Which results in a beautiful race condition upon taking the screenshot. Issues like #95 are the consequence. The resizing seems weird and unnecessary, given that the dimensions are defined already...

Approach
I found a workaround on StackOverflow how to prevent the re-sizing of the viewport. It works on my machine as expected, but please verify with your own dashboard.

@sibbl sibbl merged commit 49b1acd into sibbl:main May 22, 2024
@sibbl
Copy link
Owner

sibbl commented May 22, 2024

That's some very interesting behavior I was not aware of! Thanks for the fix, let's see which troubles it will solve besides the issue you had 👍

Thanks a lot for the PR!

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

Successfully merging this pull request may close these issues.

2 participants