This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25643 - createImageBitmap() options: color space handling
Summary: createImageBitmap() options: color space handling
Status: RESOLVED MOVED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 enhancement
Target Milestone: Needs Impl Interest
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL:
Whiteboard:
Keywords:
Depends on: 25639
Blocks:
  Show dependency treegraph
 
Reported: 2014-05-09 21:18 UTC by Ian 'Hixie' Hickson
Modified: 2016-03-16 14:14 UTC (History)
7 users (show)

See Also:


Attachments

Description Ian 'Hixie' Hickson 2014-05-09 21:18:43 UTC
This bug proposes the following new option for createImageBitmap()'s configuration dictionary (as proposed in bug 25639):

  ColorSpaceKind colorSpace = 'honour' // how to handle color space metadata
    // ColorSpaceKind:
    //   'honor' - process the color space metadata as defined in the format's
    //       specification, converting the image to the sRGB space. In the
    //       absence of image color space metadata, acts as 'strip'
    //   'strip' - ignore color space metadata, treat image data as sRGB

See also:
   http://wiki.whatwg.org/wiki/ImageBitmap_Options
   http://lists.w3.org/Archives/Public/public-whatwg-archive/2014May/0067.html
Comment 1 Kenneth Russell 2014-05-15 06:36:49 UTC
For the record, the WebGL working group would like to see this option in the spec.
Comment 2 Noel Gordon 2014-05-15 06:43:29 UTC
I would like to see better color correction and control options for web users, and canvas users.  I wondered how this proposal would interwork with CSS http://dev.w3.org/csswg/css-color-correction ?
Comment 3 Ian 'Hixie' Hickson 2014-05-15 18:04:52 UTC
This would be related to the 'color-correction' CSS property in that draft as currently specified, except that this would apply to images handled by scripts (to which CSS doesn't apply), while the property would be related to images handled by the CSS system (e.g. <img>s during composition).

Also, this bug proposed an option to ignore colour space information, while the proposed property provides a way to control the default colour space information for images that lack any such information, so they're kind of orthogonal. For images without colour space data, 'honor' and 'strip' both result in sRGB being assumed, whereas the property lets you decide between sRGB and some unknown other value chosen by the UA (probably also sRGB). For images with colour space data, the property always honours it, whereas this property lets you decide whether to honour that data or ignore it and treat it as sRGB data.
Comment 4 Kenneth Russell 2014-05-15 20:18:17 UTC
Additionally, there is desire to implement this feature on the Google Chrome team. Having it specified would make it easier to motivate adding it.
Comment 5 Justin Novosad 2014-05-16 13:50:15 UTC
For this to be useful, we need canvas backing stores to be in sRGB color space, which is not currently the case.  AFAICT, the specification does not impose a colorspace.  I am guessing this is deliberate since behavior is currently not interoperable in this respect.  We should probably solve that problem first. Right now in Chrome canvas pixels are in output-referred colorspace, which is good for performance because it means no colorspace conversion is required when compositing the canvas onto the page. I believe there will be a desire to maintain this way of doing things for performance-critical applications.  With that in mind there should probably be 'display' ColorSpaceKind (which reflects current behavior).

When an imageBitmap is being create to be used with a given canvas rendering context, it would make sense to have a read-only colorSpace attribute on CRC2D to be able to do:
{colorSpace: context.colorSpace}
Comment 6 Noel Gordon 2014-05-16 14:19:27 UTC
"output-referred colorspace", meaning the users screen color space?
Comment 7 Justin Novosad 2014-05-16 14:52:30 UTC
(In reply to Noel Gordon from comment #6)
> "output-referred colorspace", meaning the users screen color space?

Yes. The screen or whatever the output device may be.  "output-referred" is the standard term defined in ISO 22028-1
Comment 8 Kenneth Russell 2014-05-16 18:14:30 UTC
In recent discussions with Apple Computer I understood (perhaps mistakenly) that as of Mac OS X 10.9, Safari is actually using the sRGB color space for all of its rendering. Apparently there were concerns about compatibility with existing web apps, but surprisingly, none broke during this transition. This should be confirmed with a representative from Apple, but it gives hope that other implementations can make the transition to using the sRGB color space for the canvas's backing store.
Comment 9 Justin Novosad 2014-05-16 19:38:34 UTC
(In reply to Kenneth Russell from comment #8)
> In recent discussions with Apple Computer I understood (perhaps mistakenly)
> that as of Mac OS X 10.9, Safari is actually using the sRGB color space for
> all of its rendering. Apparently there were concerns about compatibility
> with existing web apps, but surprisingly, none broke during this transition.
> This should be confirmed with a representative from Apple, but it gives hope
> that other implementations can make the transition to using the sRGB color
> space for the canvas's backing store.

I would not expect such a change to break anything, but it could regress performance.  Maybe that concern is obsolete today, with GPUs being everywhere. I guess we don't need to wait for the spec to change to fix this in implementations, since the behavior is not defined in the spec.
Comment 10 Dean Jackson 2014-05-16 22:02:18 UTC
(In reply to Justin Novosad from comment #9)
> (In reply to Kenneth Russell from comment #8)
> > In recent discussions with Apple Computer I understood (perhaps mistakenly)
> > that as of Mac OS X 10.9, Safari is actually using the sRGB color space for
> > all of its rendering. Apparently there were concerns about compatibility
> > with existing web apps, but surprisingly, none broke during this transition.
> > This should be confirmed with a representative from Apple, but it gives hope
> > that other implementations can make the transition to using the sRGB color
> > space for the canvas's backing store.
> 
> I would not expect such a change to break anything,

It does: plugins. Since all other browsers until Safari on OS X 10.9 were using the device color space, plugins used device color space. Now that Safari is using sRGB, we don't color match to plugins like Flash.

There is also no API for the browser to tell a plugin that it is using sRGB.

However, breaking is the right thing to do here. When other browsers start using sRGB, plugins will too.

Another thing that is possibly problematic is video. If the video goes through a plugin, you hit the problem above. If you implement video natively, you need to make sure that it is using sRGB, or respecting the video's embedded profile.

You might not notice it as much on video though. You're more likely to notice something is wrong when you are matching a color in the page, defined by CSS. E.g. a flash animation embedded into a page but looks like regular page content.

Then there are filters, which are defined to operate in a linear space. The spec defines how to do the input and output there. I think maybe WebGL should do the same.

> but it could regress
> performance.  Maybe that concern is obsolete today, with GPUs being
> everywhere. I guess we don't need to wait for the spec to change to fix this
> in implementations, since the behavior is not defined in the spec.

FWIW we didn't notice a significant regression, but we (Safari) were lucky in that our graphics system did much of the hard work for us.