Page MenuHomePhabricator

[Spike 4hrs] Why does color contrast tool give different results for desktop and mobile?
Closed, ResolvedPublic

Description

The wikis banwiki, bjnwiki, frwiki, kowiki,pawiki, tumwiki were descoped from our deploy as we get inconsistent results in desktop and mobile.

Understand why the color contrast checker gives different results for mobile and desktop

Event Timeline

Jdlrobson triaged this task as High priority.
ovasileva renamed this task from [Spike] Why does color contrast tool give different results for desktop and mobile? to [Spike 4hrs] Why does color contrast tool give different results for desktop and mobile?.Jul 8 2024, 5:46 PM
ovasileva removed Jdlrobson as the assignee of this task.

Thanks @KSarabia-WMF for looking at this. Feel free to move this to sign off and to assign to me once you've had a chance to update T369656 with any insights based on this analysis (e.g. use mobile instead of desktop for testing).

During this investigation, the following improvements were made:

  1. Added screenshot capabilities to the contrast checker to to visually debug issues
  2. Limit the axe core library to only run the color contrast test
  3. Diagnosing the performance issues when running the contrast checker locally

This work was somewhat tangential to the question at hand, and took up the majority of time for this investigation, but it enabled us to see what might be the cause of these bugs.

Misfires

Running the contrast checker locally on
https://ami.m.wikipedia.org/wiki/Sa%E2%80%99ayayaw_pising_no_tyin-naw flags the following errors:

Screenshot 2024-07-15 at 2.39.55 PM.png (791×1 px, 208 KB)
Screenshot 2024-07-15 at 2.40.02 PM.png (791×1 px, 106 KB)
light modedark mode

Although the contrast checker is running once in light mode and a second time in dark mode (as visible in the screenshots) it still calculates the same colors values in both modes:

Fix any of the following: Element has insufficient color contrast of 1.61 (foreground color: #ffffff, background color: #c8ccd1, font size: 9.8pt (13px), font weight: bold). Expected contrast ratio of 4.5:1

I don't know what the cause of this error could be, but it could require further investigation.

Small font-size

As @KSarabia-WMF discovered, the WCAG rating take into account font-size when evaluating color contrast. This could effect elements that have small text.
The official axe core contrast checker can be used online to manually evaluate this issue: https://dequeuniversity.com/rules/axe/4.1/color-contrast

UI related bugs vs. template bugs

Many UI related bugs have gotten caught in the contrast checker. Notably, the dark-mode date color issue T369667 has been responsible for a lot of the errors flagged by this tool.

Summary

I'd recommend further investigation into why the tool looks like it's calculating the light-mode colors in dark-mode (sometimes). As to whether mobile vs desktop is more reliable, it seems most of the errors are legitimate on both platforms, just different than those we were expecting. Since mobile has a larger default font-size though, it might be better to use that instead of desktop for errors that are related specifically to color.

Thanks @Jdrewniak seems clear to me!

Given we are wrapping up this project I'm reluctant for us to do further investigation but I'm noting this in T370099 for when we do our next big roll out.

Looks like T369656 has been updated per the recommendation.

💡One more idea! (that's pretty simple to implement).
Since this tool will be focused on helping editors fix template issues going forward, we can also limit the scan to just the #mw-content-text or .mw-parser-output element so that it doesn't catch other UI related issues. (It would still be good to know what those are though).