google-chromegraphicsplaywrightheadless-browser

Chrome under playwright: Conflict in high dynamic range setting


We tried launching the same version of chrome manually and then using playwright in Java. We see a conflict in HDR setting.

A same version of chrome was launched manually and then using playwright. We observed that the following query yields different results.

console.log("HDR:", window.matchMedia("(dynamic-range: high)").matches)

On manually launched chrome, the output is true, whereas under playwright, the output is false. What causes this conflict? How do I resolve this?

Help is highly appreciated.


Solution

  • The conflict is caused by the way that Playwright emulates the user's environment.

    When you launch Chrome manually, it will detect whether the user's device supports HDR and set the dynamic-range media query accordingly.

    However, when you launch Chrome using Playwright, it will not detect whether the user's device supports HDR, so it will always return false for the dynamic-range: high media query.