From 0cacba361f8c5daf975e12241e939ee82f29a1fa Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" <docfaraday@gmail.com> Date: Thu, 31 May 2018 11:30:19 -0500 Subject: Bug 1464079 - Bring ICE connection state change callback up to spec. r=jib, a=RyanVM WebRTC --- dom/media/PeerConnection.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'dom/media') diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index 0c3021799..d13f1d0fb 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -1445,7 +1445,10 @@ PeerConnectionObserver.prototype = { break; case "IceConnectionState": - this.handleIceConnectionStateChange(this._dompc._pc.iceConnectionState); + let connState = this._dompc._pc.iceConnectionState; + this._dompc._queueTaskWithClosedCheck(() => { + this.handleIceConnectionStateChange(connState); + }); break; case "IceGatheringState": -- cgit v1.2.3 From ce38876a4daa5170485f752d4007c8fdfbbe8ccc Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" <docfaraday@gmail.com> Date: Thu, 31 May 2018 11:30:19 -0500 Subject: Bug 1464079 - Bring ICE connection state change callback up to spec. r=jib, a=RyanVM --- dom/media/PeerConnection.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'dom/media') diff --git a/dom/media/PeerConnection.js b/dom/media/PeerConnection.js index d13f1d0fb..0569b15ae 100644 --- a/dom/media/PeerConnection.js +++ b/dom/media/PeerConnection.js @@ -516,6 +516,18 @@ RTCPeerConnection.prototype = { }; }, + // This implements the fairly common "Queue a task" logic + async _queueTaskWithClosedCheck(func) { + return new Promise(resolve => { + Services.tm.mainThread.dispatch({ run() { + if (!this._closed) { + func(); + resolve(); + } + }}, Ci.nsIThread.DISPATCH_NORMAL); + }); + }, + /** * An RTCConfiguration may look like this: * -- cgit v1.2.3