From 0cb2077ab314d972eb83fa5e805168a5c0a059bd Mon Sep 17 00:00:00 2001 From: Pedro Pontes Date: Wed, 13 Dec 2023 03:46:02 +0000 Subject: [PATCH] chore: cherry-pick 1 changes from Release-0-M120 (#40724) * chore: [27-x-y] cherry-pick 1 changes from Release-0-M120 * 5fde415e06f9 from chromium * chore: update patches --------- Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com> --- patches/chromium/.patches | 1 + .../chromium/cherry-pick-5fde415e06f9.patch | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 patches/chromium/cherry-pick-5fde415e06f9.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 9c59c4de6b1e9..591886ebe1909 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -136,3 +136,4 @@ crash_gpu_process_and_clear_shader_cache_when_skia_reports.patch scale_rects_properly_in_syncgetfirstrectforrange.patch fix_restore_original_resize_performance_on_macos.patch fix_font_flooding_in_dev_tools.patch +cherry-pick-5fde415e06f9.patch diff --git a/patches/chromium/cherry-pick-5fde415e06f9.patch b/patches/chromium/cherry-pick-5fde415e06f9.patch new file mode 100644 index 0000000000000..219159db1be62 --- /dev/null +++ b/patches/chromium/cherry-pick-5fde415e06f9.patch @@ -0,0 +1,73 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Guido Urdaneta +Date: Fri, 10 Nov 2023 20:46:57 +0000 +Subject: Use KeepAlive to prevent lifetime race with audio delivery + +(cherry picked from commit 186dad16ae69183f02730fb26d84e1d53f9f1b04) + +Bug: 1497984 +Change-Id: Ic22729b2ef9690203bbb09555d32238959e93a0f +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5009864 +Reviewed-by: Michael Lippautz +Commit-Queue: Guido Urdaneta +Cr-Original-Commit-Position: refs/heads/main@{#1221614} +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5018212 +Bot-Commit: Rubber Stamper +Cr-Commit-Position: refs/branch-heads/6099@{#500} +Cr-Branched-From: e6ee4500f7d6549a9ac1354f8d056da49ef406be-refs/heads/main@{#1217362} + +diff --git a/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.cc b/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.cc +index f68c265271b48f92ff67a752cf2bedac183bd2fc..a53053b12925b6aaa4fb201e7de2c00d4203bb2a 100644 +--- a/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.cc ++++ b/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.cc +@@ -142,12 +142,12 @@ bool MediaStreamAudioTrackUnderlyingSource::StartFrameDelivery() { + return false; + } + +- if (added_to_track_) { ++ if (is_connected_to_track_) { + return true; + } + + WebMediaStreamAudioSink::AddToAudioTrack(this, WebMediaStreamTrack(track_)); +- added_to_track_ = true; ++ is_connected_to_track_ = this; + return true; + } + +@@ -159,7 +159,7 @@ void MediaStreamAudioTrackUnderlyingSource::DisconnectFromTrack() { + + WebMediaStreamAudioSink::RemoveFromAudioTrack(this, + WebMediaStreamTrack(track_)); +- added_to_track_ = false; ++ is_connected_to_track_.Clear(); + track_.Clear(); + } + +diff --git a/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.h b/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.h +index 334da29c2b210f92e9ee191275651406487601c3..4e7d22959dc8947c12d9ee2bb7acd814cc4db6b3 100644 +--- a/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.h ++++ b/third_party/blink/renderer/modules/breakout_box/media_stream_audio_track_underlying_source.h +@@ -13,6 +13,7 @@ + #include "third_party/blink/renderer/modules/breakout_box/transferred_frame_queue_underlying_source.h" + #include "third_party/blink/renderer/modules/modules_export.h" + #include "third_party/blink/renderer/platform/heap/prefinalizer.h" ++#include "third_party/blink/renderer/platform/heap/self_keep_alive.h" + + namespace blink { + +@@ -80,10 +81,13 @@ class MODULES_EXPORT MediaStreamAudioTrackUnderlyingSource + const Member media_stream_track_processor_; + + Member track_; +- bool added_to_track_ = false; + + std::unique_ptr buffer_pool_; + ++ // This prevents collection of this object while it is still connected to a ++ // platform MediaStreamTrack. ++ SelfKeepAlive is_connected_to_track_; ++ + SEQUENCE_CHECKER(sequence_checker_); + }; +