Giter Club home page Giter Club logo

Comments (4)

dgozman avatar dgozman commented on June 16, 2024

@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.

jaydenseric avatar jaydenseric commented on June 16, 2024

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.

dpino avatar dpino commented on June 16, 2024

Probably this is a bug upstream. In the case of WebKitGTK, the API for taking a snapshot stores only RGB information (CAIRO_FORMAT_RGB24).

https://github.com/WebKit/WebKit/blob/main/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp#L3047

Maybe it could be possible to change it to CAIRO_FORMAT_ARGB32 without side effects.

from playwright.

dgozman avatar dgozman commented on June 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.