[Bug]: Color profile burnt into pixels of page snapshots #33198
Labels
17-x-y
blocked/upstream ❌
Blocked on upstream; e.g. Chromium or Node
bug 🪲
has-repro-repo
Issue can be reproduced by cloning a git repo
platform/linux
stale
Preflight Checklist
Electron Version
17.1.1
What operating system are you using?
Ubuntu
Operating System Version
21.10
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Screenshots taken using
Page.captureScreenshot
command or by runningwindow.webContents.capturePage()
should not have color profile changes burnt in.Actual Behavior
When taking screenshots programmatically color profile of the system is burnt into the image. On the other hand when screenshot is taken using the DevTools the screenshot is of the actual expected pixels.
Testcase Gist URL
https://github.com/archfz/electron-issue-screenshot
Additional Information
Do the following to reproduce:
npm i && npm start
./test.png
programmatically usingwindow.webContents.capturePage()
[ctrl+shift+p]
, search screenshot, and take screenshot using devtools. Save under project as./test.correct.png
#e55145
(in index.html and in ./test.correct.png) becomes#c85847
(in test.png).I have found that the following options do not change the behaviour in how screenshots are taken:
--force-color-profile=srgb
--disable-color-correct-rendering
--enable-legacy-color-correct-rendering
Why is this an issue? I am attempting to do screenshot testing, and screenshots using both electron and chrome are inconsistent between systems, thus causing false positive failures in automation. I am using Cypress, and this framework comes bundled with electron, thus it is also the default choice for pipelines to not overbloat docker images.
I am able to confirm using Cypress that the same issue is present in chrome as well. I cannot confirm with standalone chrome. Now I do not know how to actually confirm this being an issues in chromium, as that repository is highly unfamiliar for me. This issue on the other hand is not present at all in Firefox.
I think this is a major reason why there are now far from ideal workarounds, like only generating images inside docker containers, not being able to accept changes on screenshots from GUI, or even pricey third party solutions to do the screenshots. A fix on this would greatly improve DX and potentially reduce costs.
I've created this issue in electron, as this is the closest browser with easy access to screenshot testing. I hope there is someone with chromium knowledge to confirm and potentially help with a fix on the issue, by comparing how DevTools vs how Page.captureScreenshot works.
Related issues:
The text was updated successfully, but these errors were encountered: