From c1fa1e239195b27e7ca0872ec1dc704518da8257 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Fri, 22 Mar 2024 15:12:51 +0100 Subject: [PATCH] [FIX] web_editor: prevent InvalidStateError with stressed webrtc This prevents a traceback* which happens when the webrtc connection is under signaling stress and a local rollback is triggered when the state has been set back to stable. This seems to be caused by browser bugs (both in [Firefox]() and in [Chromium]() due to an [error]() in the webrtc spec) that occur under stress. To prevent this sort of issue, a solution was provided in the form of an [implicit rollback]() on the remote description setter. This solution has recently become available everywhere (since Safari adopted it in [2022]() for desktop and iOS). This allows us to simply rely on the remote description setter to handle the rollback if needed. * Traceback: InvalidStateError: Cannot rollback local description in stable. task-3823100 closes odoo/odoo#158861 Signed-off-by: David Monjoie (dmo) --- .../static/src/js/wysiwyg/PeerToPeer.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/PeerToPeer.js b/addons/web_editor/static/src/js/wysiwyg/PeerToPeer.js index 905afb4b449..b6f2614623d 100644 --- a/addons/web_editor/static/src/js/wysiwyg/PeerToPeer.js +++ b/addons/web_editor/static/src/js/wysiwyg/PeerToPeer.js @@ -127,20 +127,11 @@ const baseNotificationMethods = { ); return; } - if (debugShowLog) console.log(`%cisOfferRacing: ${isOfferRacing}`, 'background: red;'); - - if (isOfferRacing) { - if (debugShowLog) - console.log(`%c SETREMOTEDESCRIPTION 1`, 'background: navy; color:white;'); - await Promise.all([ - pc.setLocalDescription({ type: 'rollback' }), - pc.setRemoteDescription(description), - ]); - } else { - if (debugShowLog) - console.log(`%c SETREMOTEDESCRIPTION 2`, 'background: navy; color:white;'); - await pc.setRemoteDescription(description); + if (debugShowLog) { + console.log(`%cisOfferRacing: ${isOfferRacing}`, 'background: red;'); + console.log(`%c SETREMOTEDESCRIPTION`, 'background: navy; color:white;'); } + await pc.setRemoteDescription(description); if (clientInfos.iceCandidateBuffer.length) { for (const candidate of clientInfos.iceCandidateBuffer) { await this._addIceCandidate(clientInfos, candidate);