Re: [webrtc-pc] On track removal: Should you mute an already muted track? (#2506)

> Hmm, looks like it's intermittent actually. I've filed a bug.

Not intermittent. At Nightly if an image is _not_ drawn onto the `canvas` where the `MediaStream` and `MediaStreamTrack` therefrom is passed to `addTrack()` `unmute` will _**never**_ fire
```

      const pc1 = new RTCPeerConnection(),
        pc2 = new RTCPeerConnection();

      (async () => {
        try {
          const {ctx, imageData, stream} = whiteNoise();
          console.log(stream.getTracks()[0].muted);
          stream.getTracks()[0].onmute = stream.getTracks()[0].onunmute = e => {
            console.log(e.type);
          }
          pc1.addTrack(stream.getTracks()[0], stream);
          const { track, streams } = await new Promise(r => (pc2.ontrack = r));
          // uncomment below for `unmute` to be dispatched
          // ctx.putImageData(imageData, 0, 0);
          // this has no effect, probably should be a Promise, not observable
          // stream.requestFrame();
          track.onmute = e => console.log(e);
          track.onunmute = () => {
            console.log('HERE');
            video.srcObject = stream;
          };
        } catch (e) {
          console.log(e);
        }
      })();

      pc1.onicecandidate = e => pc2.addIceCandidate(e.candidate);
      pc2.onicecandidate = e => pc1.addIceCandidate(e.candidate);
      pc1.oniceconnectionstatechange = e => console.log(pc1.iceConnectionState);

      pc1.onnegotiationneeded = async e => {
        try {
          await pc1.setLocalDescription(await pc1.createOffer());
          await pc2.setRemoteDescription(pc1.localDescription);
          await pc2.setLocalDescription(await pc2.createAnswer());
          await pc1.setRemoteDescription(pc2.localDescription);
        } catch (e) {
          console.log(e);
        }
      };

      function whiteNoise(width = 160, height = 120) {
        const canvas = Object.assign(document.createElement('canvas'), {
          width,
          height,
        });
        const ctx = canvas.getContext('2d');
        const data = new Uint8ClampedArray(
          Array(canvas.width ** 2)
            .fill([0, 0, 0, 255])
            .flat()
        );

        const imageData = new ImageData(data, canvas.width);

        /*
        requestAnimationFrame(function draw() {
          ctx.putImageData(imageData, 0, 0);
          requestAnimationFrame(draw);
        });
        */
        return {ctx, imageData, stream: canvas.captureStream(0)};
      }

```


-- 
GitHub Notification of comment by guest271314
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/2506#issuecomment-616894260 using your GitHub account

Received on Tuesday, 21 April 2020 01:22:38 UTC