W3C home > Mailing lists > Public > public-webrtc@w3.org > July 2019

[mediacapture-image] onframe Event (#210)

From: David Sanders via GitHub <sysbot+gh@w3.org>
Date: Thu, 11 Jul 2019 07:41:50 +0000
To: public-webrtc@w3.org
Message-ID: <issues.opened-466718950-1562830909-sysbot+gh@w3.org>
dsanders11 has just created a new issue for https://github.com/w3c/mediacapture-image:

== onframe Event ==
The current Chromium implementation of `grabFrame` waits until a new frame is available before resolving, which means if `frameRate` is 1, it may take up to 1 second for the promise to resolve.

Although the spec doesn't have anything to say on the timing of `grabFrame`, I think this is unexpected behavior, and should probably be changed in Chromium, and clarified in the spec.

However, there is a nice benefit to that behavior that I noticed: it throttles `grabFrame` for you automatically, so you can nicely use a loop with `await` on each `grabFrame` and it will run at the frame rate of the video, without needing to manage this yourself.

So, to retain this useful behavior, how about adding an `onframe` event to `ImageCapture` in the spec? It would 

This would also be flexible enough to easily create a `Promise` version which emulates the current Chromium `grabFrame` behavior:

```javascript
function waitForFrame (capturer) {
  return new Promise(resolve => {
    capturer.addEventListener('frame', event => {
      resolve(event.frame);
    }, { once: true });
  }
}
```

Please view or discuss this issue at https://github.com/w3c/mediacapture-image/issues/210 using your GitHub account
Received on Thursday, 11 July 2019 07:41:52 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:18:48 UTC