From 4a91505af507c8a163d515be13136c155110970d Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Wed, 15 Jun 2022 10:52:24 +0200 Subject: [PATCH] Playwright screenshots - no need for high-res "bug workaround" screenshot, use lower quality/faster configurable image quality env var --- changedetectionio/content_fetcher.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/changedetectionio/content_fetcher.py b/changedetectionio/content_fetcher.py index 89e93ca7..bc902c62 100644 --- a/changedetectionio/content_fetcher.py +++ b/changedetectionio/content_fetcher.py @@ -356,9 +356,15 @@ class base_html_playwright(Fetcher): # Bug 3 in Playwright screenshot handling # Some bug where it gives the wrong screenshot size, but making a request with the clip set first seems to solve it # JPEG is better here because the screenshots can be very very large + + # Screenshots also travel via the ws:// (websocket) meaning that the binary data is base64 encoded + # which will significantly increase the IO size between the server and client, it's recommended to use the lowest + # acceptable screenshot quality here try: - page.screenshot(type='jpeg', clip={'x': 1.0, 'y': 1.0, 'width': 1280, 'height': 1024}) - self.screenshot = page.screenshot(type='jpeg', full_page=True, quality=92) + # Quality set to 1 because it's not used, just used as a work-around for a bug, no need to change this. + page.screenshot(type='jpeg', clip={'x': 1.0, 'y': 1.0, 'width': 1280, 'height': 1024}, quality=1) + # The actual screenshot + self.screenshot = page.screenshot(type='jpeg', full_page=True, quality=int(os.getenv("PLAYWRIGHT_SCREENSHOT_QUALITY", 72))) except Exception as e: context.close() browser.close()