Skip to content

Chrome and Electron render colors differently #10732

Closed

Description

@teleclimber
  • Electron version: 1.7.8
  • Operating system: Mac 10.12.6

Expected behavior

Colors set in CSS should render the same in Electron as they do in Chrome.

Actual behavior

Colors look different. See image:

electron-chrome-bg

How to reproduce

Set the background-color of an element of an Electron app to rgb( 126, 183, 253 ). Compare the color rendered by Electron to the same color as rendered in Chrome.

In your Electron app do not set vibrancy, and do not set background color via the BrowserWindow API.

Notice as well that if you take a screenshot and draw a rectangle of the same RGB in a drawing program it will match Chrome's color, not Electron.

Consequences

Please note this is not a trivial issue for those of us using Electron to create apps intended for design. Something that looks "right" to the user in an electron-based design app can look subtly different and "wrong" when they export their design and open it in a regular browser.

Thanks :)

Activity

  1. teleclimber commented on Oct 11, 2017

    @teleclimber
    ContributorAuthor

    Confirmed that this problem does not occur on Windows:

    electron-chrome-colors-win

  2. thomastvedt commented on Nov 1, 2017

    @thomastvedt

    same problem here..

  3. esprehn commented on Nov 2, 2017

    @esprehn

    This sounds like color profile support not being hooked up properly, though I'm not sure how. ccameron (at) chromium.org can probably help.

  4. ccameron-chromium commented on Nov 2, 2017

    @ccameron-chromium

    Chrome as of 61 started (finally!) respecting the color profile that the OS specifies on all desktop platforms. As a consequence, CSS specification of the color ##ABCDEF, when drawn to the screen, will not necessarily be ##ABCDEF -- it will depend on the monitor that you draw it on.

    If you don't want this behavior, the following document shows how to delete your OS color profile settings (which gets you back to the old behavior), and also how to tell Chrome to ignore your OS color profile settings:
    https://docs.google.com/document/d/1jMokB_OBkZVELu22li8vnHxAUoL1eGnLedP-1Gttv40/edit

  5. Augus commented on Nov 23, 2017

    @Augus

    same problem here...

  6. codebytere commented on Apr 14, 2018

    @codebytere
    Member

    As chromium 61 is now in the latest master, this problem should be resolved. I'm going to go ahead and close this, but please feel free to @ me if it should persist.

  7. deanylev commented on Apr 25, 2018

    @deanylev

    @codebytere doesn't seem to be fixed. Here is the color #1D89CB. Left is Electron 2.0.0-beta.7, right is Electron 1.6.6, and bottom is Chrome 66. All are totally different.

    image

  8. teleclimber commented on Apr 25, 2018

    @teleclimber
    ContributorAuthor

    Not sure. It might be fixed. Here is what I get:

    artboard

    Method: set background colors on Electron and Chrome via devtools. Screenshoted and opened in Sketch to add a control rect using the same color. I opened Electron by clicking on it after downloading. I did not set any flags.

    @deanylev any ideas how you got the result you got?

  9. Skeukry commented on May 13, 2018

    @Skeukry

    On Linux, in electron v1.8.6 colors are correct, but in v2.0.0 they are off.
    By correct I mean IntelliJ, Inkscape and Chrome 66 render this way.

  10. ryran commented on May 17, 2018

    @ryran

    For the record, one more Linux user (Fedora) here who has the funky colors in Electron 2 (after updating atom to latest beta).

  11. jasonrudolph commented on May 18, 2018

    @jasonrudolph

    As chromium 61 is now in the latest master, this problem should be resolved. I'm going to go ahead and close this, but please feel free to @ me if it should persist.

    @codebytere: Based on the recent comments, and the reports we're seeing related to Atom using Electron 2.0 (atom/atom#17356), this problem seems to still be alive and well. 😬 Would it make sense to reopen this issue?

  12. 33 remaining items

  13. castroCrea commented on Apr 2, 2021

    @castroCrea

    On electron 11.2.3 I still have a difference on RGB green

    Capture d’écran 2021-04-02 à 22 35 08

    I tried

      app.commandLine.appendSwitch('force-color-profile', 'srgb');
      app.commandLine.appendSwitch('--disable-color-correct-rendering');
      app.commandLine.appendSwitch('disable-features', 'ColorCorrectRendering');
      app.commandLine.appendSwitch('disable-color-correct-rendering');
      app.commandLine.appendSwitch('--enable-color-correct-rendering', 'disabled');
      app.commandLine.appendSwitch('enable-color-correct-rendering', 'disabled');
      app.commandLine.appendSwitch('--enable-color-correct-rendering=disabled');
      app.commandLine.appendArgument('--enable-color-correct-rendering=disabled');
    

    Any help on this ?

  14. LeaVerou commented on Aug 3, 2021

    @LeaVerou

    Co-editor of the CSS Color specification here. 👋🏼 A bit late to the party.

    There seems to be some confusion in this thread regarding hex colors and color management. In CSS, hex colors should always be resolved in sRGB, per spec. It's not implementation-dependent, and has nothing to do with OS or user settings. It is not that Chrome, Safari and Firefox have decided differently, Chrome and Safari have both changed their behavior to follow the specification years ago, while Firefox still hasn't (though it can be enabled via a config flag, and will eventually become the default).

    It is understandable that if someone is only accustomed to specifying color through hex colors, it may be frustrating to them that if these are processed correctly, they cannot be used to specify about one third of their screen’s colors (since most screens today are roughly P3). There are however other color formats in CSS that are not gamut-restricted, such as Lab and LCH colors. And there are Display P3 RGB colors too for those who want to use RGB coordinates.

    However, all specified CSS colors are device independent. There is no color format that just throws raw RGB coordinates at the screen, and this is by design. This ensures portability, i.e. that colors specified on my device are the same on everyone else's devices (assuming the device is capable of displaying them). Having a setting that makes CSS colors render incorrectly defeats the purpose, and it's even worse if that's the default value!

  15. nornagon commented on Aug 3, 2021

    @nornagon
    Contributor

    @LeaVerou FWIW I believe some users—Figma and perhaps VS Code—still want to disable color-correction due to https://crbug.com/634542 and https://crbug.com/711107 being outstanding (i.e. that these features aren't controllable in WebGL/Canvas). No idea if that's a correct intention or not but that's the stated reason why @poiru is maintaining a patch for it!

  16. codingedgar commented on Nov 10, 2021

    @codingedgar

    On electron 11.2.3 I still have a difference on RGB green

    Capture d’écran 2021-04-02 à 22 35 08

    I tried

      app.commandLine.appendSwitch('force-color-profile', 'srgb');
      app.commandLine.appendSwitch('--disable-color-correct-rendering');
      app.commandLine.appendSwitch('disable-features', 'ColorCorrectRendering');
      app.commandLine.appendSwitch('disable-color-correct-rendering');
      app.commandLine.appendSwitch('--enable-color-correct-rendering', 'disabled');
      app.commandLine.appendSwitch('enable-color-correct-rendering', 'disabled');
      app.commandLine.appendSwitch('--enable-color-correct-rendering=disabled');
      app.commandLine.appendArgument('--enable-color-correct-rendering=disabled');
    

    Any help on this ?

    @castroCrea did you manage to fix this?

    Edit

      app.commandLine.appendSwitch('disable-color-correct-rendering');
      app.commandLine.appendSwitch('force-color-profile', 'srgb');

    worked for me for electron v11.0.1

    As chromium 61 is now in the latest master, this problem should be resolved. I'm going to go ahead and close this, but please feel free to @ me if it should persist.

    @codebytere this is still an issue today

    Also, I don't see any of the flags mentioned in this thread documented here: https://www.electronjs.org/docs/latest/api/command-line-switches, can someone please point me to where they are documented?

  17. castroCrea commented on Nov 10, 2021

    @castroCrea

    @codingedgar for me adding only

      app.commandLine.appendSwitch('disable-color-correct-rendering');
    

    works on electron from 11 to 15

  18. LoboTheDark commented on Jan 24, 2022

    @LoboTheDark

    It is possible that it is be broken again in 16.0.7? It looks like that if the switch is active, electron converts data and uses sRGB to displaySpace even if the image data are still in displaySpace.

  19. archfz commented on Mar 5, 2022

    @archfz

    I am using Cypress with Electron 94. The colors are displaying correctly in browser. But once screenshot is taken, using the browser, the colors are washed out. The same is happening with Chrome 98. disable-color-correct-rendering has no effects on this behavior.

    On the other hand Firefox 97 displays the colors correctly and screenshots have the same colors as well.

    Is it the case that disable-color-correct-rendering doesn't translate to the builtin screenshot capturing tool?

    EDIT: This behavior with screenshots in chromium is consistent while running browser outside of Cypress as well.

  20. archfz commented on Mar 6, 2022

    @archfz

    Correction screenshots from firefox also are off in color, but not that much as from chromium.
    EDIT: Correction to correction. Actually the colors of the screenshot from firefox seem to be ok. The OS image viewer confused me and I taught there was a difference (probs this one is also using color correction).

    1. screenshot with OS from chromium render
      img1
    2. screenshot from firefox, builtin
      img2
    3. screenshot from chromium, builtin
      img3
  21. archfz commented on Mar 7, 2022

    @archfz

    I've dived a bit deeper. The issues with screenshots is not affected in any way by the disable-color-correct-rendering or the force-color-space options. The idea is that:

    • if you take screenshot using Page.captureScreenshot command or by running window.webContents.capturePage(), colors will be washed
    • if you take screenshot using devtools [ctrl+shift+i] [ctrl+shift+p] and search Screenshot, colors are ok

    Now figuring based on this my hunch is that:

    1. either electron does some processing in first case
    2. or the chromium devtools does additional processing on image before saving, or different params for generation

    I've cloned chromium and attempted to find some information about this, but couldn't. Question is where should I open a bug? In electron or chromium. Need the input of someone who can look around in chromium.

  22. Flashwalker commented on Apr 22, 2022

    @Flashwalker

    It's all about the color profile of the monitor, as mentioned here #10732 (comment)
    Disabling this option makes colors the same

    Also in Chrome you can play with chrome://flags/#force-color-profile

  23. krema commented on Jul 29, 2022

    @krema

    Electron fixed/patched the disable_color_correct_rendering with release v18.3.6.
    #35050

  24. gregoripolak commented on Jul 18, 2024

    @gregoripolak

    This has caused me heartaches, I'm using cypress 10.3, and this patch isn't available for electron.
    I've upgraded cypress version to 13.6.4, and still, not working.

  25. slowriot commented on Nov 27, 2024

    @slowriot

    I encountered this issue with the latest Electron, alongside a recent Chromium, on linux (Debian testing). The application is rendering with WebGPU with a Vulkan back-end.

    Chromium on the left, Electron on the right:
    Image

    I found that forcing srgb colour profile worked around it:

    app.commandLine.appendSwitch('force-color-profile', 'srgb');
  26. rathboma commented on Feb 12, 2026

    @rathboma

    I'm seeing this happen again with v39 - anyone else having the same problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions