Comments (4)
@jaydenseric Could you please attach two screenshots, one with the alpha channel and another without? It would also be great to clarify how does this difference cause your snapshot test assertions to fail? Does it render a different image entirely? Or is the difference only in the internal channels representation, but pixels are the same?
from playwright.
Here is a screenshot taken with WebKit on Linux (paste it in a browser URL to see it):
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAIAAACzY+a1AAAABmJLR0QA/wD/AP+gvaeTAAABcElEQVR4nO3RwQkAIBDAsNPJHd0hfEghmaDQNWdI278DeGVhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmGdhnoV5FuZZmHcBD84BrGfmAcwAAAAASUVORK5CYII=
Here is a screenshot of the same thing, with WebKit on macOS:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAlqADAAQAAAABAAAAlgAAAAAXS0ggAAACqklEQVR4Ae3SwQ2AQAwDwXCV0zlIV0P2Ny7Aj9U88843psBygbP8506BWwAsEJICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSrU7AYSAqAlWR1ChYDSQGwkqxOwWIgKQBWktUpWAwkBcBKsjoFi4GkAFhJVqdgMZAUACvJ6hQsBpICYCVZnYLFQFIArCSr0x+1SgKrtZgbcAAAAABJRU5ErkJggg==
Here is a diff of expected vs actual image metadata (analyzed using sharp
method metadata
):
{
+ "background" : {
+ "b" : 255,
+ "g" : 255,
+ "r" : 255
+ },
- "channels" : 4,
+ "channels" : 3,
"density" : 72,
"depth" : "uchar",
- "exif" : <buffer>,
"format" : "png",
- "hasAlpha" : true,
+ "hasAlpha" : false,
"hasProfile" : false,
"height" : 150,
"isProgressive" : false,
"space" : "srgb",
"width" : 150
}
Note that WebKit on Linux is adding a background, not including an alpha channel, and is not including exif data like other environments and browsers do. Potentially all 3 differences could be considered a bug.
I'm not sure if you set screenshot option omitBackground
to true
, whether or not WebKit in linux would respect that or not and start adding an alpha channel, so I'm not sure if this bug leads to visual differences where transparency is missing in screenshots taken by WebKit in Linux. In the screenshots we happen to be taking in our snapshot tests they are of web pages that have a background color, so we are noticing a metadata difference in the snapshot images not a visual difference. Because we are using Playwright as part of a larger system analyzing screenshots, having one environment generating images with a pretty different format (alpha channel without a background, vs no alpha channel with a background) is a cause for concern and something I'm glad our pretty strict image snapshot testing assertion function picked up.
from playwright.
Probably this is a bug upstream. In the case of WebKitGTK, the API for taking a snapshot stores only RGB information (CAIRO_FORMAT_RGB24).
Maybe it could be possible to change it to CAIRO_FORMAT_ARGB32 without side effects.
from playwright.
@jaydenseric Thank you for the explanation. While it would be nice to have the same representation across platforms, that's not the goal for Playwright's screenshots. In fact, even rendering is often different between platforms, e.g. due to different system fonts. Therefore, I would not consider this a bug, but I would also not be opposed to align between platforms where possible.
@dpino Thank you for the pointer! I think we are using FrameSnapshotting
in the web process at the moment, but when/if we switch to taking screenshots from the UI process, this would be a good place to fix indeed.
from playwright.
Related Issues (20)
- [Bug]: Results from UI mode are not merged with merge reports command HOT 1
- [Bug]: Trace viewer shows wrong request body HOT 3
- [Docs]: Search... Please use exact or provide and option to make it fuzzy HOT 2
- [Bug]: Project dependencies not run unless dependency project is selected when running tests in VS Code HOT 2
- [Feature]: Can it support perfect timings salary? HOT 2
- [Feature]: launchServer bind hostname or address
- [Please read the message below]
- [Bug]: python confusing stacked context of page.pdf header_template HOT 1
- [Question] Add 'retain-on-failure' option to .net HOT 4
- [Bug]: Submit button is not getting enabled after filling a login form HOT 1
- [Bug]: OffscreenCanvas in Webworker missing for Webkit in GithubActions HOT 2
- [Feature]: Support optGroup parameter in Locator.selectOption method HOT 5
- [Feature]: get and set radiogroup value
- Contribute new matcher
- [Bug]: --ui mode doesn't respect --trace as of 1.43 HOT 5
- [Bug]: Playwright Extension versions 1.1.1 to 1.1.6 cannot see tests in test files HOT 4
- [Bug]: component tests fail with cryptic error when files are moved around HOT 1
- [Bug]: Linux WebKit missing support for WebRTC
- [Docs]: Clarify WebKit Feature Support on Non-Apple Platforms HOT 1
- [Bug]: context.pages is not being updated with newly opened tabs HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playwright.