simplewebrtc / SimpleWebRTC

Simplest WebRTC ever
Other
4.65k stars 1.19k forks source link

Again: Screensharing localScreenStopped event not fired on FF #616

Open greg-man opened 7 years ago

greg-man commented 7 years ago

See #531

Issue came up again using latest simplewebrtc bundle and Firefox 55.

Seems that shouldWorkAroundFirefoxStopStream() function should apply here as well or am I missing something?

greg-man commented 7 years ago

Fixed it by returning true independent of FF version (https://github.com/andyet/SimpleWebRTC/blob/master/out/simplewebrtc.bundle.js#L7425).

function shouldWorkAroundFirefoxStopStream() {
  if (typeof window === 'undefined') {
    return false;
  }
  if (!window.navigator.mozGetUserMedia) {
    return false;
  }
  var match = window.navigator.userAgent.match(/Firefox\/(\d+)\./);
  var version = match && match.length >= 1 && parseInt(match[1], 10);
  return true; //version < 50;
}

EDIT: The following issue seems to happen randomly and is likely not affected by the _removeStream() function

Sadly FF 55 then crashes on Ubuntu 16.04 if LocalMedia._removeStream() (https://github.com/andyet/SimpleWebRTC/blob/master/out/simplewebrtc.bundle.js#L7672) is not adapted as follows (omit stream when emitting localScreenStopped event)

LocalMedia.prototype._removeStream = function (stream) {
    var idx = this.localStreams.indexOf(stream);
    if (idx > -1) {
        this.localStreams.splice(idx, 1);
        this.emit('localStreamStopped', stream);
    } else {
        idx = this.localScreens.indexOf(stream);
        if (idx > -1) {
            this.localScreens.splice(idx, 1);
            this.emit('localScreenStopped'); // omit stream
        }
    }
};

This is of no harm; as you can see at https://github.com/andyet/SimpleWebRTC/blob/master/out/simplewebrtc.bundle.js#L15713 the localScreenStopped listening routine doesn't rely on stream (any more?).

Greg