Re: WHATWG comments re: Float16Array + HTML Canvas

Alternative proposal: Make the default readback format always be
Uint8ClampedArray.

For color space, we had the default readback color space match the canvas'
color space.

   - The plus side that a naive getImageData-then-putImageData doesn't lose
   data.
   - The minus side is that a naive application may assume all ImageDatas
   are sRGB, and get slightly-incorrect results.

For the type, I think there's a strong case for Uint8ClampedArray being the
universal default.

   - The plus side is that a naive getImageData+putImageData doesn't lose
   data.
   - The minus side is that a naive application will assume all ImageDatas
   are Uint8ClampedArray and just crash (or worse) when given data that
   floating point.

The guiding principle is "make naive use of non-default canvases work
reasonably". To think of it, defaulting to Float16Array is pretty
dangerous, and breaks this principle.

On Wed, Feb 8, 2023 at 10:08 PM Chris Needham <chris.needham@bbc.co.uk>
wrote:

> Hi Pierre,
>
> > Is there a concrete timeline for Float16Array, which would cause the
> Color CG to revisit its recommendations?
>
> Can we answer this question rather than ask Anne?
>

In some emails, someone said "maybe a year". So creating a dependency on
Float16Array puts this project on ice for a year. And that's only if
multiple browsers decide that float16 is worth staffing immediately (very
unlikely).

Of note is that WebGL and WebGPU can create floating point canvases today
(well, almost today, for WebGL), and so it will be acceptable to leave this
feature out of reach to "simpler" applications that use 2D canvas.



> Can we progress Float16Array within TC39? It's currently a stage 1
> proposal: https://github.com/tc39/proposals/blob/main/stage-1-proposals.md
>
> See https://tc39.es/process-document/ for description of their process
> stages.
>
> Here's the last discussion in TC39, from 2017:
>
>
> https://github.com/tc39/notes/blob/HEAD/meetings/2017-05/may-23.md#16ig-float16-on-typedarrays-dataview-mathhfround-for-stage-1
>
> and discission prior to that: https://esdiscuss.org/topic/float16array
>
> There were open questions, can we help answer them to move the proposal
> forward?
>
> Thanks,
>
> Chris
>
> -----Original Message-----
> From: Pierre-Anthony Lemieux <pal@sandflow.com>
> Sent: 08 February 2023 18:59
> To: public-colorweb@w3.org
> Subject: WHATWG comments re: Float16Array + HTML Canvas
>
> Good morning/evening,
>
> FYI. See the comment at [1].
>
> [1] https://github.com/whatwg/html/issues/8708#issuecomment-1423026968
>
> I suggest we reply.
>
> Below is a first pass at such a reply:
>
> """
> - the objective is to achieve bit depth greater than 8 bit in Canvas,
> which is needed for native HDR imagery, among other things. This is needed
> today.
>
> - the suggestion to add support today for Float32Array today was with the
> understanding that support for Float16Array could not be added today
> because it required a change in JS
>
> Is there a concrete timeline for Float16Array, which would cause the Color
> CG to revisit its recommendations?
> """
>
> Please provide feedback by Monday COB.
>
> Best,
>
> -- Pierre
>
>

Received on Monday, 13 February 2023 20:29:03 UTC