question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Visual testing in docker on different CPU architecture

See original GitHub issue

Hey team 👋🏼

I am working to migrate my puppeteer visual regression testing to playwright.

My team has people working on Macs using with either arm64 (M1 SoC) or amd64 (Intel) CPU architecture.

I’d like a way to run and update playwright tests/screenshots locally from either architecture and have the local screenshots match the screenshots running from the CI (linux/amd64).

Currently we use the mcr.microsoft.com/playwright:vx.x.x-focal docker image to run tests both locally and in the CI. However running on these different architectures produce screenshots that are ever so slightly different when run on a different architecture, virtually imperceptible differences.

Screenshot from M1 mac - arm64

image

Screenshot from Intel mac - amd64

image

Diff screenshot

image

Diff gif

Screen Recording 2022-05-03 at 07 27 31 AM


So my questions is, does anyone have a good strategy to avoid the above errors on these two architectures without reducing the threshold?

I’ve tried running docker with --platform=linux/amd64 on my M1 mac, but I run into https://github.com/microsoft/playwright/issues/13724#issuecomment-1112358113 when running the tests, even on the latest docker version (v20.10.8) with Rosetta 2 installed. Sounds like this could just be a known issue with docker.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:37 (23 by maintainers)

github_iconTop GitHub Comments

3reactions
aslushnikovcommented, Nov 16, 2022

@nickofthyme Thank you again for your repro. I was able to get 247 pairs of actual/expected screenshots that all fail for me due to anti-aliasing. Hopefully we’ll come up with something to fix this.

Everybody: if you have examples of PNG screenshots that are taken on the same browser and same OS yet are different due to anti-aliasing artifacts, could you please attach the “expected”, “actual” and “diff” images here?

This information will help with our experiments with fighting browser rendering non-determinism.

1reaction
aslushnikovcommented, Dec 15, 2022

@gselsidi thank you for checking!

Also what else can we achieve with this?

The new comparator is designed to handle browser rendering non-determinism, so as long as the page layout is exactly the same, the screenshots should pass now.

Do note though that for the layout to be the same, font metrics must be the same as well. Otherwise, line wrapping might happen in different places, boxes will have different sizes, and the images will in fact be different even for human eye.

Would headed vs headless pass?

According to some exploration I did back in the days, headless vs headed rendering differences consist of the following nuances:

  1. different font stacks: this should be fixed as of Dec 2022
  2. different anti-aliasing: this should be fixed by the new comparator
  3. showing vs hiding scrollbars: there’s an open bug for this

We didn’t aim to fix this though and we didn’t experiment yet.

Non docker images vs docker images pass?

This won’t work since browsers inside and outside docker will use different font stacks, resulting in different font metrics, resulting in different layout, and finally, yielding visually different screenshots.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Frequently asked questions - Docker Documentation
General Frequently asked questions. ... Docker Desktop's UI appears green, distorted, or has visual artifacts. How do I fix this? .
Read more >
What will happen running x86-64 & ARM-based Docker ...
How to Build Multi- Architecture Docker Images with BuildX | Deploy containers to x86 and ARM! · Docker mistakes corrected by pro ·...
Read more >
Are Docker images tied to CPU architectures?
TL;DR your idea won't work, for several reasons. In general, yes, docker images are tied to CPU architectures. It is probably possible to ......
Read more >
Developing inside a Container - Visual Studio Code
The Visual Studio Code Dev Containers extension lets you use a Docker container as a ... but at least 2 GB RAM and...
Read more >
VIDEO – Kubernetes vs. Docker: It's Not an Either/Or Question
Moving to scale with Docker alone poses many challenges; Kubernetes tackles those challenges that emerge with large Docker-based deployments ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found