Re: [mediacapture-screen-share] mute and unmute events of MediaStreamTrack should not be fired based on user non-action (#141)

@henbos Reviewed code that tested and isolated the case where `MediaStreamTrack` `mute` event is fired at Chromium, when "Chromium tab" capture is selected.

Steps To Reproduce:

Open console, run the following code, click on the window, then move the mouse pointer back to the open console.

```
onclick = async _ => { 
  onclick = null;
  var recorder, videoTrack, stream
  stream = await navigator.mediaDevices.getDisplayMedia({video: true});
  [videoTrack] = stream.getVideoTracks();
  videoTrack.onmute = videoTrack.onunmute = videoTrack.onended = e => console.log(e.type, performance.now() - now);
  await videoTrack.applyConstraints({
    resizeMode: 'none',
    cursor: 'never',
    width: window.innerWidth * 0.7,
    height: window.innerHeight,
  });
  recorder = new MediaRecorder(stream);
  recorder.onstop = e => console.log(e);
  recorder.ondataavailable = e => { 
   if (e.data.size) { 
    console.log(URL.createObjectURL(e.data)); 
   } 
  };  
  let now = performance.now();
  recorder.start();
}
```

Tested at two separate sites, `mute` event of `MediaStreamTrack` is fired at `4171.33499996271` at MDN website and `4171.41999991145` at Screen Capture website.

If the cursor is moved to the active document unmute event is fired, then the `mute` and `unmute` event toggle in succession

```
mute 4171.33499996271
VM134:6 unmute 13353.739999933168
VM134:6 mute 16691.22499995865
VM134:6 unmute 38397.969999932684
VM134:6 mute 41735.51499994937
VM134:6 unmute 42569.71499999054
VM134:6 mute 43403.89499999583
VM134:6 unmute 45072.60499999393
VM134:6 mute 45907.00000000652
VM134:6 unmute 60099.010000005364
VM134:6 mute 60933.09499998577
VM134:6 unmute 70114.04999997467
VM134:6 mute 70947.97999993898
VM134:6 unmute 74286.1649999395
VM134:6 ended 75370.05499994848
```


-- 
GitHub Notification of comment by guest271314
Please view or discuss this issue at https://github.com/w3c/mediacapture-screen-share/issues/141#issuecomment-650477534 using your GitHub account

Received on Saturday, 27 June 2020 02:51:21 UTC