Selaa lähdekoodia

fix(strophe.jingle.js): exception on ICE config modification

If ICE config object gets modified while there's any native
PeerConnection instance holding a reference, it will cause
an exception about final object being modified.

It happens when trying to reconnect XMPP Websocket on RN and
is caused by the fact that new TURN config is fetched after
the connection is re-established.
dev1
paweldomas 5 vuotta sitten
vanhempi
commit
adc87bcffd
1 muutettua tiedostoa jossa 7 lisäystä ja 1 poistoa
  1. 7
    1
      modules/xmpp/strophe.jingle.js

+ 7
- 1
modules/xmpp/strophe.jingle.js Näytä tiedosto

@@ -149,6 +149,9 @@ export default class JingleConnectionPlugin extends ConnectionPlugin {
149 149
             logger.info(
150 150
                 `Marking session from ${fromJid
151 151
                 } as ${isP2P ? '' : '*not*'} P2P`);
152
+
153
+            const iceConfig = isP2P ? this.p2pIceConfig : this.jvbIceConfig;
154
+
152 155
             sess
153 156
                 = new JingleSessionPC(
154 157
                     $(iq).find('jingle').attr('sid'),
@@ -156,7 +159,10 @@ export default class JingleConnectionPlugin extends ConnectionPlugin {
156 159
                     fromJid,
157 160
                     this.connection,
158 161
                     this.mediaConstraints,
159
-                    isP2P ? this.p2pIceConfig : this.jvbIceConfig,
162
+
163
+                    // Makes a copy in order to prevent exception thrown on RN when either this.p2pIceConfig or
164
+                    // this.jvbIceConfig is modified and there's a PeerConnection instance holding a reference
165
+                    JSON.parse(JSON.stringify(iceConfig)),
160 166
                     isP2P,
161 167
                     /* initiator */ false);
162 168
 

Loading…
Peruuta
Tallenna