Skip to content

Commit a68e328

Browse files
chore: cherry-pick 5 changes from Release-2-M114, Release-1-M110 and Release-0-M110 (#38789)
* chore: [22-x-y] cherry-pick 1 changes from Release-2-M114 * 2e76270cf65e from v8 * chore: update patches * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
1 parent 047f474 commit a68e328

9 files changed

Lines changed: 287 additions & 13 deletions

patches/chromium/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,4 @@ cherry-pick-ea1cd76358e0.patch
163163
cherry-pick-48785f698b1c.patch
164164
m108-lts_return_after_readycommitnavigation_call_in_commiterrorpage.patch
165165
m114_merge_fix_a_crash_caused_by_calling_trace_event.patch
166+
base_do_not_use_va_args_twice_in_asprintf.patch
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Benoit Lize <lizeb@chromium.org>
3+
Date: Fri, 9 Jun 2023 17:59:08 +0000
4+
Subject: Do not use va_args twice in asprintf()
5+
6+
(cherry picked from commit 3cff0cb19a6d01cbdd9932f43dabaaeda9c0330a)
7+
8+
Bug: 1450536
9+
Change-Id: Ib34d96935278869a63897f9a1c66afc98865d90f
10+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4579347
11+
Reviewed-by: Egor Pasko <pasko@chromium.org>
12+
Commit-Queue: Benoit Lize <lizeb@chromium.org>
13+
Cr-Original-Commit-Position: refs/heads/main@{#1151796}
14+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4604070
15+
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
16+
Cr-Commit-Position: refs/branch-heads/5735@{#1224}
17+
Cr-Branched-From: 2f562e4ddbaf79a3f3cb338b4d1bd4398d49eb67-refs/heads/main@{#1135570}
18+
19+
diff --git a/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h b/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h
20+
index 621873126602463a09efca1bf1548ed10910d323..de2af6d7d54e254b9e7b8264b53d30a338fb13e8 100644
21+
--- a/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h
22+
+++ b/base/allocator/partition_allocator/shim/allocator_shim_override_linker_wrapped_symbols.h
23+
@@ -123,13 +123,21 @@ SHIM_ALWAYS_EXPORT char* __wrap_getcwd(char* buffer, size_t size) {
24+
SHIM_ALWAYS_EXPORT int __wrap_vasprintf(char** strp,
25+
const char* fmt,
26+
va_list va_args) {
27+
+ // There are cases where we need to use the list of arguments twice, namely
28+
+ // when the original buffer is too small. It is not allowed to walk the list
29+
+ // twice, so make a copy for the second invocation of vsnprintf().
30+
+ va_list va_args_copy;
31+
+ va_copy(va_args_copy, va_args);
32+
+
33+
constexpr int kInitialSize = 128;
34+
*strp = static_cast<char*>(
35+
malloc(kInitialSize)); // Our malloc() doesn't return nullptr.
36+
37+
int actual_size = vsnprintf(*strp, kInitialSize, fmt, va_args);
38+
- if (actual_size < 0)
39+
+ if (actual_size < 0) {
40+
+ va_end(va_args_copy);
41+
return actual_size;
42+
+ }
43+
*strp =
44+
static_cast<char*>(realloc(*strp, static_cast<size_t>(actual_size + 1)));
45+
46+
@@ -139,9 +147,14 @@ SHIM_ALWAYS_EXPORT int __wrap_vasprintf(char** strp,
47+
//
48+
// This is very lightly used in Chromium in practice, see crbug.com/116558 for
49+
// details.
50+
- if (actual_size >= kInitialSize)
51+
- return vsnprintf(*strp, static_cast<size_t>(actual_size + 1), fmt, va_args);
52+
-
53+
+ if (actual_size >= kInitialSize) {
54+
+ int ret = vsnprintf(*strp, static_cast<size_t>(actual_size + 1), fmt,
55+
+ va_args_copy);
56+
+ va_end(va_args_copy);
57+
+ return ret;
58+
+ }
59+
+
60+
+ va_end(va_args_copy);
61+
return actual_size;
62+
}
63+
64+
diff --git a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc
65+
index 6caf9d6ffe0db92602ac1e448f45da422e077c2c..57d36f722e1aa747cda3a808104cc108147552c1 100644
66+
--- a/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc
67+
+++ b/base/allocator/partition_allocator/shim/allocator_shim_unittest.cc
68+
@@ -706,6 +706,28 @@ TEST_F(AllocatorShimTest, InterceptVasprintf) {
69+
// Should not crash.
70+
}
71+
72+
+TEST_F(AllocatorShimTest, InterceptLongVasprintf) {
73+
+ char* str = nullptr;
74+
+ const char* lorem_ipsum =
75+
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. "
76+
+ "Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, "
77+
+ "ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula "
78+
+ "massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci "
79+
+ "nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit "
80+
+ "amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat "
81+
+ "in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero "
82+
+ "pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo "
83+
+ "in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue "
84+
+ "blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus "
85+
+ "et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed "
86+
+ "pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales "
87+
+ "hendrerit.";
88+
+ int err = asprintf(&str, "%s", lorem_ipsum);
89+
+ EXPECT_EQ(err, static_cast<int>(strlen(lorem_ipsum)));
90+
+ EXPECT_TRUE(str);
91+
+ free(str);
92+
+}
93+
+
94+
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
95+
96+
#endif // BUILDFLAG(IS_ANDROID)

patches/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@
2727

2828
"src/electron/patches/skia": "src/third_party/skia",
2929

30-
"src/electron/patches/dawn": "src/third_party/dawn"
30+
"src/electron/patches/dawn": "src/third_party/dawn",
31+
32+
"src/electron/patches/webrtc": "src/third_party/webrtc"
3133
}

patches/v8/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ merged_ic_fix_store_handler_selection_for_arguments_objects.patch
2121
cherry-pick-73af1a19a901.patch
2222
merged_regexp_fix_clobbered_register_in_global_unicode_special.patch
2323
m108-lts_api_fix_v8_object_setaccessorproperty.patch
24+
cherry-pick-2e76270cf65e.patch
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Shu-yu Guo <syg@chromium.org>
3+
Date: Mon, 5 Jun 2023 16:05:52 -0700
4+
Subject: Merged: Check for encoding when appending in string builder
5+
6+
Fixed: chromium:1450114
7+
(cherry picked from commit a7e2bef27b72f187a7dcdf95714df686f56d9e0b)
8+
9+
Change-Id: I5838383b6b12d137e84c8a36863ef88000e85c76
10+
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4604652
11+
Reviewed-by: Igor Sheludko <ishell@chromium.org>
12+
Cr-Commit-Position: refs/branch-heads/11.4@{#41}
13+
Cr-Branched-From: 8a8a1e7086dacc426965d3875914efa66663c431-refs/heads/11.4.183@{#1}
14+
Cr-Branched-From: 5483d8e816e0bbce865cbbc3fa0ab357e6330bab-refs/heads/main@{#87241}
15+
16+
diff --git a/src/strings/string-builder.cc b/src/strings/string-builder.cc
17+
index 9d1e3a95746b47b99c15f18ec593549d79e10b8c..c7e98e55763aba2d64f4070e25759489f850f589 100644
18+
--- a/src/strings/string-builder.cc
19+
+++ b/src/strings/string-builder.cc
20+
@@ -306,12 +306,21 @@ bool IncrementalStringBuilder::CanAppendByCopy(Handle<String> string) {
21+
void IncrementalStringBuilder::AppendStringByCopy(Handle<String> string) {
22+
DCHECK(CanAppendByCopy(string));
23+
24+
- Handle<SeqOneByteString> part =
25+
- Handle<SeqOneByteString>::cast(current_part());
26+
{
27+
DisallowGarbageCollection no_gc;
28+
- String::WriteToFlat(*string, part->GetChars(no_gc) + current_index_, 0,
29+
- string->length());
30+
+ if (encoding_ == String::ONE_BYTE_ENCODING) {
31+
+ String::WriteToFlat(
32+
+ *string,
33+
+ Handle<SeqOneByteString>::cast(current_part())->GetChars(no_gc) +
34+
+ current_index_,
35+
+ 0, string->length());
36+
+ } else {
37+
+ String::WriteToFlat(
38+
+ *string,
39+
+ Handle<SeqTwoByteString>::cast(current_part())->GetChars(no_gc) +
40+
+ current_index_,
41+
+ 0, string->length());
42+
+ }
43+
}
44+
current_index_ += string->length();
45+
DCHECK(current_index_ <= part_length_);

patches/webrtc/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
cherry-pick-e0efbd45ea74.patch
22
cherry-pick-218b56e51638.patch
3+
m114_move_transceiver_iteration_loop_over_to_the_signaling_thread.patch

patches/webrtc/cherry-pick-218b56e51638.patch

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 218b56e516386cd57c7513197528c3124bcd7ef3 Mon Sep 17 00:00:00 2001
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: Alexander Cooper <alcooper@chromium.org>
3-
Date: Wed, 08 Feb 2023 14:16:01 -0800
4-
Subject: [PATCH] Fix Destruction inside WGC Callback
3+
Date: Wed, 8 Feb 2023 14:16:01 -0800
4+
Subject: Fix Destruction inside WGC Callback
55

66
If we are notified of the destruction of the window before a
77
CaptureFrame call can fail, then we may end up attempting to destroy the
@@ -29,13 +29,12 @@ Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/293246
2929
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
3030
Cr-Commit-Position: refs/branch-heads/5481@{#5}
3131
Cr-Branched-From: 2e1a9a4ae0234d4b1ea7a6fd4188afa1fb20379d-refs/heads/main@{#38901}
32-
---
3332

3433
diff --git a/modules/desktop_capture/win/wgc_capture_session.cc b/modules/desktop_capture/win/wgc_capture_session.cc
35-
index e165291..ea5565c 100644
34+
index 831257b4d476d674303f835f6002b22bf809a772..20045b6d1d1250fc9b634e51fe3875b484d6c397 100644
3635
--- a/modules/desktop_capture/win/wgc_capture_session.cc
3736
+++ b/modules/desktop_capture/win/wgc_capture_session.cc
38-
@@ -397,17 +397,14 @@
37+
@@ -388,17 +388,14 @@ HRESULT WgcCaptureSession::OnItemClosed(WGC::IGraphicsCaptureItem* sender,
3938

4039
RTC_LOG(LS_INFO) << "Capture target has been closed.";
4140
item_closed_ = true;

patches/webrtc/cherry-pick-e0efbd45ea74.patch

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
From e0efbd45ea7421fb944c7343254ac5dc22bee541 Mon Sep 17 00:00:00 2001
2-
From: Henrik Boström <hbos@webrtc.org>
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Henrik=20Bostr=C3=B6m?= <hbos@webrtc.org>
33
Date: Fri, 20 Jan 2023 10:48:31 +0100
4-
Subject: [PATCH] [Merge-110] [Stats] Handle the case of missing certificates.
4+
Subject: =?UTF-8?q?=C2=A0[Stats]=20Handle=20the=20case=20of=20missing=20ce?=
5+
=?UTF-8?q?rtificates.?=
6+
MIME-Version: 1.0
7+
Content-Type: text/plain; charset=UTF-8
8+
Content-Transfer-Encoding: 8bit
59

610
Certificates being missing is a sign of a bug (e.g. webrtc:14844, to be
711
fixed separately) which is why we have a DCHECK. But this DCHECK does
@@ -22,13 +26,12 @@ Cr-Original-Commit-Position: refs/heads/main@{#39159}
2226
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/291380
2327
Cr-Commit-Position: refs/branch-heads/5481@{#2}
2428
Cr-Branched-From: 2e1a9a4ae0234d4b1ea7a6fd4188afa1fb20379d-refs/heads/main@{#38901}
25-
---
2629

2730
diff --git a/pc/rtc_stats_collector.cc b/pc/rtc_stats_collector.cc
28-
index d500a7b..1d88566 100644
31+
index ff7e334169da41c400d94387527734362d5dbeaa..c16e9ac7eaade4785f16afa46b2051f338095ca3 100644
2932
--- a/pc/rtc_stats_collector.cc
3033
+++ b/pc/rtc_stats_collector.cc
31-
@@ -2192,16 +2192,17 @@
34+
@@ -2197,16 +2197,17 @@ void RTCStatsCollector::ProduceTransportStats_n(
3235
// exist.
3336
const auto& certificate_stats_it =
3437
transport_cert_stats.find(transport_name);
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Tommi <tommi@webrtc.org>
3+
Date: Thu, 1 Jun 2023 16:08:52 +0200
4+
Subject: Move transceiver iteration loop over to the signaling thread.
5+
6+
This is required for ReportTransportStats since iterating over the
7+
transceiver list from the network thread is not safe.
8+
9+
(cherry picked from commit dba22d31909298161318e00d43a80cdb0abc940f)
10+
11+
No-Try: true
12+
Bug: chromium:1446274, webrtc:12692
13+
Change-Id: I7c514df9f029112c4b1da85826af91217850fb26
14+
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/307340
15+
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
16+
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
17+
Cr-Original-Commit-Position: refs/heads/main@{#40197}
18+
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/308001
19+
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
20+
Cr-Commit-Position: refs/branch-heads/5735@{#3}
21+
Cr-Branched-From: df7df199abd619e75b9f1d9a7e12fc3f3f748775-refs/heads/main@{#39949}
22+
23+
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
24+
index 4615ce5a2c413dba798c3f9f8f7d4c1ae78bf9af..62179cd44c57dc6d808579353b398412db5e1ed6 100644
25+
--- a/pc/peer_connection.cc
26+
+++ b/pc/peer_connection.cc
27+
@@ -716,9 +716,6 @@ JsepTransportController* PeerConnection::InitializeTransportController_n(
28+
transport_controller_->SubscribeIceConnectionState(
29+
[this](cricket::IceConnectionState s) {
30+
RTC_DCHECK_RUN_ON(network_thread());
31+
- if (s == cricket::kIceConnectionConnected) {
32+
- ReportTransportStats();
33+
- }
34+
signaling_thread()->PostTask(
35+
SafeTask(signaling_thread_safety_.flag(), [this, s]() {
36+
RTC_DCHECK_RUN_ON(signaling_thread());
37+
@@ -2372,6 +2369,20 @@ void PeerConnection::OnTransportControllerConnectionState(
38+
case cricket::kIceConnectionConnected:
39+
RTC_LOG(LS_INFO) << "Changing to ICE connected state because "
40+
"all transports are writable.";
41+
+ {
42+
+ std::vector<RtpTransceiverProxyRefPtr> transceivers;
43+
+ if (ConfiguredForMedia()) {
44+
+ transceivers = rtp_manager()->transceivers()->List();
45+
+ }
46+
+
47+
+ network_thread()->PostTask(
48+
+ SafeTask(network_thread_safety_,
49+
+ [this, transceivers = std::move(transceivers)] {
50+
+ RTC_DCHECK_RUN_ON(network_thread());
51+
+ ReportTransportStats(std::move(transceivers));
52+
+ }));
53+
+ }
54+
+
55+
SetIceConnectionState(PeerConnectionInterface::kIceConnectionConnected);
56+
NoteUsageEvent(UsageEvent::ICE_STATE_CONNECTED);
57+
break;
58+
@@ -2701,20 +2712,18 @@ void PeerConnection::OnTransportControllerGatheringState(
59+
}
60+
61+
// Runs on network_thread().
62+
-void PeerConnection::ReportTransportStats() {
63+
+void PeerConnection::ReportTransportStats(
64+
+ std::vector<RtpTransceiverProxyRefPtr> transceivers) {
65+
TRACE_EVENT0("webrtc", "PeerConnection::ReportTransportStats");
66+
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
67+
std::map<std::string, std::set<cricket::MediaType>>
68+
media_types_by_transport_name;
69+
- if (ConfiguredForMedia()) {
70+
- for (const auto& transceiver :
71+
- rtp_manager()->transceivers()->UnsafeList()) {
72+
- if (transceiver->internal()->channel()) {
73+
- std::string transport_name(
74+
- transceiver->internal()->channel()->transport_name());
75+
- media_types_by_transport_name[transport_name].insert(
76+
- transceiver->media_type());
77+
- }
78+
+ for (const auto& transceiver : transceivers) {
79+
+ if (transceiver->internal()->channel()) {
80+
+ std::string transport_name(
81+
+ transceiver->internal()->channel()->transport_name());
82+
+ media_types_by_transport_name[transport_name].insert(
83+
+ transceiver->media_type());
84+
}
85+
}
86+
87+
diff --git a/pc/peer_connection.h b/pc/peer_connection.h
88+
index 36a9d2ac743a81e2c4ac8b4abd73d2fd40c3dd40..ea221e697322bd8b8c161edada7a448a68fa7f68 100644
89+
--- a/pc/peer_connection.h
90+
+++ b/pc/peer_connection.h
91+
@@ -563,7 +563,8 @@ class PeerConnection : public PeerConnectionInternal,
92+
93+
// Invoked when TransportController connection completion is signaled.
94+
// Reports stats for all transports in use.
95+
- void ReportTransportStats() RTC_RUN_ON(network_thread());
96+
+ void ReportTransportStats(std::vector<RtpTransceiverProxyRefPtr> transceivers)
97+
+ RTC_RUN_ON(network_thread());
98+
99+
// Gather the usage of IPv4/IPv6 as best connection.
100+
static void ReportBestConnectionState(const cricket::TransportStats& stats);
101+
diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc
102+
index 19cc6ce3cfc8b8b38d45f5df9c28fe6dd01572f5..da8a53ef5d91c9c14dc6f42a10d176c7f6089ada 100644
103+
--- a/pc/peer_connection_integrationtest.cc
104+
+++ b/pc/peer_connection_integrationtest.cc
105+
@@ -1831,6 +1831,10 @@ TEST_P(PeerConnectionIntegrationTest,
106+
EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
107+
callee()->ice_connection_state(), kDefaultTimeout);
108+
109+
+ // Part of reporting the stats will occur on the network thread, so flush it
110+
+ // before checking NumEvents.
111+
+ SendTask(network_thread(), [] {});
112+
+
113+
EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(
114+
"WebRTC.PeerConnection.CandidatePairType_UDP",
115+
webrtc::kIceCandidatePairHostNameHostName));
116+
@@ -1959,6 +1963,10 @@ TEST_P(PeerConnectionIntegrationIceStatesTest, MAYBE_VerifyBestConnection) {
117+
EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
118+
callee()->ice_connection_state(), kDefaultTimeout);
119+
120+
+ // Part of reporting the stats will occur on the network thread, so flush it
121+
+ // before checking NumEvents.
122+
+ SendTask(network_thread(), [] {});
123+
+
124+
// TODO(bugs.webrtc.org/9456): Fix it.
125+
const int num_best_ipv4 = webrtc::metrics::NumEvents(
126+
"WebRTC.PeerConnection.IPMetrics", webrtc::kBestConnections_IPv4);

0 commit comments

Comments
 (0)