Browse Source

chore: cherry-pick 5651fb858b75 from chromium (#28199)

* chore: cherry-pick 5651fb858b75 from chromium

* update patches

Co-authored-by: Electron Bot <[email protected]>
Co-authored-by: Cheng Zhao <[email protected]>
Pedro Pontes 4 years ago
parent
commit
a576c92d4b
2 changed files with 46 additions and 0 deletions
  1. 1 0
      patches/chromium/.patches
  2. 45 0
      patches/chromium/cherry-pick-5651fb858b75.patch

+ 1 - 0
patches/chromium/.patches

@@ -155,4 +155,5 @@ mediarecorder_tolerate_non-gmb_nv12_frames_for_h264.patch
 cherry-pick-6e8856624cbb.patch
 cherry-pick-b772b48067c4.patch
 cherry-pick-3910c9f5cde6.patch
+cherry-pick-5651fb858b75.patch
 cherry-pick-b3dc4c4b349d.patch

+ 45 - 0
patches/chromium/cherry-pick-5651fb858b75.patch

@@ -0,0 +1,45 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Harald Alvestrand <[email protected]>
+Date: Thu, 11 Mar 2021 18:54:23 +0000
+Subject: Iterate more carefully over DTLS transports at close
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Ensure that even if the set of DTLS transports is modified during
+callbacks called from close, the process will be well-defined.
+
+(cherry picked from commit 4f62c7bb28b0ce77b773a611c6ba02b361db1c85)
+
+Bug: chromium:1167357
+Change-Id: I712280e7382a647027912178156127831b437f75
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2639893
+Reviewed-by: Henrik Boström <[email protected]>
+Commit-Queue: Harald Alvestrand <[email protected]>
+Cr-Original-Commit-Position: refs/heads/master@{#845122}
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2752880
+Reviewed-by: Adrian Taylor <[email protected]>
+Cr-Commit-Position: refs/branch-heads/4389@{#1521}
+Cr-Branched-From: 9251c5db2b6d5a59fe4eac7aafa5fed37c139bb7-refs/heads/master@{#843830}
+
+diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
+index 1503444ac2931a4205afe990f2e2dac11206de48..5d0b7e9cbe1f3459057b50879ab88d5a2ae12c20 100644
+--- a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
++++ b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
+@@ -3438,8 +3438,14 @@ void RTCPeerConnection::CloseInternal() {
+   if (sctp_transport_) {
+     sctp_transport_->Close();
+   }
+-  for (auto& dtls_transport_iter : dtls_transports_by_native_transport_) {
+-    dtls_transport_iter.value->Close();
++  // Since Close() can trigger JS-level callbacks, iterate over a copy
++  // of the transports list.
++  auto dtls_transports_copy = dtls_transports_by_native_transport_;
++  for (auto& dtls_transport_iter : dtls_transports_copy) {
++    // Since "value" is a WeakPtr, check if it's still valid.
++    if (dtls_transport_iter.value) {
++      dtls_transport_iter.value->Close();
++    }
+   }
+ 
+   feature_handle_for_scheduler_.reset();