Skip to content

Colours appear lighter on iOS compared to Android #39113

Description

@MichaelM97

Using the following example:

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        body: Center(
          child: FlatButton(
            color: const Color(0xFFFE9700),
            shape: StadiumBorder(),
            child: Text('Click me!'),
            onPressed: () {},
          ),
        ),
      ),
    ),
  );
}

We can see that the button is rendered with the correct colour FE9700 on Android:
Android

But appears lighter, using colour F19B38 on iOS:
iOS

This may relate to an older issue -> #11410.

Activity

  1. brianosman commented on Aug 23, 2019

    @brianosman
    Contributor

    What Android device and version are you using? If it's a recent version, and you go into Settings -> Display -> Colors, what is that set to (Natural, Boosted, etc...)?

  2. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 23, 2019
  3. MichaelM97 commented on Aug 23, 2019

    @MichaelM97
    Author

    I've tested this on an emulated Pixel 3 and a physical Samsung S8, both running Android 9, neither have any colour boosting enabled, and the colours appear darker on both.

  4. MichaelM97 commented on Aug 24, 2019

    @MichaelM97
    Author

    I believe I may of been incorrect about Android being at fault with this issue, I will rename it to "Colours appear lighter on iOS compared to Android" to better reflect the real issue.

    After looking into the screenshots I attached to this ticket, I can see that Android is correctly rendering the button with the colour FE9700, however, iOS renders the button with the colour F19B38.

    I've tested this on a Simulated iPhone XS, and a physical iPhone 6, both runnning the latest iOS 12.4

  5. changed the title [-]Colours appear darker on Android compared to iOS[/-] [+]Colours appear lighter on iOS compared to Android[/+] on Aug 24, 2019
  6. brianosman commented on Aug 28, 2019

    @brianosman
    Contributor

    That is the result of iOS applying color management to the framebuffer produced by Flutter. It assumes that the output of Flutter is sRGB (which it is), and then (on nearly all iPhone devices) converts to Display P3, which has a wider gamut. You can actually reproduce this with a Mac's Color Sync utility, using the Calculator tab to convert from sRGB to Display P3, and plugging the colors in on the sRGB side.

    If you were running on an Android device with the color mode set to 'Natural' (may or may not be available, depending on device and android version), then you'd see similar results. However, because people are accustomed to seeing very bright colors on their high end phones, most Android device manufacturers choose to boost colors (basically, taking the sRGB colors and directly feeding them to the screen, resulting in artificially bright/saturated results).

  7. tomasbaran commented on Apr 18, 2020

    @tomasbaran

    how can I set P3 colors on my flutter app (instead of sRGB), so I can achieve those vivid P3 colors please?

  8. TahaTesser commented on Jul 1, 2020

    @TahaTesser
    Contributor

    it looks lighter on Android than iOS for me

    flutter doctor -v
    [✓] Flutter (Channel dev, 1.20.0-2.0.pre, on Mac OS X 10.15.5 19F101, locale
        en-GB)
        • Flutter version 1.20.0-2.0.pre at /Users/tahatesser/Code/flutter_dev
        • Framework revision 15a28159bc (8 days ago), 2020-06-23 04:52:58 -0700
        • Engine revision 91a63d6a44
        • Dart version 2.9.0 (build 2.9.0-19.0.dev 7e72c9ae7e)
    
     
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
        • Android SDK at /Users/tahatesser/Code/sdk
        • Platform android-30, build-tools 30.0.0
        • ANDROID_HOME = /Users/tahatesser/Code/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 11.5)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 11.5, Build version 11E608c
        • CocoaPods version 1.9.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 47.0.2
        • Dart plugin version 193.7361
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
    
    [✓] VS Code (version 1.46.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.12.1
    
    [✓] Connected device (4 available)
        • SM M305F      • 32003c30dc19668f • android-arm64  • Android 10 (API 29)
        • macOS desktop • macos            • darwin-x64     • Mac OS X 10.15.5
          19F101
        • Web Server    • web-server       • web-javascript • Flutter Tools
        • Chrome        • chrome           • web-javascript • Google Chrome
          83.0.4103.116
    
    • No issues found!
    
  9. ajmalsalim commented on Feb 6, 2021

    @ajmalsalim

    Still reproducible on 1.22.6. Even images appear lighter on iOS Physical Device! Most probably coz of Display P3?

    Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 9b2d32b (2 weeks ago) • 2021-01-22 14:36:39 -0800
    Engine • revision 2f0af37152

  10. Krispy145 commented on May 20, 2022

    @Krispy145

    I really need display P3 for iOS soon. Are there any developments with this issue?

  11. kristapus commented on May 23, 2022

    @kristapus

    I can't stand the way colors look on Flutter apps compared to others, when Flutter will make a use of P3 color gamut? Can't wait!

  12. maheshj01 commented on Dec 27, 2022

    @maheshj01
    Member

    Reproducible
    IOS | MacOS | Android
    image

    code sample
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(
        MaterialApp(
          home: Scaffold(
            body: Center(
              child: ElevatedButton(
                style: ElevatedButton.styleFrom(
                  foregroundColor: Colors.white,
                  backgroundColor: const Color(0xFFFE9700),
                  shape: const StadiumBorder(),
                ),
                onPressed: () {},
                child: const Text('Click me!'),
              ),
            ),
          ),
        ),
      );
    }
    flutter doctor -v (mac)
    [✓] Flutter (Channel master, 3.7.0-3.0.pre.33, on macOS 12.6 21G115 darwin-arm64, locale en-IN)
        • Flutter version 3.7.0-3.0.pre.33 on channel master 
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5201856805 (38 minutes ago), 2022-12-05 18:27:21 -0800
        • Engine revision a309d239c4
        • Dart version 2.19.0 (build 2.19.0-463.0.dev)
        • DevTools version 2.20.0
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly
          to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.55.20221129
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 108.0.5359.94
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
    [✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-IN)
        • Flutter version 3.3.9 on channel stable at /Users/mahesh/Development/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision b8f7f1f986 (24 hours ago), 2022-11-23 06:43:51 +0900
        • Engine revision 8f2221fbef
        • Dart version 2.18.5
        • DevTools version 2.15.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.53.20221101
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    
  13. 7 remaining items

  14. gaaclarke commented on Jan 3, 2023

    @gaaclarke
    Member

    This isn't actually a bug in Flutter per se, but we may be able to address it in Flutter.

    Here is the sRGB reading for the Android image:
    Screen Shot 2023-01-03 at 2 48 08 PM

    Here's the sRGB reading for the iOS image:
    Screen Shot 2023-01-03 at 2 49 28 PM

    Notice that the Android screenshot isn't in the sRGB colorspace (it says "clipped"). This is, as Brian mentioned, a result of the Android device somewhere in the rendering pipeline beyond Flutter (Operating System, Driver, Display). The iOS color almost matches the specified color. The discrepancy ((255, 152, 1) vs (254, 151, 0)) is probably sampling/roundoff error when converting and capturing the screenshot.

    The color mentioned in the description erroneously specifies the iOS color as F19B38, they sampled the color in Display P3 and manually converted the values to a hash value (implicitly converting it to sRGB incorrectly).

    Sooo... this bug could potentially be fixed without adding support for Display P3 (what that means is another discussion). It could be a matter of telling Android to somehow not extrapolate sRGB colors to Display P3 colors. Some setting on the Androids drawing surface might be able to do that (for example, setting it to Display P3 and maybe explicitly converting the colors with a fragment shader?). Implementing some support for Display P3 will potentially fix this issue though since the renderer would have to reserve the space for these extrapolated Display P3 colors with real Display P3 colors.

  15. jmagman commented on Jan 3, 2023

    @jmagman
    Member

    Thanks for looking into this more!

  16. gaaclarke commented on Jan 4, 2023

    @gaaclarke
    Member

    @brianosman I suspect this issue may be related to the EGL_GL_COLORSPACE setting of the surface provided by Skia. It looks like Skia isn't setting that explicitly and the default value is EGL_GL_COLORSPACE_LINEAR. I suspect setting EGL_GL_COLORSPACE to EGL_GL_COLORSPACE_SRGB will force our colors to be in the sRGB colorspace. It sounds like EGL_GL_COLORSPACE_LINEAR may be extrapolating the colors into the Display P3 space where it is available.

    I can try it out but it's going to take some time so I thought I'd pick your brain while I'm waiting on compilation.

  17. removed
    r: duplicateIssue is closed as a duplicate of an existing issue
    on Jan 4, 2023
  18. brianosman commented on Jan 4, 2023

    @brianosman
    Contributor
  19. gaaclarke commented on Jan 4, 2023

    @gaaclarke
    Member

    I tried to reproduce the issue and set the operating system color to "boosted" and "adjusted" and got the same results as iOS on a Pixel 4a on Android 13:
    Screen Shot 2023-01-04 at 11 04 51 AM

    So, this seems to suggest that the problem isn't universal across devices with the expanded color gamut. Maybe it doesn't manifest on Android 13?

    (I was able to verify that my device supports wide gamut colors in the Photos app with a test image.)

    After reading Brian's article it seems like setting EGL_GL_COLORSPACE_KHR to EGL_GL_COLORSPACE_DISPLAY_P3_EXT may fix the issue. But since I don't know what devices are affected and it doesn't manifest on my device it's not possible for me to test that theory.

    This bug is unactionable until we are able to identify a device that can reproduce the issue. @MichaelM97 @maheshmnj do you have info on what device you were seeing this on? Does the problem persist with Android 13?

    Engine hash

    985f4ac

    methodology

    1. Take screenshot on android device
    2. download the screenshot with adb
    3. Open the image in Preview, verify the colorspace of the screenshot
    4. Use Digital Color Meter to view the pixel color
  20. added
    platform-androidAndroid applications specifically
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    and removed
    platform-iosiOS applications specifically
    on Jan 4, 2023
  21. maheshj01 commented on Jan 5, 2023

    @maheshj01
    Member

    @gaaclarke I was able to reproduce it on an Android emulator Pixel 4 api 30 as can be seen in the below screenshot

    Screenshot 2023-01-05 at 12 17 05 PM

    I am also able to reproduce it on my physical device Android Xiaomi Redmi k20 pro (Android 11), But Surprisingly when I take a screenshot either by adb or flutter tool or screenshot from device and upload it here, I don't see the issue. The button has dark color only when viewing the screenshots or the actual app on my physical device.

    Xiaomi Screenshot flutter screenshot adb screenshot
    Screenshot_2023-01-05-12-04-21-948_com example flutter_issue flutter_01 screen

    logs

    mahesh@Maheshs-MacBook-Air-M1 flutter_issue % adb -s 10.0.0.252 shell screencap -p /sdcard/screen.png
    mahesh@Maheshs-MacBook-Air-M1 flutter_issue % adb -s 10.0.0.252 pull /sdcard/screen.png     
    /sdcard/screen.png: 1 file pulled, 0 skipped. 0.9 MB/s (46295 bytes in 0.049s)
    mahesh@Maheshs-MacBook-Air-M1 flutter_issue % 
    
    flutter doctor -v (mac)
    [✓] Flutter (Channel master, 3.7.0-13.0.pre.131, on macOS 13.1 22C65 darwin-arm64, locale en-IN)
        • Flutter version 3.7.0-13.0.pre.131 on channel master at /Users/mahesh/Development/flutter_master
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 0196e6050b (2 days ago), 2022-12-31 11:10:23 -0500
        • Engine revision 932591ec04
        • Dart version 3.0.0 (build 3.0.0-76.0.dev)
        • DevTools version 2.20.0
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks
          and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.74.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.56.0
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 13.1 22C65 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 108.0.5359.124
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
        
    • No issues found!
    
    [✓] Flutter (Channel stable, 3.3.9, on macOS 12.6 21G115 darwin-arm, locale en-IN)
        • Flutter version 3.3.9 on channel stable at /Users/mahesh/Development/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision b8f7f1f986 (24 hours ago), 2022-11-23 06:43:51 +0900
        • Engine revision 8f2221fbef
        • Dart version 2.18.5
        • DevTools version 2.15.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
        • Android SDK at /Users/mahesh/Library/Android/sdk
        • Platform android-33, build-tools 33.0.0-rc4
        • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14A400
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2021.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/6351-dart
        • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.2.1)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin version 61.2.4
        • Dart plugin version 212.5080.8
    
    [✓] VS Code (version 1.70.2)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.53.20221101
    
    [✓] Connected device (3 available)
        • iPhone 12 Pro (mobile) • 026D5789-9E78-4AD5-B1B2-3F8D4E7F65E4 • ios            •
          com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.6 21G115 darwin-arm
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 107.0.5304.110
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
    

    Let me know incase any further clarification is required.

  22. github-actions commented on Jan 25, 2023

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.
    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.
    Thanks for your contribution.

  23. github-actions commented on Mar 4, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  24. locked as resolved and limited conversation to collaborators on Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    found in release: 3.3Found to occur in 3.3found in release: 3.7Found to occur in 3.7frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesplatform-androidAndroid applications specificallywaiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions