W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > January 2020

Re: [mediacapture-fromelement] The sequence canvas.transferControlToOffscreen() followed by canvas.captureStream() does not appear to be specified (#84)

From: guest271314 via GitHub <sysbot+gh@w3.org>
Date: Tue, 14 Jan 2020 18:23:11 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issue_comment.created-574307512-1579026190-sysbot+gh@w3.org>
Chromium implements `requestFrame()` on the `MediaStreamTrack`. Firefox still implements `requestFrame()` on `MediaStream`.

Nonetheless when `autoplay` is set on an HTML `<video>` element and the `MediaStream` from `canvas.captureStream()` is set as `srcObject` of the `<video>` and `requestFrame()` is executed the `<video>` `currentTime` does not increment.

```
  <canvas style="border:1px solid green"></canvas>
  <video controls autoplay></video>
  <script>
    const canvas = document.querySelector("canvas");
    const offscreen = canvas.transferControlToOffscreen();
    const stream = canvas.captureStream(0);
    const worker = new Worker("firefoxNightlyOffscreenCanvasNotVisibleIncorrectWidthAndHeightWorker.js");
    worker.onmessage = e => {
      const {
        width, height
      } = e.data;
      const stream = canvas.captureStream();
      document.querySelector("video").srcObject = stream;
      let n = 0;
      const requestFrame = _ => {
        if (canvas.width !== width && canvas.height !== height) {
          console.assert(canvas.width === width && canvas.height === height, [width, height, canvas.width, canvas.height]);
           requestAnimationFrame(requestFrame);
        } else {
          // document.querySelector("video").currentTime remains at 0
          console.log(canvas.width === width && canvas.height === height, [width, height, canvas.width, canvas.height], {n}, document.querySelector("video").currentTime);
          stream.getVideoTracks()[0].requestFrame();
          ++n;
          requestAnimationFrame(requestFrame);
        }
      } 
      requestAnimationFrame(requestFrame);
    }
    worker.postMessage({
      offscreen
    }, [offscreen]);
</script>
```

-- 
GitHub Notification of comment by guest271314
Please view or discuss this issue at https://github.com/w3c/mediacapture-fromelement/issues/84#issuecomment-574307512 using your GitHub account
Received on Tuesday, 14 January 2020 18:23:12 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:22:36 UTC