Bug 1783765: Make sure we clear out mUncommittedJsepSession when sRD/sLD fails in JS. r=jib,webidl,smaug

Differential Revision: https://phabricator.services.mozilla.com/D154168
This commit is contained in:
Byron Campen 2022-08-12 16:29:07 +00:00
Родитель 7556a7d769
Коммит 5af4144f3e
4 изменённых файлов: 49 добавлений и 28 удалений

Просмотреть файл

@ -1101,12 +1101,18 @@ class RTCPeerConnection {
} else {
this._sanityCheckSdp(sdp);
}
await new Promise((resolve, reject) => {
this._onSetDescriptionSuccess = resolve;
this._onSetDescriptionFailure = reject;
this._pc.setLocalDescription(this._actions[type], sdp);
});
await p;
try {
await new Promise((resolve, reject) => {
this._onSetDescriptionSuccess = resolve;
this._onSetDescriptionFailure = reject;
this._pc.setLocalDescription(this._actions[type], sdp);
});
await p;
} catch (e) {
this._pc.onSetDescriptionError();
throw e;
}
await this._pc.onSetDescriptionSuccess(type, false);
});
}
@ -1194,37 +1200,44 @@ class RTCPeerConnection {
}
this._checkClosed();
return this._chain(async () => {
if (type == "offer" && this.signalingState == "have-local-offer") {
await new Promise((resolve, reject) => {
this._onSetDescriptionSuccess = resolve;
this._onSetDescriptionFailure = reject;
this._pc.setLocalDescription(Ci.IPeerConnection.kActionRollback, "");
});
await this._pc.onSetDescriptionSuccess("rollback", false);
this._updateCanTrickle();
}
try {
if (type == "offer" && this.signalingState == "have-local-offer") {
await new Promise((resolve, reject) => {
this._onSetDescriptionSuccess = resolve;
this._onSetDescriptionFailure = reject;
this._pc.setLocalDescription(
Ci.IPeerConnection.kActionRollback,
""
);
});
await this._pc.onSetDescriptionSuccess("rollback", false);
this._updateCanTrickle();
}
if (this._closed) {
return;
}
if (this._closed) {
return;
}
const p = this._getPermission();
const haveSetRemote = (async () => {
this._sanityCheckSdp(sdp);
await new Promise((resolve, reject) => {
const p = this._getPermission();
const haveSetRemote = new Promise((resolve, reject) => {
this._onSetDescriptionSuccess = resolve;
this._onSetDescriptionFailure = reject;
this._pc.setRemoteDescription(this._actions[type], sdp);
});
})();
if (type != "rollback") {
// Do setRemoteDescription and identity validation in parallel
await this._validateIdentity(sdp);
if (type != "rollback") {
// Do setRemoteDescription and identity validation in parallel
await this._validateIdentity(sdp);
}
await p;
await haveSetRemote;
} catch (e) {
this._pc.onSetDescriptionError();
throw e;
}
await p;
await haveSetRemote;
await this._pc.onSetDescriptionSuccess(type, true);
this._updateCanTrickle();

Просмотреть файл

@ -2632,6 +2632,10 @@ void PeerConnectionImpl::DoSetDescriptionSuccessPostProcessing(
}));
}
void PeerConnectionImpl::OnSetDescriptionError() {
mUncommittedJsepSession = nullptr;
}
RTCSignalingState PeerConnectionImpl::GetSignalingState() const {
switch (mJsepSession->GetState()) {
case kJsepStateStable:

Просмотреть файл

@ -464,6 +464,8 @@ class PeerConnectionImpl final
already_AddRefed<dom::Promise> OnSetDescriptionSuccess(
dom::RTCSdpType aSdpType, bool aRemote, ErrorResult& aError);
void OnSetDescriptionError();
bool IsClosed() const;
// called when DTLS connects; we only need this once
nsresult OnAlpnNegotiated(bool aPrivacyRequested);

Просмотреть файл

@ -89,6 +89,8 @@ interface PeerConnectionImpl {
[Throws]
Promise<void> onSetDescriptionSuccess(RTCSdpType type, boolean remote);
void onSetDescriptionError();
/* Attributes */
/* This provides the implementation with the certificate it uses to
* authenticate itself. The JS side must set this before calling