-
Notifications
You must be signed in to change notification settings - Fork 717
[css-color-4] What if gradients with legacy colors *also* interpolated in Oklab by default? #7948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the demo! I had expected it to also work in Chrome Canary 108 (with experimental flag), but it didn't which I found surprising. |
It appears to be parsing the syntax, but not actually applying it. I guess that must be temporary, otherwise it would break feature detection! @sesse could clarify. |
I think this is very risky.
I don't think that is the right question. A preprocessor like PostCSS easily allows you to make |
Can you post a screenshot of the demo to see the better results? I tried WebKitGTK and |
I pulled out of CSS Color a long time ago, so I don't have anything to do with Chrome's implementation, sorry. (I ended up doing nesting instead.) |
I just added some to the first post. |
So where are we on this? I saw @fserb saying that Chrome won't change gradients that currently interpolate in sRGB because backwards-compat is prioritized over better results. |
My understanding is that Chrome at some point tried interpolating in linear RGB by default and decided the backwards compat cost was too much; but that's very different than interpolating in OkLab… Where is that comment by @fserb ? |
@fserb wrote (in the context of which interpolation spaces should be allowed and whether to add intent-based names which might change over time):
|
|
@fserb could yo confirm whether your backwards-compat concern was "we can't change to |
@svgeesus can you place srgb and oklab next to each other? |
Here you go simple edit |
Question: would it be possible to introduce a new CSS property that would set the default interpolation for the colors? Like, This way it would be possible to not break backwards-compat, but anyone who would want to just always use the more modern version, could just put this property in their reset. Something like |
It's not that simple, because you typically want a different interpolation color space depending on the use case (e.g. gradients vs transitions vs compositing etc). |
Perhaps #7035? |
The CSS Working Group just discussed
The full IRC log of that discussion<chris> q+<Rossen_> ack chris <emeyer> chris: For non-legacy colors, implementation should interpolate in oklab <emeyer> …The spec says implementations MAY interpolate in sRGB if all the colors are legacy colors <emeyer> …Lea raised, why not make them all do it in oklab? <lea> q+ <emeyer> …We did some tests, and for some colors there’s a big difference <emeyer> lea: I think it’s an obvious improvement in every color pair we tried <emeyer> …There is precedent for doing this in places like text-decoration-skip <emeyer> …It makes for an easier rule to learn and remeber <emeyer> …oklab produces better gradients <emeyer> …The only problem I could think of is color pickers <emeyer> …I can’t remember the proposed solution to this <emeyer> …The Chrome team has said they’re kind of apprehensive because they tried to do linear RGB and there were problems <emeyer> …This isn’t the same because linear RGB isn’t perceptually uniform <emeyer> chris: In Chrome, the colors are stored in premultiplied linear RGB <emeyer> …I wanted to know whether they said they can’t change because of that trial, or because of the proposal <emeyer> lea: I heard from someone on Chrome team they trioed linear RGB and had poor results <emeyer> chris: As expected <emeyer> bramus: I don’t think anyone here can address this directly, but I’ll poke the correct people for a response <fremy> I would note that there might be images associated to the gradients <emeyer> Rossen: In absence of that, is there a resolution you want to take here that will ideally be something that would work? <emeyer> lea: Are there any objections to this, involving actual cases where this would be worse? <emeyer> emilio: Does this only affect gradients, or does it also affect animation? <emeyer> lea: That’s up to us; I believe it’s currently about gradients only <emeyer> emilio: Applying to animations would be trickier because it affects computed styles <TabAtkins> yeah i'd be relatively bothered by interpolation and gradients not working the same <emeyer> chris: The spec is about interoplation, so it would apply to everything <emeyer> emilio: That’s a bit trickier, but it might work <lea> q+ <emeyer> …I’d be surprised if there are no pages that rely on this, but it might be a better default <lea> q- <emeyer> chris: Although it’s true a gradient defined as a gradient is better, I’m concerned we’ll get “why is my page lighter?” <lea> q+ <emeyer> emilio: It’s good to change the default consistently <emeyer> …I agree it’s a better default, but compat is a concern <ydaniv> what about filters? <emeyer> …Gradients would be better regardless, I think <lea> ydaniv: filters are defined entirely differently, they don't use interpolation <emeyer> …Changing the default for everything is probably worth a try <Rossen_> ack lea <emeyer> lea: I want to clarify that making this the default doesn’t make it mandatory <emeyer> …There’s a way to specify the interpolation space for gradients, and will be able to apply to other things <emeyer> …So there’s an escape hatch <emeyer> chris: This comes down to, is this an opt-in or an opt-out? <emeyer> …For unmaintained pages, what happens? <plinss> q+ <emeyer> Rossen: opt-in would be safer, yes? <emeyer> chris: I agree <bramus> q+ <emeyer> plinss: The issue of a page becoming lighter isn’t a big deal except in cases where CSS color needs to match image color <Rossen_> ack plinss <emeyer> …Want to be sure we’re taking that into consideration <Rossen_> ack bramus <emeyer> bramus: I vote for opt-in; authors will be surprised if colors change <lea> q+ to point out the other huge precedent for changing color display <emeyer> Rossen: +1 from me <emeyer> …colors can often be a branding issue <chris> q? <fantasai> +1 from me to plinss's point, that it's important for the endpoints and not so much for the middle <Rossen_> q <Rossen_> ack lea <Zakim> lea, you wanted to point out the other huge precedent for changing color display <emeyer> lea: This reminded me, we have a more relevant precedent where we changed to interpret legacy CSS colors in sRGB, so what what red meant changed (for example) <emeyer> …That’s a much bigger change than what we’re discussing here <Rossen_> ack fantasai <emeyer> …only midpoints in a transition will change <TabAtkins> color management only affected people with good screens, tho <emeyer> fantasai: I support Lea’s proposal; I think midpoint changes will be an improvement <florian> +1 <miriam> +1 <emeyer> …There’s a lot of shift in colors depending on monitor calibration etc. <emeyer> Rossen: So do we make this opt-in, something we can drop later, or make it opt-out? <emeyer> lea: Opt-in bascially means no change <emeyer> fantasai: I think we should change the default for the web to be the better interpolation <emeyer> lea: Current language is that browsers MAY do this; proposal is to change this to MUST <emeyer> Rossen: Or maybe SHOULD <lea> s/is to change this to MUST/is to change this to MUST ...or at least SHOULD?/ <emeyer> lea: Also resolutions are not binding, we can always reverse if investigations reveal it’s a bad idea <emeyer> florian: I’m not sure what we gain with a SHOULD <emeyer> …If we have a good reason not to do something, we should roll this back <emeyer> …I think MUST is appropriate <emeyer> lea: Maybe SHOULD is better for low-powered devices where oklab computation is harder than calculating the RGB values on hand <emeyer> plinss: I would argue devices like that probably won’t support this sort of thing <astearns> +1 to MUST <fantasai> +1 to requiring OKLab interpolation <emeyer> Rossen: Objections to using MUST on using oklab? <emeyer> (silence) <emeyer> RESOLVED: change specification say browser MUST use OKLab color interpolation for all colors, including legacy colors <emeyer> s/browser/browsers/ |
I still think this is a bad idea. The benefits and downsides haven't been weighted properly in my opinion. It has only been demonstrated that Reasons not to do this :
This is highly subjective. srgb interpolations tend to have darker midpoints. A page that is accessible before this change could become inaccessible. |
Sorry, for the delay in replying. I was away. I agree with @romainmenke. This is not about the gradients being better looking (they are), but as mentioned before, they can have unexpected side effects on contrast and other elements close to the gradient. Here's an example that I made using the codepen above: It's a simple The "opt-in" change is relatively simple (just add |
@fserb This example is specifically crafted for this purpose, but how prominent is this problem in the wild? Also do note that even in the first example, contrast is already insufficient. As I pointed out in the call, there is precedent for us making a change with similar dangers, when we moved from device RGB to sRGB. I don't recall anyone having text readability concerns then, and arguably that was an even more impactful change (since it also affected spot colors, not just transitions between them). |
Correct me if I am wrong, but the change from device RGB to sRGB was homogenous across any colors defined in CSS right? That change made CSS defined colors more consistent and predictable overal. This change however doesn't do any of that. I don't think these two changes are actually similar in nature.
The same is true for the inverse. It hasn't been demonstrated that authors want this change. |
The CSS Working Group just discussed The full IRC log of that discussion<emeyer> chris: We resolved but we got some pushback on github; people thought we were too hasty and they were worried about backward compatibility<lea> q+ <emeyer> …The current issue is, are we sticking with our original resolution, are we backpedaling on it, will there be an origin trial? <fserb> q+ <emeyer> lea: My recollection is we didn’t just resolve to use okLAB everywhere, we resolved to explore the potential implications <emeyer> Rossen: I would be surprised if people are pushing back on us being more careful <fantasai> the resolution definitely wasn't worded that way... <emeyer> fserb: I don’t think this was well captured on the issue; that wasn’t my understanding <emeyer> …Is this too much for an origin trial? It feels like it has the potential to break sites in weird ways <emeyer> …There’s not firm ground here <emeyer> …It felt a little bit too much, even for an origin trial, because there are expectations of what colors look like <lea> q+ <emeyer> Rossen: Origin trials are the best way we have to test safely <emeyer> …Anything we introduce can have the effect of changing things in ways authors don’t expect <emeyer> …If this is an extension of an existing features, there are different risks that can be taken <emilio> q+ <emeyer> …But anything introduced generally needs an origin trisl to make sure we don’t upset expectations <Rossen_> q? <emeyer> …This doesn’t seem too heavy in terms of trial <emeyer> dbaron: I don’t think this is the sort of thing origin trials are good at <emeyer> …Trials are good for things like PIAs <emeyer> …This is making a change that might be a compatbility problem that might break sites <emeyer> s/PIAs/APIs/ <lea> wouldn't deploying the change on beta/canary channels address this? <emeyer> …There is the concept of a reverse origin trial, but I think that’s useful when we’re more strongly committed to making breaking change but might need a bumpy rollout <Rossen_> ack dbaron <emeyer> …I didn’t get the sense we were that committed to it <fserb> +1 to what dbaron said <emeyer> emilio: I agree with fserb <emeyer> s/fserb/dbaron/ <Rossen_> ack emeyer <Rossen_> ack emilio <emeyer> …In general, an origin trial seems do-able, but I was going to ask if this has to be an origin trial as we know them <emeyer> lea: Would deploying on beta or canary channels address this? <fserb> q+ <emeyer> …In my experience, when authors do gradients, they have expectations about the color stops, not what’s between the stops <emeyer> …Also, how does a reverse origin trial work? <emeyer> iank_: Generally it’s when we’re making a known breaking change, and we want time to roll it out <emeyer> …An origin can opt out while they work to fix their site <Rossen_> q? <emeyer> …Generally only used when we really really want to do something, as they can drag on for quarters or years <Rossen_> ack lea <Rossen_> ack fserb <chris> q? <emeyer> fserb: I agree authors usually don’t want a particular value outside stops, but the gradients are different enough that even the stops can look odd <emeyer> …Colors could get darker or lighter than expected <emeyer> fantasai: I support Lea’s too points: the best way is to roll out through beta channels and collected feedback, and also that changing interpolation isn’t nearly as bad as changing stops <emeyer> …Authors who really care about the interpolation tend to add color stops to force them <lea> +1 fantasai <chris> I agree that if a specific matching color is relied on, there will be a color stop there <emeyer> …We have to consider cases where this will make things better, not just those where things will be worse <emeyer> …We expect this change to make the web better overall <emeyer> Rossen_: Is there anything we need to do about the previous resoluion? <lea> q+ <emeyer> chris: Do we stick the previous resolution in the spec, or put it in with caveats? <emeyer> lea: In theory, fserb’s point about breakage is possible if not likely, but we should explore that <emeyer> …It sounds to me like we have consensus that we should do this, but perhaps we should make the resolution more explicit that we want to explore this <emeyer> Rossen_: I agree with you there <Rossen_> ack lea <emeyer> fantasai: If we’re not going to do this, then we can’t put it in the specification, so we need an implementor to say they’re willing to do it <fserb> q+ <emeyer> Rossen_: Any implementor interest? <lea> How could implementors be interested in testing this if we have no idea *how* to test? They cannot commit to an unknown amount of work <lea> Op, I guess I was wrong :) <emeyer> emilio: It should be relatively easy to prototype and test out <fantasai> Release it in beta, and see what happens <fantasai> If there aren't lots of bugs reported, then we should be fine to release more broadly <emeyer> fserb: I’d like to see a way to measure the impact of this <lea> q? <lea> q+ <emeyer> …How would we extrapolate from beta to stable? <Rossen_> ack fserb <emeyer> …Not against this on principle <emeyer> lea: Another testing channel could be to tack it onto a flag that a lot of developers already have enabled <fantasai> s/have enabled/have enabled, e.g. experimental web platform features flag/ <fantasai> +! <fantasai> +1 <emeyer> Rossen_: There was some implementor interest, and how we implement testing is really their call <emeyer> …With that said, it sounds like the text that goes into the spec is the previous resolution <Rossen_> q? <emeyer> chris: Okay, thanks <Rossen_> ack lea <emeyer> Rossen_: So, no change here |
…ab color interpolation for all colors, including legacy colors #7948
@svgeesus Was there a resolution to change this, or was there a resolution to investigate changing this? I assumed the second from the minutes, but now I am unsure. Edit : re-read the minutes and I think I understand it better now. The final resolution in these minutes was to change the specification. |
Yes. Which amounted to commenting-out a "may interpolate in sRGB' and flipping a paragraph about how to get the old behavior. |
I see that there is a WPT which tests the old behavior (legacy syntax colors interpolate in sRGB) I guess that should be reworded and the reference should be linked with a "must not match". @mysteryDate you wrote that test (which was correct, at the time) do you agree? |
Or we could just change the reference for that test to |
Yes, right. |
Should http://wpt.live/css/css-images/parsing/gradient-interpolation-method-valid.html be updated to reflect this change? |
For the impact of changing the default to oklab will definitely be more widespread, we need to gather further feedback from the industry. In particular, the color selector in mainstream design software is basically based on sRGB. |
I agree with @svgeesus, the test should be updated. At the moment, the repo is in an inconsistent state, and has been for over a year now. This is pretty confusing when it's the spec prose and MDN VS. the spec test and actual browser behaviour. I was about to file an issue about the spec not addressing legacy colour values properly until I came across this issue. I made a jsfiddle so you can see how your browser interpolates in different situations: |
So, over a year on, where are we?
Agenda+ to re-examine the resolution |
If the WPTs have remained testing the old, now incorrect behavior, then I'm not surprised that browsers haven't followed the spec. Those need fixing. |
So we (still) have two options
|
Uh oh!
There was an error while loading. Please reload this page.
Right now, css-color-4 allows UAs to handle interpolation between legacy colors in gamma-encoded sRGB:
I wrote this as a may to give UAs the choice of not doing this, but so far implementations seem to have all done this.
We have accepted that we have to live with this wart because of webcompat, but I'm not sure we have sufficiently examined the implications of the opposite. Can we actually examine the web compat implications of doing away with this clause? What if we moved all color interpolation on the Web away from gamma-encoded sRGB?
There is precedent of changing rendering of existing content when the new way is universally better (
text-decoration-skip
, I'm looking at you), so this shouldn't be a non-starter, the bar is just high for what kind of changes are acceptable, and I'd argue this may pass that bar. Interpolating colors in Oklab never produces worse results (I challenge anyone who disagrees to find me an example where gamma-encoded sRGB interpolation produces better results, you can play with the colors here in Safari TP).The only case I can think of where gamma-encoded sRGB interpolation is desirable is color pickers. However,
It would be nice if gradients could just do the right thing by default without people needing to know about color spaces, and having to type
in oklab
in their gradients like a magic incantation until the end of time. 😕Examples
red
tolime
:red
toaqua
:red
tofuchsia
:aqua
tofuchsia
:lime
tofuchsia
:lime
toblue
:blue
togray
:white
toblue
:white
toblack
:The text was updated successfully, but these errors were encountered: