Bug 1548318 - find new local addrs each time we gather ICE candidates. r?bwc! draft
authorMichael Froman <mfroman@mozilla.com>
Wed, 04 Dec 2019 13:44:27 -0600
changeset 2526056 9a56c79dfaf9d8ed7f66c518eee8897a24eae00a
parent 2507441 778b6b11194c072d2603e58118aaf6959e98902f
child 2526057 af98b2faf156332474271e9b221d705374f2395c
push id462926
push usermfroman@nostrum.com
push dateTue, 10 Dec 2019 05:11:38 +0000
treeherdertry@4cd787a95fae [default view] [failures only]
reviewersbwc
bugs1548318
milestone73.0a1
Bug 1548318 - find new local addrs each time we gather ICE candidates. r?bwc! If we don't refresh the local addrs, an ICE restart due to a WiFi change will fail. Differential Revision: https://phabricator.services.mozilla.com/D55883
media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
--- a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.c
@@ -688,20 +688,16 @@ int nr_ice_set_local_addresses(nr_ice_ct
   {
     int r,_status;
     nr_local_addr local_addrs[MAXADDRS];
     nr_local_addr *addrs = 0;
     int i,addr_ct;
     nr_local_addr default_addrs[2];
     int default_addr_ct = 0;
 
-    if (ctx->local_addrs) {
-      r_log(LOG_ICE,LOG_WARNING,"ICE(%s): local addresses already set, no work to do",ctx->label);
-      ABORT(R_ALREADY);
-    }
     if (!stun_addrs || !stun_addr_ct) {
       r_log(LOG_ICE,LOG_ERR,"ICE(%s): no stun addrs provided",ctx->label);
       ABORT(R_BAD_ARGS);
     }
 
     addr_ct = MIN(stun_addr_ct, MAXADDRS);
     r_log(LOG_ICE, LOG_DEBUG, "ICE(%s): copy %d pre-fetched stun addrs", ctx->label, addr_ct);
     for (i=0; i<addr_ct; ++i) {
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -152,19 +152,16 @@ bool PeerConnectionMedia::ShouldForcePro
   proxyInfo->GetType(proxyType);
 
   return !proxyType.IsEmpty() && !proxyType.EqualsLiteral("direct");
 }
 
 nsresult PeerConnectionMedia::Init() {
   mForceProxy = ShouldForceProxy();
 
-  // setup the stun local addresses IPC async call
-  InitLocalAddrs();
-
   ConnectSignals();
   return NS_OK;
 }
 
 void PeerConnectionMedia::EnsureTransports(const JsepSession& aSession) {
   for (const auto& transceiver : aSession.GetTransceivers()) {
     if (transceiver->HasOwnTransport()) {
       mTransportHandler->EnsureProvisionalTransport(
@@ -497,16 +494,23 @@ void PeerConnectionMedia::PerformOrEnque
   } else {
     mQueuedIceCtxOperations.push_back(runnable);
   }
 }
 
 void PeerConnectionMedia::GatherIfReady() {
   ASSERT_ON_THREAD(mMainThread);
 
+  // Init local addrs here so that if we re-gather after an ICE restart
+  // resulting from changing WiFi networks, we get new local addrs.
+  // Otherwise, we would reuse the addrs from the original WiFi network
+  // and the ICE restart will fail.
+  mLocalAddrsCompleted = false;
+  InitLocalAddrs();
+
   // If we had previously queued gathering or ICE start, unqueue them
   mQueuedIceCtxOperations.clear();
   nsCOMPtr<nsIRunnable> runnable(WrapRunnable(
       RefPtr<PeerConnectionMedia>(this),
       &PeerConnectionMedia::EnsureIceGathering, GetPrefDefaultAddressOnly(),
       GetPrefObfuscateHostAddresses()));
 
   PerformOrEnqueueIceCtxOperation(runnable);