Intent to Prototype And Ship: Allow transferring ArrayBuffer into VideoFrame, AudioData, EncodedVideoChunk, EncodedAudioChunk, ImageDecoder constructors

160 views
Skip to first unread message

Eugene Zemtsov

unread,
Aug 16, 2023, 5:22:00 PM8/16/23
to blink-dev, Dale Curtis

Contact emails

ezem...@google.com

Explainer

https://gist.github.com/Djuffin/1c8fac486ca9f402be85074166e89a16

Specification

https://www.w3.org/TR/webcodecs/#dictdef-videoframeinit

Summary

This will allow detaching array buffers and using corresponding buffers inside VideoFrame, ImageDecoder, EncodedVideoChunk, EncodedAudioChunk, AudioData without a copy.


Blink component

Blink>Media>WebCodecs


TAG review

None

Risks



Interoperability and Compatibility

None



Gecko: N/A (https://www.w3.org/2023/05/30-mediawg-minutes.html#t01) Change is too small to justify this effort. The change was discussed and approved by the w3c media working group.

WebKit: N/A (https://www.w3.org/2023/05/30-mediawg-minutes.html#t01) Change is too small to justify this effort. The change was discussed and approved by the w3c media working group.

Web developers: No signals

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

None



Is this feature fully tested by web-platform-tests?

No

Flag name on chrome://flags

None

Finch feature name

None

Non-finch justification

None

Requires code in //chrome?

False

Tracking bug

https://crbug.com/1446808

Estimated milestones

Shipping on desktop120
Shipping on Android120


Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5075602045927424

--
Thanks,
Eugene Zemtsov.

Jonathan Hao

unread,
Aug 22, 2023, 5:08:24 AM8/22/23
to blink-dev, Eugene Zemtsov, Dale Curtis
Hi Eugene,

Just to double check.  Once an ArrayBuffer is transferred and detached, any further access will result in some sort of TypeError, right?

Thanks,
Jonathan

Yoav Weiss

unread,
Aug 22, 2023, 10:36:35 AM8/22/23
to blink-dev, Jonathan Hao, Eugene Zemtsov, Dale Curtis
On Tuesday, August 22, 2023 at 11:08:24 AM UTC+2 Jonathan Hao wrote:
Hi Eugene,

Just to double check.  Once an ArrayBuffer is transferred and detached, any further access will result in some sort of TypeError, right?

Thanks,
Jonathan

On Wednesday, August 16, 2023 at 10:22:00 PM UTC+1 Eugene Zemtsov wrote:


Summary

This will allow detaching array buffers and using corresponding buffers inside VideoFrame, ImageDecoder, EncodedVideoChunk, EncodedAudioChunk, AudioData without a copy.


Blink componentBlink>Media>WebCodecs

TAG reviewNone

Risks


Interoperability and Compatibility

None



Gecko: N/A (https://www.w3.org/2023/05/30-mediawg-minutes.html#t01) Change is too small to justify this effort. The change was discussed and approved by the w3c media working group.

WebKit: N/A (https://www.w3.org/2023/05/30-mediawg-minutes.html#t01) Change is too small to justify this effort. The change was discussed and approved by the w3c media working group.

I somewhat share Youenn's concerns about the API shape, but I'm not familiar with the examples this is supposed to be consistent with. Would it be possible to explore different API shapes in the explainer? (e.g. a boolean that detaches the input buffer after init would be my first choice)
Typically we defer such questions to a TAG review. I'd hate to introduce significant delay at this point, but it might be possible to expedite this specific question and get it in front of them.
 

Web developers: No signals

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

None



Is this feature fully tested by web-platform-tests?No

Flag name on chrome://flagsNone

Finch feature nameNone

Non-finch justificationNone

Requires code in //chrome?False

Tracking bughttps://crbug.com/1446808

Estimated milestonesShipping on desktop120Shipping on Android120

Link to entry on the Chrome Platform Statushttps://chromestatus.com/feature/5075602045927424

--
Thanks,
Eugene Zemtsov.

Eugene Zemtsov

unread,
Aug 22, 2023, 4:20:27 PM8/22/23
to Yoav Weiss, blink-dev, Jonathan Hao
A transfer list is consistent with the approach taken by structuredClone and postMessage
And it's already a part of the WebCodecs spec. 

--
Thanks,
Eugene Zemtsov.

Jonathan Hao

unread,
Aug 23, 2023, 6:26:57 AM8/23/23
to Eugene Zemtsov, Yoav Weiss, blink-dev
Thanks for the clarification!

Yoav Weiss

unread,
Aug 24, 2023, 3:51:44 AM8/24/23
to Jonathan Hao, Eugene Zemtsov, blink-dev
On Wed, Aug 23, 2023 at 12:26 PM Jonathan Hao <ph...@chromium.org> wrote:
Thanks for the clarification!

On Tue, Aug 22, 2023 at 9:20 PM Eugene Zemtsov <ezem...@google.com> wrote:
A transfer list is consistent with the approach taken by structuredClone and postMessage
And it's already a part of the WebCodecs spec. 

Can you clarify if this was in response to my questions or to Jonathan's?

Eugene Zemtsov

unread,
Aug 24, 2023, 12:45:42 PM8/24/23
to Yoav Weiss, Jonathan Hao, blink-dev
Can you clarify if this was in response to my questions or to Jonathan's?

Yours.
Sorry, I missed Jonathan's question.

 Once an ArrayBuffer is transferred and detached, any further access will result in some sort of TypeError, right?

Detached ArrayBuffers look like an empty ArrayBuffers. 
you can play with them using this code

let ab = new ArrayBuffer(100);
let ab2 = structuredClone(ab,  { transfer: [ab] })
ab is empty now

--
Thanks,
Eugene Zemtsov.

Alex Russell

unread,
Aug 30, 2023, 12:03:37 PM8/30/23
to blink-dev, Eugene Zemtsov, Jonathan Hao, blink-dev, Yoav Weiss
Hey Eugene,

I'm a little worried that we're debating API shape here when there hasn't been any guidance from the TAG on design consistency. Have you either asked the TAG to weigh in (didn't see a review link in the Intent) or asked Chromium (ex)TAG members to give the API a once-over?

Best,

Alex

Daniel Bratell

unread,
Aug 30, 2023, 12:19:25 PM8/30/23
to Alex Russell, blink-dev, Eugene Zemtsov, Jonathan Hao, Yoav Weiss

In addition to Alex's question, I also noticed that you answered the web-platform-tests with a "no", which is a bit unexpected to me. Is there a reason this cannot or won't be tested in web-platform-tests?

/Daniel

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/ca4852cc-e0ab-4685-99d9-84d2f8316b90n%40chromium.org.

Dale Curtis

unread,
Aug 30, 2023, 12:50:52 PM8/30/23
to Daniel Bratell, Alex Russell, blink-dev, Eugene Zemtsov, Jonathan Hao, Yoav Weiss
Alex, I assume you mean TAG's views on consistency regarding transfer ergonomics? Otherwise https://www.w3.org/TR/design-principles/#consistency is what we followed here. We have not asked, given that we felt this was a small performance improvement, with pre-existing ergonomics, and already has Media WG approval. We can certainly file a TAG request, but as you know, litigating minor features like this through TAG is unlikely to have a timely resolution.

Regarding Yoav's proposal above of a single boolean, that might make sense today where we have a single transfer, but we expect more input ArrayBuffers over time for some of these APIs, which would mean it becomes all-or-nothing for developers. E.g., we are likely to accept arrays of metadata, HDR data, etc. The boolean would mean they must transfer everything, which may lead to them making temporary copies of smaller buffers to get transfer effects on the larger ones.

Daniel, sorry, that's just an oversight in the chromestatus entry. There are tests added (here's the one for videoFrame):

- dale

Eugene Zemtsov

unread,
Aug 30, 2023, 6:14:32 PM8/30/23
to Dale Curtis, Daniel Bratell, Alex Russell, blink-dev, Jonathan Hao, Yoav Weiss
--
Thanks,
Eugene Zemtsov.

Sangwhan Moon

unread,
Sep 3, 2023, 7:32:27 AM9/3/23
to Eugene Zemtsov, Dale Curtis, Daniel Bratell, Alex Russell, blink-dev, Jonathan Hao, Yoav Weiss
Thank you for filing this. If it is urgent, I could flag it as time constrained.

On Aug 31, 2023, at 7:14, 'Eugene Zemtsov' via blink-dev <blin...@chromium.org> wrote:



Dale Curtis

unread,
Sep 5, 2023, 2:39:33 PM9/5/23
to Sangwhan Moon, Eugene Zemtsov, Daniel Bratell, Alex Russell, blink-dev, Jonathan Hao, Yoav Weiss
I wouldn't say it's urgent, but I would hope for feedback within a week or two. Thanks!

- dale

Yoav Weiss

unread,
Sep 20, 2023, 10:41:10 AM9/20/23
to Dale Curtis, Sangwhan Moon, Eugene Zemtsov, Daniel Bratell, Alex Russell, blink-dev, Jonathan Hao
LGTM1 given the consistency here with other platform APIs and the need to extend this in the future.

Chris Harrelson

unread,
Sep 20, 2023, 11:48:35 AM9/20/23
to Yoav Weiss, Dale Curtis, Sangwhan Moon, Eugene Zemtsov, Daniel Bratell, Alex Russell, blink-dev, Jonathan Hao
LGTM2

Would be great to file official vendor signals just so they know this is happening, if you're willing.

Mike Taylor

unread,
Sep 20, 2023, 11:48:59 AM9/20/23
to Chris Harrelson, Yoav Weiss, Dale Curtis, Sangwhan Moon, Eugene Zemtsov, Daniel Bratell, Alex Russell, blink-dev, Jonathan Hao
Reply all
Reply to author
Forward
0 new messages