Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Add PreferredAudioOutputDeviceManager implementation. [chromium/src : main]

3 views
Skip to first unread message

Sunggook Chue (Gerrit)

unread,
Jun 27, 2024, 9:09:13 PM6/27/24
to Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
Attention needed from Olga Sharonova

Sunggook Chue added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Sunggook Chue . resolved

Thanks for reviewing!

Open in Gerrit

Related details

Attention is currently required from:
  • Olga Sharonova
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Review
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
Gerrit-Change-Number: 5664173
Gerrit-PatchSet: 1
Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
Gerrit-Reviewer: Olga Sharonova <ol...@google.com>
Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
Gerrit-Attention: Olga Sharonova <ol...@google.com>
Gerrit-Comment-Date: Fri, 28 Jun 2024 01:09:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Olga Sharonova (Gerrit)

unread,
Jun 28, 2024, 4:22:08 AM6/28/24
to Sunggook Chue, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
Attention needed from Olga Sharonova and Sunggook Chue

Olga Sharonova added 8 comments

File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
Line 92, Patchset 1 (Latest): std::string preferred_sin_id;
Olga Sharonova . unresolved

preferred_sink_id

Line 59, Patchset 1 (Latest): AudioOutputDeviceSwitcher* broker,
Olga Sharonova . unresolved

It's not a broker, it's AudioOutputDeviceSwitcher - let's not make leaky abstractions by disclosing implementation details via names.

Line 29, Patchset 1 (Latest):// streaming is active. The cached sink id will be used to set the
// preferred sink id for the audio service when the audio service is started.
Olga Sharonova . unresolved

I don't quite understand this part.

Line 28, Patchset 1 (Latest):// forwards the request to the corresponding active audio controler if
Olga Sharonova . unresolved

There is no concept of audio controller at this layer, it's deep in the audio service.

Line 28, Patchset 1 (Latest):// forwards the request to the corresponding active audio controler if
Olga Sharonova . unresolved

"controler" is a possible misspelling of "controller".

Please fix.

Line 27, Patchset 1 (Latest):// It caches the preferred sink id with each top RenderFrameHost ojbect and
Olga Sharonova . unresolved

"ojbect" is a possible misspelling of "object".

Please fix.

File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
Line 200, Patchset 1 (Latest): weak_ptr_factory_.GetWeakPtr(), broker,
Olga Sharonova . unresolved

Which thread PreferredAudioOutputDeviceManager is destroyed on?
weak_ptr can't be used on IO thread, if the PreferredAudioOutputDeviceManager is destroyed on UI thread (see base/memory/weak_ptr.h)

File third_party/blink/public/mojom/mediastream/media_devices.mojom
Line 148, Patchset 1 (Latest): SetPreferredSinkId(string sink_id) => (media.mojom.OutputDeviceStatus status);
Olga Sharonova . unresolved

Why this is a part of this CL?

Open in Gerrit

Related details

Attention is currently required from:
  • Olga Sharonova
  • Sunggook Chue
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
    Gerrit-Change-Number: 5664173
    Gerrit-PatchSet: 1
    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@google.com>
    Gerrit-CC: Olga Sharonova <ol...@chromium.org>
    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Attention: Olga Sharonova <ol...@google.com>
    Gerrit-Comment-Date: Fri, 28 Jun 2024 08:21:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Sunggook Chue (Gerrit)

    unread,
    Jun 28, 2024, 5:09:01 PM6/28/24
    to Olga Sharonova, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Olga Sharonova and Olga Sharonova

    Sunggook Chue added 9 comments

    Patchset-level comments
    File-level comment, Patchset 2 (Latest):
    Sunggook Chue . resolved

    addressed and replied comments, thanks.

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
    Line 92, Patchset 1: std::string preferred_sin_id;
    Olga Sharonova . resolved

    preferred_sink_id

    Sunggook Chue

    Done

    Line 59, Patchset 1: AudioOutputDeviceSwitcher* broker,
    Olga Sharonova . resolved

    It's not a broker, it's AudioOutputDeviceSwitcher - let's not make leaky abstractions by disclosing implementation details via names.

    Sunggook Chue

    Done

    Line 29, Patchset 1:// streaming is active. The cached sink id will be used to set the

    // preferred sink id for the audio service when the audio service is started.
    Olga Sharonova . resolved

    I don't quite understand this part.

    Sunggook Chue

    Done

    Line 28, Patchset 1:// forwards the request to the corresponding active audio controler if
    Olga Sharonova . resolved

    There is no concept of audio controller at this layer, it's deep in the audio service.

    Sunggook Chue

    Done

    Line 28, Patchset 1:// forwards the request to the corresponding active audio controler if
    Olga Sharonova . resolved

    "controler" is a possible misspelling of "controller".

    Please fix.

    Sunggook Chue

    Done

    Line 27, Patchset 1:// It caches the preferred sink id with each top RenderFrameHost ojbect and
    Olga Sharonova . resolved

    "ojbect" is a possible misspelling of "object".

    Please fix.

    Sunggook Chue

    Done

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
    Line 200, Patchset 1: weak_ptr_factory_.GetWeakPtr(), broker,
    Olga Sharonova . unresolved

    Which thread PreferredAudioOutputDeviceManager is destroyed on?
    weak_ptr can't be used on IO thread, if the PreferredAudioOutputDeviceManager is destroyed on UI thread (see base/memory/weak_ptr.h)

    Sunggook Chue

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    I don't find weak_ptr (WeakPtr) can't be on IO thread although it enforce use of same thread sequence.

    PreferredAudioOutputDeviceManager lifetime belongs MediaStreamManager that also has VideoCaptureManager, which has VideoCaptureController.

    VideoCaptureController is also created and destroyed like PreferredAudioOutputDeviceManager, and it is WeakPtrFactory.

    Can you point out any guideline, i might missed that?

    File third_party/blink/public/mojom/mediastream/media_devices.mojom
    Line 148, Patchset 1: SetPreferredSinkId(string sink_id) => (media.mojom.OutputDeviceStatus status);
    Olga Sharonova . resolved

    Why this is a part of this CL?

    Sunggook Chue

    PreferredAudioOutputDeviceManager::SetPreferredSinkId function needs 'SetPreferredSinkIdCallback', which come from this.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Olga Sharonova
    • Olga Sharonova
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
    Gerrit-Change-Number: 5664173
    Gerrit-PatchSet: 2
    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@google.com>
    Gerrit-CC: Olga Sharonova <ol...@chromium.org>
    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Olga Sharonova <ol...@google.com>
    Gerrit-Comment-Date: Fri, 28 Jun 2024 21:08:49 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Sharonova (Gerrit)

    unread,
    Jul 1, 2024, 5:17:54 AM7/1/24
    to Sunggook Chue, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Olga Sharonova and Sunggook Chue

    Olga Sharonova added 3 comments

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
    Line 30, Patchset 2 (Latest):// default audio output device
    Olga Sharonova . unresolved

    .

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
    Line 200, Patchset 1: weak_ptr_factory_.GetWeakPtr(), broker,
    Olga Sharonova . unresolved

    Which thread PreferredAudioOutputDeviceManager is destroyed on?
    weak_ptr can't be used on IO thread, if the PreferredAudioOutputDeviceManager is destroyed on UI thread (see base/memory/weak_ptr.h)

    Sunggook Chue

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    I don't find weak_ptr (WeakPtr) can't be on IO thread although it enforce use of same thread sequence.

    PreferredAudioOutputDeviceManager lifetime belongs MediaStreamManager that also has VideoCaptureManager, which has VideoCaptureController.

    VideoCaptureController is also created and destroyed like PreferredAudioOutputDeviceManager, and it is WeakPtrFactory.

    Can you point out any guideline, i might missed that?

    Olga Sharonova

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    VideoCaptureManager is refcounted, so it's unknown on which thread it is destroyed. Also, it does not seem to use weak pointers?
    VideoCaptureController is the one who uses weak pointers, and not necessarily correctly, since it also seems to be refcounted. I don't know what guarantees the correctness there (probably nothing), we may need ask the authors of the code.

    Also, media stream manager does not seem to be destroyed on IO thread, rather IO thread is destroyed before: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/media_stream_manager.cc;l=1643;drc=7b232da0f22e8cdf555d43c52b6491baeb87f729;bpv=1;bpt=1

    Guido knows this part better.

    File third_party/blink/public/mojom/mediastream/media_devices.mojom
    Line 148, Patchset 1: SetPreferredSinkId(string sink_id) => (media.mojom.OutputDeviceStatus status);
    Olga Sharonova . unresolved

    Why this is a part of this CL?

    Sunggook Chue

    PreferredAudioOutputDeviceManager::SetPreferredSinkId function needs 'SetPreferredSinkIdCallback', which come from this.

    Olga Sharonova

    It does not come from this one, it comes from AudioOutputDeviceSwitcher.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Olga Sharonova
    • Sunggook Chue
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
    Gerrit-Change-Number: 5664173
    Gerrit-PatchSet: 2
    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Reviewer: Olga Sharonova <ol...@google.com>
    Gerrit-CC: Olga Sharonova <ol...@chromium.org>
    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Attention: Olga Sharonova <ol...@google.com>
    Gerrit-Comment-Date: Mon, 01 Jul 2024 09:17:43 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
    Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Sunggook Chue (Gerrit)

    unread,
    Jul 1, 2024, 8:24:11 PM7/1/24
    to Guido Urdaneta, Steve Becker, Gabriel Brito, Olga Sharonova, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova, Olga Sharonova and Steve Becker

    Sunggook Chue added 4 comments

    Sunggook Chue . resolved

    addressed and replied comments, thanks.

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
    Line 30, Patchset 2:// default audio output device
    Olga Sharonova . resolved

    .

    Sunggook Chue

    Done

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
    Line 200, Patchset 1: weak_ptr_factory_.GetWeakPtr(), broker,
    Olga Sharonova . unresolved

    Which thread PreferredAudioOutputDeviceManager is destroyed on?
    weak_ptr can't be used on IO thread, if the PreferredAudioOutputDeviceManager is destroyed on UI thread (see base/memory/weak_ptr.h)

    Sunggook Chue

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    I don't find weak_ptr (WeakPtr) can't be on IO thread although it enforce use of same thread sequence.

    PreferredAudioOutputDeviceManager lifetime belongs MediaStreamManager that also has VideoCaptureManager, which has VideoCaptureController.

    VideoCaptureController is also created and destroyed like PreferredAudioOutputDeviceManager, and it is WeakPtrFactory.

    Can you point out any guideline, i might missed that?

    Olga Sharonova

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    VideoCaptureManager is refcounted, so it's unknown on which thread it is destroyed. Also, it does not seem to use weak pointers?
    VideoCaptureController is the one who uses weak pointers, and not necessarily correctly, since it also seems to be refcounted. I don't know what guarantees the correctness there (probably nothing), we may need ask the authors of the code.

    Also, media stream manager does not seem to be destroyed on IO thread, rather IO thread is destroyed before: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/media_stream_manager.cc;l=1643;drc=7b232da0f22e8cdf555d43c52b6491baeb87f729;bpv=1;bpt=1

    Guido knows this part better.

    Sunggook Chue

    VideoCaptureManager (PreferredAudioOutputDeviceManager) will be destroyed in the IO thread during DestructionObserver::WillDestroyCurrentMessageLoop and MediaStreamManager is destroyed on non IO thread after this.

    File third_party/blink/public/mojom/mediastream/media_devices.mojom
    Line 148, Patchset 1: SetPreferredSinkId(string sink_id) => (media.mojom.OutputDeviceStatus status);
    Olga Sharonova . resolved

    Why this is a part of this CL?

    Sunggook Chue

    PreferredAudioOutputDeviceManager::SetPreferredSinkId function needs 'SetPreferredSinkIdCallback', which come from this.

    Olga Sharonova

    It does not come from this one, it comes from AudioOutputDeviceSwitcher.

    Sunggook Chue

    if delete it from the media_devices, the compilation error.

    ../..\content/browser/renderer_host/media/media_devices_dispatcher_host.h(80,27): error: unknown type name 'SetPreferredSinkIdCallback'
    80 | SetPreferredSinkIdCallback callback) override;
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Gabriel Brito
    • Guido Urdaneta
    • Olga Sharonova
    • Olga Sharonova
    • Steve Becker
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
    Gerrit-Change-Number: 5664173
    Gerrit-PatchSet: 3
    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
    Gerrit-Reviewer: Olga Sharonova <ol...@google.com>
    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
    Gerrit-CC: Olga Sharonova <ol...@chromium.org>
    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
    Gerrit-Attention: Steve Becker <ste...@microsoft.com>
    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Olga Sharonova <ol...@google.com>
    Gerrit-Comment-Date: Tue, 02 Jul 2024 00:24:00 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Guido Urdaneta (Gerrit)

    unread,
    Jul 5, 2024, 6:30:15 AM7/5/24
    to Sunggook Chue, Steve Becker, Gabriel Brito, Olga Sharonova, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Gabriel Brito, Olga Sharonova, Olga Sharonova, Steve Becker and Sunggook Chue

    Guido Urdaneta added 1 comment

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
    Line 200, Patchset 1: weak_ptr_factory_.GetWeakPtr(), broker,
    Olga Sharonova . unresolved

    Which thread PreferredAudioOutputDeviceManager is destroyed on?
    weak_ptr can't be used on IO thread, if the PreferredAudioOutputDeviceManager is destroyed on UI thread (see base/memory/weak_ptr.h)

    Sunggook Chue

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    I don't find weak_ptr (WeakPtr) can't be on IO thread although it enforce use of same thread sequence.

    PreferredAudioOutputDeviceManager lifetime belongs MediaStreamManager that also has VideoCaptureManager, which has VideoCaptureController.

    VideoCaptureController is also created and destroyed like PreferredAudioOutputDeviceManager, and it is WeakPtrFactory.

    Can you point out any guideline, i might missed that?

    Olga Sharonova

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    VideoCaptureManager is refcounted, so it's unknown on which thread it is destroyed. Also, it does not seem to use weak pointers?
    VideoCaptureController is the one who uses weak pointers, and not necessarily correctly, since it also seems to be refcounted. I don't know what guarantees the correctness there (probably nothing), we may need ask the authors of the code.

    Also, media stream manager does not seem to be destroyed on IO thread, rather IO thread is destroyed before: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/media_stream_manager.cc;l=1643;drc=7b232da0f22e8cdf555d43c52b6491baeb87f729;bpv=1;bpt=1

    Guido knows this part better.

    Sunggook Chue

    VideoCaptureManager (PreferredAudioOutputDeviceManager) will be destroyed in the IO thread during DestructionObserver::WillDestroyCurrentMessageLoop and MediaStreamManager is destroyed on non IO thread after this.

    Guido Urdaneta

    Like Olga says, MediaStreamManager is **not** destroyed on the IO thread. It outlives the IO thread.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Gabriel Brito
    • Olga Sharonova
    • Olga Sharonova
    • Steve Becker
    • Sunggook Chue
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
    Gerrit-Change-Number: 5664173
    Gerrit-PatchSet: 4
    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
    Gerrit-Reviewer: Olga Sharonova <ol...@google.com>
    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
    Gerrit-CC: Olga Sharonova <ol...@chromium.org>
    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
    Gerrit-Attention: Steve Becker <ste...@microsoft.com>
    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Attention: Olga Sharonova <ol...@google.com>
    Gerrit-Comment-Date: Fri, 05 Jul 2024 10:30:04 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Guido Urdaneta (Gerrit)

    unread,
    Jul 5, 2024, 6:34:49 AM7/5/24
    to Sunggook Chue, Steve Becker, Gabriel Brito, Olga Sharonova, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Gabriel Brito, Olga Sharonova, Olga Sharonova, Steve Becker and Sunggook Chue

    Guido Urdaneta added 1 comment

    File content/browser/renderer_host/media/media_devices_dispatcher_host.cc
    Line 340, Patchset 4 (Latest): NOTIMPLEMENTED();
    Guido Urdaneta . unresolved

    Follow Olga's indications on how to split the CLs, and make sure this appears in the same CL where the method is added to the mojom file and that it has a real implementation.

    Gerrit-Comment-Date: Fri, 05 Jul 2024 10:34:37 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Sharonova (Gerrit)

    unread,
    Jul 5, 2024, 7:38:41 AM7/5/24
    to Sunggook Chue, Guido Urdaneta, Steve Becker, Gabriel Brito, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova, Steve Becker and Sunggook Chue

    Olga Sharonova added 7 comments

    Patchset-level comments
    File-level comment, Patchset 4 (Latest):
    Olga Sharonova . resolved

    PreferredAudioOutputDeviceManger introduces 2 interaction surfaces: 1) Interface for brokers to register/undergister; 2) SetPreferredSinkId interface.

    We need to see the code
    1) handling PreferredAudioOutputDeviceManger lifetime.
    2) introducing an interaction between a broker and PreferredAudioOutputDeviceManger.
    3) introducing SetPreferredSinkId usage.

    It's impossible to reason about correctness here until we see the interactions with the class.

    This should likely be 3 separate CLs, but I leave it up to you to arrange it so it makes sense.

    Also a diagram of relationships would be very helpful.

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
    Line 41, Patchset 4 (Latest): void AddBrokerAndGetOverrideDeviceId(
    AudioOutputDeviceSwitcher* device_switcher,
    base::OnceCallback<void(const std::string&)> callback);
    void GetOverrideDeviceId(
    const int process_id,
    const int render_frame_id,
    base::OnceCallback<void(const std::string&)> callback);
    void RemoveBrokerEntry(AudioOutputDeviceSwitcher* device_switcher);
    void RemoveRenderFrameHostEntry(RenderFrameHost* render_frame_host);
    Olga Sharonova . unresolved

    I'd like to see a CL which clearly introduces usage of these interfaces. Only looking at it we can judge this one. Currently the usage is introduces in the last CL of the chain along with many other things, so we can't review effectively.

    Line 41, Patchset 4 (Latest): void AddBrokerAndGetOverrideDeviceId(
    Olga Sharonova . unresolved

    Re: naming: we agreed to used Switcher; this class is unaware of brokers. Please fix everywhere.

    Line 29, Patchset 4 (Latest):// streaming is active. The cached sink id will be used instead of the active
    Olga Sharonova . unresolved

    What does "streaming is active" mean?

    Line 28, Patchset 4 (Latest):// forwards the request to the corresponding active audio service if
    Olga Sharonova . unresolved

    What does it mean?

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
    Line 200, Patchset 1: weak_ptr_factory_.GetWeakPtr(), broker,
    Olga Sharonova . unresolved

    Which thread PreferredAudioOutputDeviceManager is destroyed on?
    weak_ptr can't be used on IO thread, if the PreferredAudioOutputDeviceManager is destroyed on UI thread (see base/memory/weak_ptr.h)

    Sunggook Chue

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    I don't find weak_ptr (WeakPtr) can't be on IO thread although it enforce use of same thread sequence.

    PreferredAudioOutputDeviceManager lifetime belongs MediaStreamManager that also has VideoCaptureManager, which has VideoCaptureController.

    VideoCaptureController is also created and destroyed like PreferredAudioOutputDeviceManager, and it is WeakPtrFactory.

    Can you point out any guideline, i might missed that?

    Olga Sharonova

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    VideoCaptureManager is refcounted, so it's unknown on which thread it is destroyed. Also, it does not seem to use weak pointers?
    VideoCaptureController is the one who uses weak pointers, and not necessarily correctly, since it also seems to be refcounted. I don't know what guarantees the correctness there (probably nothing), we may need ask the authors of the code.

    Also, media stream manager does not seem to be destroyed on IO thread, rather IO thread is destroyed before: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/media_stream_manager.cc;l=1643;drc=7b232da0f22e8cdf555d43c52b6491baeb87f729;bpv=1;bpt=1

    Guido knows this part better.

    Sunggook Chue

    VideoCaptureManager (PreferredAudioOutputDeviceManager) will be destroyed in the IO thread during DestructionObserver::WillDestroyCurrentMessageLoop and MediaStreamManager is destroyed on non IO thread after this.

    Guido Urdaneta

    Like Olga says, MediaStreamManager is **not** destroyed on the IO thread. It outlives the IO thread.

    Olga Sharonova

    VideoCaptureManager (PreferredAudioOutputDeviceManager) will be destroyed in the IO thread during DestructionObserver::WillDestroyCurrentMessageLoop

    Please point to the place in the code you refer to.
    Also please document the reasoning bout the lifetime in the code. Why it's safe to use weak pointers, why the object will be destroyed on IO thread, etc.
    Also please document the object threading: created on thread x, requests are forwarded to thread y, destroyed on thread z.

    File third_party/blink/public/mojom/mediastream/media_devices.mojom
    Line 148, Patchset 1: SetPreferredSinkId(string sink_id) => (media.mojom.OutputDeviceStatus status);
    Olga Sharonova . unresolved

    Why this is a part of this CL?

    Sunggook Chue

    PreferredAudioOutputDeviceManager::SetPreferredSinkId function needs 'SetPreferredSinkIdCallback', which come from this.

    Olga Sharonova

    It does not come from this one, it comes from AudioOutputDeviceSwitcher.

    Sunggook Chue

    if delete it from the media_devices, the compilation error.

    ../..\content/browser/renderer_host/media/media_devices_dispatcher_host.h(80,27): error: unknown type name 'SetPreferredSinkIdCallback'
    80 | SetPreferredSinkIdCallback callback) override;
    Olga Sharonova

    Because MediaDispatcherHost change is also irrelevant for this CL: it's not implemented.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Gabriel Brito
    • Guido Urdaneta
    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Attention: Olga Sharonova <ol...@google.com>
    Gerrit-Comment-Date: Fri, 05 Jul 2024 11:38:29 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Guido Urdaneta <gui...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Sharonova (Gerrit)

    unread,
    Jul 5, 2024, 7:50:36 AM7/5/24
    to Sunggook Chue, Guido Urdaneta, Steve Becker, Gabriel Brito, Olga Sharonova, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova, Steve Becker and Sunggook Chue

    Olga Sharonova added 1 comment

    File content/browser/media/audio_output_stream_broker.h
    Line 27, Patchset 4 (Latest):class AudioOutputDeviceSwitcher {
    public:
    virtual ~AudioOutputDeviceSwitcher() = default;

    virtual void SwitchAudioOutputDeviceId(const std::string& device_id) = 0;

    virtual GlobalRenderFrameHostId GetGlobalRenderFrameHostId() const = 0;
    };
    Olga Sharonova . unresolved

    Introduce this and the device switch logic from https://chromium-review.googlesource.com/c/chromium/src/+/5530803/11 in the CL *preceding* this one.

    Otherwise this interface is hanging in the air without actual meaning, and we can only guess about the intentions by the fact that the device switcher was named "broker".

    Gerrit-Comment-Date: Fri, 05 Jul 2024 11:50:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Sunggook Chue (Gerrit)

    unread,
    Jul 8, 2024, 11:39:09 PM7/8/24
    to Olga Sharonova, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova and Steve Becker

    Sunggook Chue added 9 comments

    Patchset-level comments
    File-level comment, Patchset 6 (Latest):
    Sunggook Chue . resolved

    addressed comments based on f2f meeting, thanks.

    File content/browser/media/audio_output_stream_broker.h
    Line 27, Patchset 4:class AudioOutputDeviceSwitcher {

    public:
    virtual ~AudioOutputDeviceSwitcher() = default;

    virtual void SwitchAudioOutputDeviceId(const std::string& device_id) = 0;

    virtual GlobalRenderFrameHostId GetGlobalRenderFrameHostId() const = 0;
    };
    Olga Sharonova . resolved

    Introduce this and the device switch logic from https://chromium-review.googlesource.com/c/chromium/src/+/5530803/11 in the CL *preceding* this one.

    Otherwise this interface is hanging in the air without actual meaning, and we can only guess about the intentions by the fact that the device switcher was named "broker".

    Sunggook Chue

    Done

    File content/browser/renderer_host/media/media_devices_dispatcher_host.cc
    Line 340, Patchset 4: NOTIMPLEMENTED();
    Guido Urdaneta . resolved

    Follow Olga's indications on how to split the CLs, and make sure this appears in the same CL where the method is added to the mojom file and that it has a real implementation.

    Sunggook Chue

    Done

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
    Line 41, Patchset 4: void AddBrokerAndGetOverrideDeviceId(

    AudioOutputDeviceSwitcher* device_switcher,
    base::OnceCallback<void(const std::string&)> callback);
    void GetOverrideDeviceId(
    const int process_id,
    const int render_frame_id,
    base::OnceCallback<void(const std::string&)> callback);
    void RemoveBrokerEntry(AudioOutputDeviceSwitcher* device_switcher);
    void RemoveRenderFrameHostEntry(RenderFrameHost* render_frame_host);
    Olga Sharonova . resolved

    I'd like to see a CL which clearly introduces usage of these interfaces. Only looking at it we can judge this one. Currently the usage is introduces in the last CL of the chain along with many other things, so we can't review effectively.

    Sunggook Chue

    These interfaces are essential for this class, so unit tests will give idea what these methods are.

    I think it is same with already added Audio Services where we implemented before its clients; bottom up approach what you suggested, instead of client first, which is my initial CLs.

    If we add methods with its clients, then the class can't have any methods yet all.

    Line 41, Patchset 4: void AddBrokerAndGetOverrideDeviceId(
    Olga Sharonova . resolved

    Re: naming: we agreed to used Switcher; this class is unaware of brokers. Please fix everywhere.

    Sunggook Chue

    Done

    Line 29, Patchset 4:// streaming is active. The cached sink id will be used instead of the active
    Olga Sharonova . resolved

    What does "streaming is active" mean?

    Sunggook Chue

    current playing.

    Line 28, Patchset 4:// forwards the request to the corresponding active audio service if
    Olga Sharonova . resolved

    What does it mean?

    Sunggook Chue

    audio output stream in the audio service.

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
    Line 200, Patchset 1: weak_ptr_factory_.GetWeakPtr(), broker,
    Olga Sharonova . resolved

    Which thread PreferredAudioOutputDeviceManager is destroyed on?
    weak_ptr can't be used on IO thread, if the PreferredAudioOutputDeviceManager is destroyed on UI thread (see base/memory/weak_ptr.h)

    Sunggook Chue

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    I don't find weak_ptr (WeakPtr) can't be on IO thread although it enforce use of same thread sequence.

    PreferredAudioOutputDeviceManager lifetime belongs MediaStreamManager that also has VideoCaptureManager, which has VideoCaptureController.

    VideoCaptureController is also created and destroyed like PreferredAudioOutputDeviceManager, and it is WeakPtrFactory.

    Can you point out any guideline, i might missed that?

    Olga Sharonova

    PreferredAudioOutputDeviceManager is created and destroyed on IO thread like VideoCaptureManager.

    VideoCaptureManager is refcounted, so it's unknown on which thread it is destroyed. Also, it does not seem to use weak pointers?
    VideoCaptureController is the one who uses weak pointers, and not necessarily correctly, since it also seems to be refcounted. I don't know what guarantees the correctness there (probably nothing), we may need ask the authors of the code.

    Also, media stream manager does not seem to be destroyed on IO thread, rather IO thread is destroyed before: https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/media_stream_manager.cc;l=1643;drc=7b232da0f22e8cdf555d43c52b6491baeb87f729;bpv=1;bpt=1

    Guido knows this part better.

    Sunggook Chue

    VideoCaptureManager (PreferredAudioOutputDeviceManager) will be destroyed in the IO thread during DestructionObserver::WillDestroyCurrentMessageLoop and MediaStreamManager is destroyed on non IO thread after this.

    Guido Urdaneta

    Like Olga says, MediaStreamManager is **not** destroyed on the IO thread. It outlives the IO thread.

    Olga Sharonova

    VideoCaptureManager (PreferredAudioOutputDeviceManager) will be destroyed in the IO thread during DestructionObserver::WillDestroyCurrentMessageLoop

    Please point to the place in the code you refer to.
    Also please document the reasoning bout the lifetime in the code. Why it's safe to use weak pointers, why the object will be destroyed on IO thread, etc.
    Also please document the object threading: created on thread x, requests are forwarded to thread y, destroyed on thread z.

    Sunggook Chue

    Please take a look at the media_stream_manager.cc changes where it instantiates and destroyed at the IO thread. (same place with VideoCaptureManager).

    File third_party/blink/public/mojom/mediastream/media_devices.mojom
    Line 148, Patchset 1: SetPreferredSinkId(string sink_id) => (media.mojom.OutputDeviceStatus status);
    Olga Sharonova . resolved

    Why this is a part of this CL?

    Sunggook Chue

    PreferredAudioOutputDeviceManager::SetPreferredSinkId function needs 'SetPreferredSinkIdCallback', which come from this.

    Olga Sharonova

    It does not come from this one, it comes from AudioOutputDeviceSwitcher.

    Sunggook Chue

    if delete it from the media_devices, the compilation error.

    ../..\content/browser/renderer_host/media/media_devices_dispatcher_host.h(80,27): error: unknown type name 'SetPreferredSinkIdCallback'
    80 | SetPreferredSinkIdCallback callback) override;
    Olga Sharonova

    Because MediaDispatcherHost change is also irrelevant for this CL: it's not implemented.

    Sunggook Chue

    What I mean, PreferredAudioOutputDeviceManager::SetPreferredSinkId needs 'blink::mojom::MediaDevicesDispatcherHost::SetPreferredSinkIdCallback', which needs media_devices.mojom change.

    If we want to delete this one here, then we can't implement PreferredAudioOutputDeviceManager::SetPreferredSinkId as it misses

    PreferredAudioOutputDeviceManager class will be called from

    1. from the broker class: 3rd CL.

    2. from the renderer through MediaDispatcherHost host,
    Renderer -> MediaDispatcherHost-> MediaStreamManager->PreferredAudioOutputDeviceManager.

    Here, I will skip SetPreferredSinkId implementation, so,

    4th CL: PreferredAudioOutputDeviceManager with custom SetPreferredSinkIdCallback
    5th CL: Broker interact with PreferredAudioOutputDeviceManager.
    6th CL: Device Authorization.
    7th CL: MediaStreamManager instantiate PreferredAudioOutputDeviceManager and media_devices.mojom (MediaDispatcherHost), correct type of SetPreferredSinkIdCallback.
    8th CL: Renderer call MediaDispatcherHost with IDL.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Gabriel Brito
    • Guido Urdaneta
    • Olga Sharonova
    • Steve Becker
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Review
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
    Gerrit-Change-Number: 5664173
    Gerrit-PatchSet: 6
    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
    Gerrit-Attention: Steve Becker <ste...@microsoft.com>
    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
    Gerrit-Comment-Date: Tue, 09 Jul 2024 03:38:59 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Olga Sharonova (Gerrit)

    unread,
    Jul 9, 2024, 10:28:46 AM7/9/24
    to Sunggook Chue, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
    Attention needed from Gabriel Brito, Guido Urdaneta, Steve Becker and Sunggook Chue

    Olga Sharonova added 6 comments

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
    Line 86, Patchset 7 (Latest): std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
    Olga Sharonova . unresolved

    Document that it's only accessed on IO thread.

    Line 39, Patchset 7 (Latest): void SetPreferredSinkId(const std::string& sink_id,
    SetPreferredSinkIdCallback callback,
    GlobalRenderFrameHostId rfh_id);
    void AddSwitcherAndGetOverrideDeviceId(

    AudioOutputDeviceSwitcher* device_switcher,
    base::OnceCallback<void(const std::string&)> callback);
    void GetOverrideDeviceId(
    const int process_id,
    const int render_frame_id,
    base::OnceCallback<void(const std::string&)> callback);
    void RemoveSwitcherEntry(AudioOutputDeviceSwitcher* device_switcher);
    void RemoveRenderFrameHostEntry(RenderFrameHost* render_frame_host);
    Olga Sharonova . unresolved

    Please document the API: what are the parameters, on which threads which of the method is expected to be called, etc.

    Line 48, Patchset 7 (Latest): base::OnceCallback<void(const std::string&)> callback);
    Olga Sharonova . unresolved

    Ditto

    Line 44, Patchset 7 (Latest): base::OnceCallback<void(const std::string&)> callback);
    Olga Sharonova . unresolved

    What is this callback, on which thread it's expected to run? Please document.

    Line 34, Patchset 7 (Latest):class CONTENT_EXPORT PreferredAudioOutputDeviceManager {
    Olga Sharonova . unresolved

    I requested in one of the earlier CLs to document this class lifetime, which thread it's destroyed on, why weak pointers are safe, etc. - could you please do that?

    Also, since the methods hop through threads all the time - please provide sequence diagrams for them.

    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
    Line 207, Patchset 7 (Latest):void PreferredAudioOutputDeviceManager::RemoveSwitcherEntry(
    Olga Sharonova . unresolved

    I don't think this works. This method is called in the broker destructor. When it exits, the device switcher pointer is no longer valid. However, we jump through UI thread and back to IO before actually removing it from the map. Meanwhile, there may be preferred device switch calls already scheduled on IO thread, and they will call the already deleted switcher before we get to RemoveSwitcherEntryOnIOThread().

    Please see above my request for sequence diagrams. There may be other problems like that, for example when web content is gone.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Gabriel Brito
    • Guido Urdaneta
    • Steve Becker
    • Sunggook Chue
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedNo-Unresolved-Comments
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
      Gerrit-Change-Number: 5664173
      Gerrit-PatchSet: 7
      Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
      Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
      Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
      Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
      Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
      Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
      Gerrit-Attention: Steve Becker <ste...@microsoft.com>
      Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
      Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
      Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
      Gerrit-Comment-Date: Tue, 09 Jul 2024 14:28:33 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Sunggook Chue (Gerrit)

      unread,
      Jul 10, 2024, 12:09:50 AM7/10/24
      to Olga Sharonova, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
      Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova and Steve Becker

      Sunggook Chue added 7 comments

      Patchset-level comments
      File-level comment, Patchset 8 (Latest):
      Sunggook Chue . resolved

      addressed comments, thanks.

      File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
      Line 86, Patchset 7: std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
      Olga Sharonova . resolved

      Document that it's only accessed on IO thread.

      Sunggook Chue

      Done

      Line 39, Patchset 7: void SetPreferredSinkId(const std::string& sink_id,

      SetPreferredSinkIdCallback callback,
      GlobalRenderFrameHostId rfh_id);
      void AddSwitcherAndGetOverrideDeviceId(
      AudioOutputDeviceSwitcher* device_switcher,
      base::OnceCallback<void(const std::string&)> callback);
      void GetOverrideDeviceId(
      const int process_id,
      const int render_frame_id,
      base::OnceCallback<void(const std::string&)> callback);
      void RemoveSwitcherEntry(AudioOutputDeviceSwitcher* device_switcher);
      void RemoveRenderFrameHostEntry(RenderFrameHost* render_frame_host);
      Olga Sharonova . resolved

      Please document the API: what are the parameters, on which threads which of the method is expected to be called, etc.

      Sunggook Chue

      Done

      Line 48, Patchset 7: base::OnceCallback<void(const std::string&)> callback);
      Olga Sharonova . resolved

      Ditto

      Sunggook Chue

      Done

      Line 44, Patchset 7: base::OnceCallback<void(const std::string&)> callback);
      Olga Sharonova . resolved

      What is this callback, on which thread it's expected to run? Please document.

      Sunggook Chue

      Done

      Line 34, Patchset 7:class CONTENT_EXPORT PreferredAudioOutputDeviceManager {
      Olga Sharonova . resolved

      I requested in one of the earlier CLs to document this class lifetime, which thread it's destroyed on, why weak pointers are safe, etc. - could you please do that?

      Also, since the methods hop through threads all the time - please provide sequence diagrams for them.

      Sunggook Chue

      I added comments, feel free to suggest if needed.

      File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
      Line 207, Patchset 7:void PreferredAudioOutputDeviceManager::RemoveSwitcherEntry(
      Olga Sharonova . resolved

      I don't think this works. This method is called in the broker destructor. When it exits, the device switcher pointer is no longer valid. However, we jump through UI thread and back to IO before actually removing it from the map. Meanwhile, there may be preferred device switch calls already scheduled on IO thread, and they will call the already deleted switcher before we get to RemoveSwitcherEntryOnIOThread().

      Please see above my request for sequence diagrams. There may be other problems like that, for example when web content is gone.

      Sunggook Chue

      The current logic is same with 'NotifyFrameHostOfAudioStreamStopped', which is called in AudioOutputStreamBroker dtor and operate on UI thread.

      All it needs the RenderFrameHost object is alive on the UI thread, and it doesn't have to live when it back to the IO thread as it is nothing but a integer.

      It is called on the UI thread for WebContents, where it is even safer than broker since it doesn't have to switch to UI thread.

      It's not convenient to draw sequence diagram on the /h file, anyway, tried.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Gabriel Brito
      • Guido Urdaneta
      • Olga Sharonova
      • Steve Becker
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Review
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
      Gerrit-Change-Number: 5664173
      Gerrit-PatchSet: 8
      Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
      Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
      Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
      Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
      Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
      Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
      Gerrit-Attention: Steve Becker <ste...@microsoft.com>
      Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
      Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
      Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
      Gerrit-Comment-Date: Wed, 10 Jul 2024 04:09:39 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Olga Sharonova (Gerrit)

      unread,
      Jul 10, 2024, 2:52:46 AM7/10/24
      to Sunggook Chue, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
      Attention needed from Gabriel Brito, Guido Urdaneta, Steve Becker and Sunggook Chue

      Olga Sharonova added 2 comments

      File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
      Line 44, Patchset 8 (Latest):// substitued for the new audio output stream if the requested stream is
      Olga Sharonova . unresolved

      "substitued" is a possible misspelling of "substituted" or "substitute".

      Please fix.

      File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
      Line 207, Patchset 7:void PreferredAudioOutputDeviceManager::RemoveSwitcherEntry(
      Olga Sharonova . unresolved

      I don't think this works. This method is called in the broker destructor. When it exits, the device switcher pointer is no longer valid. However, we jump through UI thread and back to IO before actually removing it from the map. Meanwhile, there may be preferred device switch calls already scheduled on IO thread, and they will call the already deleted switcher before we get to RemoveSwitcherEntryOnIOThread().

      Please see above my request for sequence diagrams. There may be other problems like that, for example when web content is gone.

      Sunggook Chue

      The current logic is same with 'NotifyFrameHostOfAudioStreamStopped', which is called in AudioOutputStreamBroker dtor and operate on UI thread.

      All it needs the RenderFrameHost object is alive on the UI thread, and it doesn't have to live when it back to the IO thread as it is nothing but a integer.

      It is called on the UI thread for WebContents, where it is even safer than broker since it doesn't have to switch to UI thread.

      It's not convenient to draw sequence diagram on the /h file, anyway, tried.

      Olga Sharonova

      I mean: *a* sequence diagram - in any readable format, not in .h file. Since we have not discussed this in a design doc, and the interactions are rather complex. Also, because I just described a problem with these sequences.

      I don't see how your comment addresses the situation I described though: SetPreferredSinkIdOnIOThread() being called while we jump here from IO thread to UI and back to removed a deleted switcher from the map.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Gabriel Brito
      • Guido Urdaneta
      • Steve Becker
      • Sunggook Chue
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
        Gerrit-Change-Number: 5664173
        Gerrit-PatchSet: 8
        Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
        Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
        Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
        Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
        Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
        Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
        Gerrit-Attention: Steve Becker <ste...@microsoft.com>
        Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
        Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
        Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
        Gerrit-Comment-Date: Wed, 10 Jul 2024 06:52:35 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
        Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Olga Sharonova (Gerrit)

        unread,
        Jul 10, 2024, 3:15:29 AM7/10/24
        to Sunggook Chue, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
        Attention needed from Gabriel Brito, Guido Urdaneta, Steve Becker and Sunggook Chue

        Olga Sharonova added 1 comment

        File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
        Line 238, Patchset 8 (Latest):void PreferredAudioOutputDeviceManager::RemoveRenderFrameHostEntry(
        Olga Sharonova . unresolved

        There may be SetPreferredSinkIdOnIOThread() scheduled before RemoveRenderFrameHostEntryEntryOnIOThread is called.

        Gerrit-Comment-Date: Wed, 10 Jul 2024 07:15:16 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Olga Sharonova (Gerrit)

        unread,
        Jul 10, 2024, 3:45:23 AM7/10/24
        to Sunggook Chue, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
        Attention needed from Gabriel Brito, Guido Urdaneta, Steve Becker and Sunggook Chue

        Olga Sharonova added 1 comment

        File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
        Line 134, Patchset 8 (Latest): &GetRenderFrameHostOnUIThread,
        device_switcher->GetGlobalRenderFrameHostId(),
        Olga Sharonova . unresolved

        I think we should reconsider this part of PreferredAudioOutputDeviceManager. Why do we make it fetch the host, rather than providing it? For example, the host is known for the Broker aka Switcher during its creation, isn't it? So Switcher can have a getter for it, rather than for its id.
        If we make PreferredAudioOutputDeviceManager to work with main frame directly, the threading will be much simpler and safer.
        Am I missing something?

        Gerrit-Comment-Date: Wed, 10 Jul 2024 07:45:09 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Sunggook Chue (Gerrit)

        unread,
        Jul 11, 2024, 1:19:09 AM7/11/24
        to Olga Sharonova, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
        Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova and Steve Becker

        Sunggook Chue added 5 comments

        Patchset-level comments
        File-level comment, Patchset 9 (Latest):
        Sunggook Chue . resolved

        addressed and replied comments, thanks.

        File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
        Line 44, Patchset 8:// substitued for the new audio output stream if the requested stream is
        Olga Sharonova . resolved

        "substitued" is a possible misspelling of "substituted" or "substitute".

        Please fix.

        Sunggook Chue

        Done

        File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
        Line 134, Patchset 8: &GetRenderFrameHostOnUIThread,
        device_switcher->GetGlobalRenderFrameHostId(),
        Olga Sharonova . resolved

        I think we should reconsider this part of PreferredAudioOutputDeviceManager. Why do we make it fetch the host, rather than providing it? For example, the host is known for the Broker aka Switcher during its creation, isn't it? So Switcher can have a getter for it, rather than for its id.
        If we make PreferredAudioOutputDeviceManager to work with main frame directly, the threading will be much simpler and safer.
        Am I missing something?

        Sunggook Chue

        Actually, Broker is on the IO thread only and its knowledge of the Host is limited to its integer ID (process id, frame id), not a RenderFrameHost object.

        We need to get RenderFrameHost to tell if it is main or sub, and RenderFrameHost can be acquired from the IDs only in the UI thread.

        Line 207, Patchset 7:void PreferredAudioOutputDeviceManager::RemoveSwitcherEntry(
        Olga Sharonova . resolved

        I don't think this works. This method is called in the broker destructor. When it exits, the device switcher pointer is no longer valid. However, we jump through UI thread and back to IO before actually removing it from the map. Meanwhile, there may be preferred device switch calls already scheduled on IO thread, and they will call the already deleted switcher before we get to RemoveSwitcherEntryOnIOThread().

        Please see above my request for sequence diagrams. There may be other problems like that, for example when web content is gone.

        Sunggook Chue

        The current logic is same with 'NotifyFrameHostOfAudioStreamStopped', which is called in AudioOutputStreamBroker dtor and operate on UI thread.

        All it needs the RenderFrameHost object is alive on the UI thread, and it doesn't have to live when it back to the IO thread as it is nothing but a integer.

        It is called on the UI thread for WebContents, where it is even safer than broker since it doesn't have to switch to UI thread.

        It's not convenient to draw sequence diagram on the /h file, anyway, tried.

        Olga Sharonova

        I mean: *a* sequence diagram - in any readable format, not in .h file. Since we have not discussed this in a design doc, and the interactions are rather complex. Also, because I just described a problem with these sequences.

        I don't see how your comment addresses the situation I described though: SetPreferredSinkIdOnIOThread() being called while we jump here from IO thread to UI and back to removed a deleted switcher from the map.

        Sunggook Chue

        That's good point, probably we will have to use WeakPtr for the store of the Switcher interface. updated.

        Line 238, Patchset 8:void PreferredAudioOutputDeviceManager::RemoveRenderFrameHostEntry(
        Olga Sharonova . resolved

        There may be SetPreferredSinkIdOnIOThread() scheduled before RemoveRenderFrameHostEntryEntryOnIOThread is called.

        Sunggook Chue

        Yes, it could be, but the worst case is that SetPreferredSinkIdOnIOThread will call the SwitchAudioOutputDeviceId of the broker, but the broker could have been called if not deleted from the list yey; The broker is a WeakPtr already that will be handled gracefully there whether the Broker is still alive or not.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Gabriel Brito
        • Guido Urdaneta
        • Olga Sharonova
        • Steve Becker
        Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement is not satisfiedCode-Review
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
        Gerrit-Change-Number: 5664173
        Gerrit-PatchSet: 9
        Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
        Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
        Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
        Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
        Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
        Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
        Gerrit-Attention: Steve Becker <ste...@microsoft.com>
        Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
        Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
        Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
        Gerrit-Comment-Date: Thu, 11 Jul 2024 05:18:58 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Olga Sharonova (Gerrit)

        unread,
        Jul 11, 2024, 3:42:36 AM7/11/24
        to Sunggook Chue, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
        Attention needed from Gabriel Brito, Guido Urdaneta, Steve Becker and Sunggook Chue

        Olga Sharonova added 9 comments

        File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
        Line 55, Patchset 9 (Latest): if (check_type == RenderFrameHostCheckType::kTopFrame && rfh->GetParent()) {
        Olga Sharonova . unresolved

        Can be nullptr?

        Line 89, Patchset 9 (Latest): RenderFrameHost* render_frame_host) {
        Olga Sharonova . unresolved

        Can be deleted on UI thread meanwhile, can't it?

        Line 93, Patchset 9 (Latest): media::OutputDeviceStatus::OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED);
        Olga Sharonova . unresolved

        Any other possible reasons for it being nullptr?

        Line 98, Patchset 9 (Latest): DCHECK_EQ(render_frame_host->GetMainFrame(), render_frame_host);
        Olga Sharonova . unresolved

        Not thread-safe?

        Line 134, Patchset 8: &GetRenderFrameHostOnUIThread,
        device_switcher->GetGlobalRenderFrameHostId(),
        Olga Sharonova . unresolved

        I think we should reconsider this part of PreferredAudioOutputDeviceManager. Why do we make it fetch the host, rather than providing it? For example, the host is known for the Broker aka Switcher during its creation, isn't it? So Switcher can have a getter for it, rather than for its id.
        If we make PreferredAudioOutputDeviceManager to work with main frame directly, the threading will be much simpler and safer.
        Am I missing something?

        Sunggook Chue

        Actually, Broker is on the IO thread only and its knowledge of the Host is limited to its integer ID (process id, frame id), not a RenderFrameHost object.

        We need to get RenderFrameHost to tell if it is main or sub, and RenderFrameHost can be acquired from the IDs only in the UI thread.

        Olga Sharonova

        It's not set in stone, we can reconsider it/add additional information. What would be the problems if a broker holds to the host, passed in the constructor? It can also be in an anonymous form of "group id" (see the comment below).

        I'm not proposing to rewrite everything immediately, but I think we should consider this options. The current design is quite complicated and not very robust to future changes; maybe that would simplify it.

        Line 199, Patchset 9 (Latest): RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
        Olga Sharonova . unresolved

        Not thread-safe?

        Line 207, Patchset 7:void PreferredAudioOutputDeviceManager::RemoveSwitcherEntry(
        Olga Sharonova . unresolved

        I don't think this works. This method is called in the broker destructor. When it exits, the device switcher pointer is no longer valid. However, we jump through UI thread and back to IO before actually removing it from the map. Meanwhile, there may be preferred device switch calls already scheduled on IO thread, and they will call the already deleted switcher before we get to RemoveSwitcherEntryOnIOThread().

        Please see above my request for sequence diagrams. There may be other problems like that, for example when web content is gone.

        Sunggook Chue

        The current logic is same with 'NotifyFrameHostOfAudioStreamStopped', which is called in AudioOutputStreamBroker dtor and operate on UI thread.

        All it needs the RenderFrameHost object is alive on the UI thread, and it doesn't have to live when it back to the IO thread as it is nothing but a integer.

        It is called on the UI thread for WebContents, where it is even safer than broker since it doesn't have to switch to UI thread.

        It's not convenient to draw sequence diagram on the /h file, anyway, tried.

        Olga Sharonova

        I mean: *a* sequence diagram - in any readable format, not in .h file. Since we have not discussed this in a design doc, and the interactions are rather complex. Also, because I just described a problem with these sequences.

        I don't see how your comment addresses the situation I described though: SetPreferredSinkIdOnIOThread() being called while we jump here from IO thread to UI and back to removed a deleted switcher from the map.

        Sunggook Chue

        That's good point, probably we will have to use WeakPtr for the store of the Switcher interface. updated.

        Olga Sharonova

        SG. I'm still looking forward to a sequence diagram describing thread jumps. Can be added to the design doc, for example. Or be in any other readable form.

        Line 233, Patchset 9 (Latest): RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
        Olga Sharonova . unresolved

        not thread-safe?

        Line 238, Patchset 8:void PreferredAudioOutputDeviceManager::RemoveRenderFrameHostEntry(
        Olga Sharonova . unresolved

        There may be SetPreferredSinkIdOnIOThread() scheduled before RemoveRenderFrameHostEntryEntryOnIOThread is called.

        Sunggook Chue

        Yes, it could be, but the worst case is that SetPreferredSinkIdOnIOThread will call the SwitchAudioOutputDeviceId of the broker, but the broker could have been called if not deleted from the list yey; The broker is a WeakPtr already that will be handled gracefully there whether the Broker is still alive or not.

        Olga Sharonova

        With added weak pointers - yes.
        But how about render_frame_host deleted on UI thread before/during any IO thread calls accessing it?


        I'd prefer this CL treating RenderFrameHost* as an anonymous "group id" (and Switcher interface providing a getter for it). Would be much safer and simpler, and a better separation of concerns - as far as I can see.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Gabriel Brito
        • Guido Urdaneta
        • Steve Becker
        • Sunggook Chue
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
          Gerrit-Change-Number: 5664173
          Gerrit-PatchSet: 9
          Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
          Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
          Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
          Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
          Gerrit-Attention: Steve Becker <ste...@microsoft.com>
          Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
          Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
          Gerrit-Comment-Date: Thu, 11 Jul 2024 07:42:25 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Guido Urdaneta (Gerrit)

          unread,
          Jul 23, 2024, 5:33:47 AM7/23/24
          to Sunggook Chue, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
          Attention needed from Gabriel Brito, Steve Becker and Sunggook Chue

          Guido Urdaneta added 5 comments

          Patchset-level comments
          File-level comment, Patchset 10 (Latest):
          Guido Urdaneta . resolved

          Some initial comments.

          File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
          Line 145, Patchset 10 (Latest): std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
          Guido Urdaneta . unresolved

          Using raw pointers that can go dangling as keys a map looks dangerous to me.
          Can you replace it with the global routing IDs?

          Line 137, Patchset 10 (Latest): // The active streaming device_switchers that are using the system default
          Guido Urdaneta . unresolved

          Is it always system default, or could it be a non-system-default device if the user has called SetPreferredSinkId?

          Line 125, Patchset 10 (Latest): struct WebContentsSinkId {
          Guido Urdaneta . unresolved

          Given the restrictions on how this is created (only default or move constructor), it looks like this should be a class.
          Also, if you define move constructor, you should also define move assignment.

          Line 44, Patchset 10 (Latest):// substitued for the new audio output stream if the requested stream is
          Guido Urdaneta . unresolved

          "substitued" is a possible misspelling of "substituted" or "substitute".

          Please fix.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Gabriel Brito
          • Steve Becker
          • Sunggook Chue
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedNo-Unresolved-Comments
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
          Gerrit-Change-Number: 5664173
          Gerrit-PatchSet: 10
          Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
          Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
          Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
          Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
          Gerrit-Attention: Steve Becker <ste...@microsoft.com>
          Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
          Gerrit-Comment-Date: Tue, 23 Jul 2024 09:33:38 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Sunggook Chue (Gerrit)

          unread,
          Aug 6, 2024, 6:18:00 PM8/6/24
          to Olga Sharonova, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
          Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova and Steve Becker

          Sunggook Chue added 14 comments

          Patchset-level comments
          File-level comment, Patchset 11 (Latest):
          Sunggook Chue . resolved

          addressed comments, thanks.

          File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
          Line 145, Patchset 10: std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
          Guido Urdaneta . resolved

          Using raw pointers that can go dangling as keys a map looks dangerous to me.
          Can you replace it with the global routing IDs?

          Sunggook Chue

          global routing id can't give any information of the called render frame host (RFH)'s relation to its top RFH or children RFH.

          for example, RFH_A (top), RFH_B(top) are cached entries. And when RHF_C (child) is called, it should tell which RFH RHF_C child of? global ID can't help.

          Line 137, Patchset 10: // The active streaming device_switchers that are using the system default
          Guido Urdaneta . resolved

          Is it always system default, or could it be a non-system-default device if the user has called SetPreferredSinkId?

          Sunggook Chue

          it should be system default regardless of SetprefferedSinkId device id for switchers.

          Switchers is the one that user listen to audio device that is a system default or device from setSinkId. If it isn't system default device id from setSinkId, we don't register it (not called for registration).

          Line 125, Patchset 10: struct WebContentsSinkId {
          Guido Urdaneta . resolved

          Given the restrictions on how this is created (only default or move constructor), it looks like this should be a class.
          Also, if you define move constructor, you should also define move assignment.

          Sunggook Chue

          Done

          Line 44, Patchset 10:// substitued for the new audio output stream if the requested stream is
          Guido Urdaneta . resolved

          "substitued" is a possible misspelling of "substituted" or "substitute".

          Please fix.

          Sunggook Chue

          Done

          File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
          Line 55, Patchset 9: if (check_type == RenderFrameHostCheckType::kTopFrame && rfh->GetParent()) {
          Olga Sharonova . resolved

          Can be nullptr?

          Sunggook Chue

          Done

          Line 89, Patchset 9: RenderFrameHost* render_frame_host) {
          Olga Sharonova . resolved

          Can be deleted on UI thread meanwhile, can't it?

          Sunggook Chue

          it could be, but it doesn't matter because it is just int_ptr type for key, no object access.

          Line 93, Patchset 9: media::OutputDeviceStatus::OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED);
          Olga Sharonova . resolved

          Any other possible reasons for it being nullptr?

          Sunggook Chue

          It is common pattern of RenderFrameHost::FromID where the caller ensure it returns nullptr. I'm not expert in that area, but I assume that the frame host process or frame could be terminated.

          Line 98, Patchset 9: DCHECK_EQ(render_frame_host->GetMainFrame(), render_frame_host);
          Olga Sharonova . resolved

          Not thread-safe?

          Sunggook Chue

          no, GetMainFrame is one of thread agnostic methods in the RenderFrameHostImpl.

          Line 134, Patchset 8: &GetRenderFrameHostOnUIThread,
          device_switcher->GetGlobalRenderFrameHostId(),
          Olga Sharonova . resolved

          I think we should reconsider this part of PreferredAudioOutputDeviceManager. Why do we make it fetch the host, rather than providing it? For example, the host is known for the Broker aka Switcher during its creation, isn't it? So Switcher can have a getter for it, rather than for its id.
          If we make PreferredAudioOutputDeviceManager to work with main frame directly, the threading will be much simpler and safer.
          Am I missing something?

          Sunggook Chue

          Actually, Broker is on the IO thread only and its knowledge of the Host is limited to its integer ID (process id, frame id), not a RenderFrameHost object.

          We need to get RenderFrameHost to tell if it is main or sub, and RenderFrameHost can be acquired from the IDs only in the UI thread.

          Olga Sharonova

          It's not set in stone, we can reconsider it/add additional information. What would be the problems if a broker holds to the host, passed in the constructor? It can also be in an anonymous form of "group id" (see the comment below).

          I'm not proposing to rewrite everything immediately, but I think we should consider this options. The current design is quite complicated and not very robust to future changes; maybe that would simplify it.

          Sunggook Chue

          The client who passed the host should do same thing as the client is in the IO thread: IOThread -> UIThread -> IOThread.

          https://docs.google.com/document/d/1xVn0VwLa8w7jwXl6aeOfYn0mYK7zEc4pSmHelHAbi2g/edit?usp=sharing

          "The Browser has to cache the default sink id for the main RenderFrameHost, but the input is process id and frame id so it has to retrieve RenderFrameHost on the UI thread after being called on the IO thread. Once it retrieves RenderFrameHost on the UI thread, it has to return to the IO thread in order to call the Switcher. The logic seems too complicated, can we find simplified file solution here."

          Line 199, Patchset 9: RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
          Olga Sharonova . resolved

          Not thread-safe?

          Sunggook Chue

          ditto above, multi threads method.

          Line 207, Patchset 7:void PreferredAudioOutputDeviceManager::RemoveSwitcherEntry(
          Olga Sharonova . resolved

          I don't think this works. This method is called in the broker destructor. When it exits, the device switcher pointer is no longer valid. However, we jump through UI thread and back to IO before actually removing it from the map. Meanwhile, there may be preferred device switch calls already scheduled on IO thread, and they will call the already deleted switcher before we get to RemoveSwitcherEntryOnIOThread().

          Please see above my request for sequence diagrams. There may be other problems like that, for example when web content is gone.

          Sunggook Chue

          The current logic is same with 'NotifyFrameHostOfAudioStreamStopped', which is called in AudioOutputStreamBroker dtor and operate on UI thread.

          All it needs the RenderFrameHost object is alive on the UI thread, and it doesn't have to live when it back to the IO thread as it is nothing but a integer.

          It is called on the UI thread for WebContents, where it is even safer than broker since it doesn't have to switch to UI thread.

          It's not convenient to draw sequence diagram on the /h file, anyway, tried.

          Olga Sharonova

          I mean: *a* sequence diagram - in any readable format, not in .h file. Since we have not discussed this in a design doc, and the interactions are rather complex. Also, because I just described a problem with these sequences.

          I don't see how your comment addresses the situation I described though: SetPreferredSinkIdOnIOThread() being called while we jump here from IO thread to UI and back to removed a deleted switcher from the map.

          Sunggook Chue

          That's good point, probably we will have to use WeakPtr for the store of the Switcher interface. updated.

          Olga Sharonova

          SG. I'm still looking forward to a sequence diagram describing thread jumps. Can be added to the design doc, for example. Or be in any other readable form.

          Line 233, Patchset 9: RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
          Olga Sharonova . resolved

          not thread-safe?

          Sunggook Chue

          ditto,

          Line 238, Patchset 8:void PreferredAudioOutputDeviceManager::RemoveRenderFrameHostEntry(
          Olga Sharonova . resolved

          There may be SetPreferredSinkIdOnIOThread() scheduled before RemoveRenderFrameHostEntryEntryOnIOThread is called.

          Sunggook Chue

          Yes, it could be, but the worst case is that SetPreferredSinkIdOnIOThread will call the SwitchAudioOutputDeviceId of the broker, but the broker could have been called if not deleted from the list yey; The broker is a WeakPtr already that will be handled gracefully there whether the Broker is still alive or not.

          Olga Sharonova

          With added weak pointers - yes.
          But how about render_frame_host deleted on UI thread before/during any IO thread calls accessing it?


          I'd prefer this CL treating RenderFrameHost* as an anonymous "group id" (and Switcher interface providing a getter for it). Would be much safer and simpler, and a better separation of concerns - as far as I can see.

          Sunggook Chue

          When RFH (RenderFrameHost) is before/deleted in the during of IO thread calls, it doesn't affect the call as it doesn't access the object on the IO thread, and WeakPtr for Switcher also protect the Broker pointer access.

          I really wish we don't have to use RenderFrameHost, but unfortunately we need to find a main RenderFrameHost whether the requested host is related to the called setDefaultSinkId. But there is no way at this time to figure out whether 2 different RenderFrameHostId belongs to same main RenderFrameHost. I added your proposal under the open issues.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Gabriel Brito
          • Guido Urdaneta
          • Olga Sharonova
          • Steve Becker
          Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement is not satisfiedCode-Review
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
          Gerrit-Change-Number: 5664173
          Gerrit-PatchSet: 11
          Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
          Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
          Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
          Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
          Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
          Gerrit-Attention: Steve Becker <ste...@microsoft.com>
          Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
          Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
          Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
          Gerrit-Comment-Date: Tue, 06 Aug 2024 22:17:27 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Guido Urdaneta <gui...@chromium.org>
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Sunggook Chue (Gerrit)

          unread,
          Aug 6, 2024, 6:34:52 PM8/6/24
          to AyeAye, Olga Sharonova, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
          Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova and Steve Becker

          Sunggook Chue added 1 comment

          File chrome/browser/ui/side_panel/OWNERS
          Line 3, Patchset 12 (Latest):tl...@chromium.org
          Sunggook Chue . unresolved

          Olga, lease ignore this file as I edited to avoid upload issue that has been issue last couple of days. I will remove this one before landing, or have Lei https://chromium-review.googlesource.com/c/chromium/src/+/5735589 reviewed this file.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Gabriel Brito
          • Guido Urdaneta
          • Olga Sharonova
          • Steve Becker
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Review
            • requirement is not satisfiedNo-Unresolved-Comments
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
            Gerrit-Change-Number: 5664173
            Gerrit-PatchSet: 12
            Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
            Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
            Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
            Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
            Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
            Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
            Gerrit-Attention: Steve Becker <ste...@microsoft.com>
            Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
            Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
            Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
            Gerrit-Comment-Date: Tue, 06 Aug 2024 22:34:41 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Sunggook Chue (Gerrit)

            unread,
            Aug 6, 2024, 6:54:46 PM8/6/24
            to AyeAye, Olga Sharonova, Guido Urdaneta, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
            Attention needed from Gabriel Brito, Guido Urdaneta, Olga Sharonova and Steve Becker

            Sunggook Chue added 1 comment

            File chrome/browser/ui/side_panel/OWNERS

            Olga, lease ignore this file as I edited to avoid upload issue that has been issue last couple of days. I will remove this one before landing, or have Lei https://chromium-review.googlesource.com/c/chromium/src/+/5735589 reviewed this file.

            Sunggook Chue

            Done

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Gabriel Brito
            • Guido Urdaneta
            • Olga Sharonova
            • Steve Becker
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Review
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
            Gerrit-Change-Number: 5664173
            Gerrit-PatchSet: 13
            Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
            Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
            Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
            Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
            Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
            Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
            Gerrit-Attention: Steve Becker <ste...@microsoft.com>
            Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
            Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
            Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
            Gerrit-Comment-Date: Tue, 06 Aug 2024 22:54:35 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Guido Urdaneta (Gerrit)

            unread,
            Aug 8, 2024, 4:23:36 AM8/8/24
            to Sunggook Chue, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
            Attention needed from Gabriel Brito, Olga Sharonova, Steve Becker and Sunggook Chue

            Guido Urdaneta added 1 comment

            Patchset-level comments
            File-level comment, Patchset 14 (Latest):
            Guido Urdaneta . resolved

            moving myself to cc since Olga is the main owner here and her review should be enough.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Gabriel Brito
            • Olga Sharonova
            • Steve Becker
            • Sunggook Chue
            Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement is not satisfiedCode-Review
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
            Gerrit-Change-Number: 5664173
            Gerrit-PatchSet: 14
            Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
            Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
            Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
            Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
            Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
            Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
            Gerrit-Attention: Steve Becker <ste...@microsoft.com>
            Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
            Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
            Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
            Gerrit-Comment-Date: Thu, 08 Aug 2024 08:23:25 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: No
            satisfied_requirement
            unsatisfied_requirement
            open
            diffy

            Olga Sharonova (Gerrit)

            unread,
            Aug 16, 2024, 10:54:52 AM8/16/24
            to Sunggook Chue, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
            Attention needed from Gabriel Brito, Steve Becker and Sunggook Chue

            Olga Sharonova added 8 comments

            Patchset-level comments
            File-level comment, Patchset 15 (Latest):
            Olga Sharonova . resolved

            Please do not mark the comments as resolved until the consensus is reached. Looks like there are several discussions lost in the resolved comments.

            Also, I explained before: since there is no detailed design, I can't review the class without seeing the context, so a follow-up CL is needed.

            I remember I asked for a sequence diagram, it's probably somewhere in the resolved comments - could you point to it? Thanks!

            File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
            Line 89, Patchset 9: RenderFrameHost* render_frame_host) {
            Olga Sharonova . unresolved

            Can be deleted on UI thread meanwhile, can't it?

            Sunggook Chue

            it could be, but it doesn't matter because it is just int_ptr type for key, no object access.

            Olga Sharonova

            There is a data race: below: render_frame_host->GetMainFrame()

            Line 98, Patchset 9: DCHECK_EQ(render_frame_host->GetMainFrame(), render_frame_host);
            Olga Sharonova . unresolved

            Not thread-safe?

            Sunggook Chue

            no, GetMainFrame is one of thread agnostic methods in the RenderFrameHostImpl.

            Olga Sharonova

            See above: looks like a data race. (Also we can't conclude that the API is thread agnostic base on one of implementations.)

            Line 132, Patchset 15 (Latest): device_switcher->GetGlobalRenderFrameHostId();
            Olga Sharonova . unresolved

            device_switcher is a WeakPtr => can be null.

            Line 199, Patchset 9: RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
            Olga Sharonova . unresolved

            Not thread-safe?

            Sunggook Chue

            ditto above, multi threads method.

            Olga Sharonova

            Same here: data race accessing render_frame_host?

            Line 214, Patchset 15 (Latest): device_switcher->GetGlobalRenderFrameHostId();
            Olga Sharonova . unresolved

            Here and in other places: device_switcher is a WeakPtr => can be null.

            Line 233, Patchset 9: RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
            Olga Sharonova . unresolved

            not thread-safe?

            Sunggook Chue

            ditto,

            Olga Sharonova

            same

            Line 238, Patchset 8:void PreferredAudioOutputDeviceManager::RemoveRenderFrameHostEntry(
            Olga Sharonova . unresolved

            There may be SetPreferredSinkIdOnIOThread() scheduled before RemoveRenderFrameHostEntryEntryOnIOThread is called.

            Sunggook Chue

            Yes, it could be, but the worst case is that SetPreferredSinkIdOnIOThread will call the SwitchAudioOutputDeviceId of the broker, but the broker could have been called if not deleted from the list yey; The broker is a WeakPtr already that will be handled gracefully there whether the Broker is still alive or not.

            Olga Sharonova

            With added weak pointers - yes.
            But how about render_frame_host deleted on UI thread before/during any IO thread calls accessing it?


            I'd prefer this CL treating RenderFrameHost* as an anonymous "group id" (and Switcher interface providing a getter for it). Would be much safer and simpler, and a better separation of concerns - as far as I can see.

            Sunggook Chue

            When RFH (RenderFrameHost) is before/deleted in the during of IO thread calls, it doesn't affect the call as it doesn't access the object on the IO thread, and WeakPtr for Switcher also protect the Broker pointer access.

            I really wish we don't have to use RenderFrameHost, but unfortunately we need to find a main RenderFrameHost whether the requested host is related to the called setDefaultSinkId. But there is no way at this time to figure out whether 2 different RenderFrameHostId belongs to same main RenderFrameHost. I added your proposal under the open issues.

            Olga Sharonova

            I'm not sure we are talking about the same problem. This code is calling methods of raw pointer (render_frame_host) while it may be being deleted on UI thread.

            Open in Gerrit

            Related details

            Attention is currently required from:
            • Gabriel Brito
            • Steve Becker
            • Sunggook Chue
            Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
              Gerrit-Change-Number: 5664173
              Gerrit-PatchSet: 15
              Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
              Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
              Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
              Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
              Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
              Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
              Gerrit-Attention: Steve Becker <ste...@microsoft.com>
              Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
              Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
              Gerrit-Comment-Date: Fri, 16 Aug 2024 14:54:37 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Olga Sharonova (Gerrit)

              unread,
              Aug 16, 2024, 11:31:19 AM8/16/24
              to Sunggook Chue, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
              Attention needed from Gabriel Brito, Guido Urdaneta, Steve Becker and Sunggook Chue

              Olga Sharonova added 4 comments

              Patchset-level comments
              Olga Sharonova . unresolved

              I still think it would probably be more effective to discuss the design of this class: where it lives, where its dependencies live, how all their lifetimes are managed, what is accessed on which threads, etc; rather than doing massive iterations on the source code.

              File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
              Line 154, Patchset 15 (Latest): std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
              Olga Sharonova . unresolved

              Why do we mention web contents here? Let's keep consistent terminoligy.

              Line 145, Patchset 10: std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
              Guido Urdaneta . unresolved

              Using raw pointers that can go dangling as keys a map looks dangerous to me.
              Can you replace it with the global routing IDs?

              Sunggook Chue

              global routing id can't give any information of the called render frame host (RFH)'s relation to its top RFH or children RFH.

              for example, RFH_A (top), RFH_B(top) are cached entries. And when RHF_C (child) is called, it should tell which RFH RHF_C child of? global ID can't help.

              Olga Sharonova

              https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/render_frame_host.h;l=129;drc=0a301506035e13015ea5c8dd39164d0d5954fa60;bpv=1;bpt=1


              There is a way to get RFH from global ID. However, RenderFrameHost::FromID can only be called on the UI thread.
              Looks like this CL is using a raw pointer to RHF in a non-threadsafe manner.


              Why have you decided to make it PreferredAudioOutputDeviceManager's responsibility to traverse the tree? Why can't it always accept only the global id of the main frame and live peacefully on IO thread, and let the caller take care of finding that id?

              File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
              Line 238, Patchset 8:void PreferredAudioOutputDeviceManager::RemoveRenderFrameHostEntry(
              Olga Sharonova . unresolved

              There may be SetPreferredSinkIdOnIOThread() scheduled before RemoveRenderFrameHostEntryEntryOnIOThread is called.

              Sunggook Chue

              Yes, it could be, but the worst case is that SetPreferredSinkIdOnIOThread will call the SwitchAudioOutputDeviceId of the broker, but the broker could have been called if not deleted from the list yey; The broker is a WeakPtr already that will be handled gracefully there whether the Broker is still alive or not.

              Olga Sharonova

              With added weak pointers - yes.
              But how about render_frame_host deleted on UI thread before/during any IO thread calls accessing it?


              I'd prefer this CL treating RenderFrameHost* as an anonymous "group id" (and Switcher interface providing a getter for it). Would be much safer and simpler, and a better separation of concerns - as far as I can see.

              Sunggook Chue

              When RFH (RenderFrameHost) is before/deleted in the during of IO thread calls, it doesn't affect the call as it doesn't access the object on the IO thread, and WeakPtr for Switcher also protect the Broker pointer access.

              I really wish we don't have to use RenderFrameHost, but unfortunately we need to find a main RenderFrameHost whether the requested host is related to the called setDefaultSinkId. But there is no way at this time to figure out whether 2 different RenderFrameHostId belongs to same main RenderFrameHost. I added your proposal under the open issues.

              Olga Sharonova

              I'm not sure we are talking about the same problem. This code is calling methods of raw pointer (render_frame_host) while it may be being deleted on UI thread.

              Olga Sharonova

              *may have been deleted

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Gabriel Brito
              • Guido Urdaneta
              • Steve Becker
              • Sunggook Chue
              Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
              Gerrit-Change-Number: 5664173
              Gerrit-PatchSet: 15
              Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
              Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
              Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
              Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
              Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
              Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
              Gerrit-Attention: Steve Becker <ste...@microsoft.com>
              Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
              Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
              Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
              Gerrit-Comment-Date: Fri, 16 Aug 2024 15:31:07 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              Comment-In-Reply-To: Guido Urdaneta <gui...@chromium.org>
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Guido Urdaneta (Gerrit)

              unread,
              Aug 17, 2024, 7:48:23 AM8/17/24
              to Sunggook Chue, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
              Attention needed from Gabriel Brito, Olga Sharonova, Steve Becker and Sunggook Chue

              Guido Urdaneta added 1 comment

              File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
              Line 145, Patchset 10: std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
              Guido Urdaneta . unresolved

              Using raw pointers that can go dangling as keys a map looks dangerous to me.
              Can you replace it with the global routing IDs?

              Sunggook Chue

              global routing id can't give any information of the called render frame host (RFH)'s relation to its top RFH or children RFH.

              for example, RFH_A (top), RFH_B(top) are cached entries. And when RHF_C (child) is called, it should tell which RFH RHF_C child of? global ID can't help.

              Olga Sharonova

              https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/render_frame_host.h;l=129;drc=0a301506035e13015ea5c8dd39164d0d5954fa60;bpv=1;bpt=1


              There is a way to get RFH from global ID. However, RenderFrameHost::FromID can only be called on the UI thread.
              Looks like this CL is using a raw pointer to RHF in a non-threadsafe manner.


              Why have you decided to make it PreferredAudioOutputDeviceManager's responsibility to traverse the tree? Why can't it always accept only the global id of the main frame and live peacefully on IO thread, and let the caller take care of finding that id?

              Guido Urdaneta

              raw pointers can become dangling or can be reused if the originals are destroyed and new objects created.
              There is a 1:1 mapping between routing IDs and RFHs (https://crsrc.org/c/content/browser/renderer_host/render_frame_host_impl.h;l=347) and you can't access RFHs outside the main thread, so it's better to use routing IDs (which don't have the issues raw pointers have) outside of the main thread.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Gabriel Brito
              • Olga Sharonova
              • Steve Becker
              • Sunggook Chue
              Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement is not satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
              Gerrit-Change-Number: 5664173
              Gerrit-PatchSet: 15
              Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
              Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
              Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
              Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
              Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
              Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
              Gerrit-Attention: Steve Becker <ste...@microsoft.com>
              Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
              Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
              Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
              Gerrit-Comment-Date: Sat, 17 Aug 2024 11:48:12 +0000
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Sunggook Chue (Gerrit)

              unread,
              Aug 19, 2024, 8:16:22 PM8/19/24
              to Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
              Attention needed from Olga Sharonova

              Sunggook Chue added 10 comments

              Patchset-level comments
              File-level comment, Patchset 15:
              Olga Sharonova . resolved

              I still think it would probably be more effective to discuss the design of this class: where it lives, where its dependencies live, how all their lifetimes are managed, what is accessed on which threads, etc; rather than doing massive iterations on the source code.

              Sunggook Chue

              I believe I've explained few times but it looks like it isn't perfect or we are lost during conversation, basically it is same with VideoCaptureManager in terms of lifetime and its threading model if you're familiar with media components in the browser.

              Anyway, I've added threading model and dependency on the design doc. Please leave a comments if need more clarification.

              https://docs.google.com/document/d/1xVn0VwLa8w7jwXl6aeOfYn0mYK7zEc4pSmHelHAbi2g/edit?usp=sharing

              File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
              Line 154, Patchset 15: std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
              Olga Sharonova . resolved

              Why do we mention web contents here? Let's keep consistent terminoligy.

              Sunggook Chue

              it's good point, updated it.

              Line 145, Patchset 10: std::map<RenderFrameHost*, WebContentsSinkId> web_contents_to_sink_ids_;
              Guido Urdaneta . resolved

              Using raw pointers that can go dangling as keys a map looks dangerous to me.
              Can you replace it with the global routing IDs?

              Sunggook Chue

              global routing id can't give any information of the called render frame host (RFH)'s relation to its top RFH or children RFH.

              for example, RFH_A (top), RFH_B(top) are cached entries. And when RHF_C (child) is called, it should tell which RFH RHF_C child of? global ID can't help.

              Olga Sharonova

              https://source.chromium.org/chromium/chromium/src/+/main:content/public/browser/render_frame_host.h;l=129;drc=0a301506035e13015ea5c8dd39164d0d5954fa60;bpv=1;bpt=1


              There is a way to get RFH from global ID. However, RenderFrameHost::FromID can only be called on the UI thread.
              Looks like this CL is using a raw pointer to RHF in a non-threadsafe manner.


              Why have you decided to make it PreferredAudioOutputDeviceManager's responsibility to traverse the tree? Why can't it always accept only the global id of the main frame and live peacefully on IO thread, and let the caller take care of finding that id?

              Guido Urdaneta

              raw pointers can become dangling or can be reused if the originals are destroyed and new objects created.
              There is a 1:1 mapping between routing IDs and RFHs (https://crsrc.org/c/content/browser/renderer_host/render_frame_host_impl.h;l=347) and you can't access RFHs outside the main thread, so it's better to use routing IDs (which don't have the issues raw pointers have) outside of the main thread.

              Sunggook Chue

              The problem is that we have to figure out the parent and child relationship. for example, the parent RFH calls SetPreferredSinkId, then its all sub frames will use preferred sink id. we can't figure out these parent/child relationship with routing IDs. If there is a way for it, please let me know. I really want to go that path.

              File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
              Line 89, Patchset 9: RenderFrameHost* render_frame_host) {
              Olga Sharonova . resolved

              Can be deleted on UI thread meanwhile, can't it?

              Sunggook Chue

              it could be, but it doesn't matter because it is just int_ptr type for key, no object access.

              Olga Sharonova

              There is a data race: below: render_frame_host->GetMainFrame()

              Sunggook Chue

              updated based on the above feedback. thanks.

              Line 98, Patchset 9: DCHECK_EQ(render_frame_host->GetMainFrame(), render_frame_host);
              Olga Sharonova . resolved

              Not thread-safe?

              Sunggook Chue

              no, GetMainFrame is one of thread agnostic methods in the RenderFrameHostImpl.

              Olga Sharonova

              See above: looks like a data race. (Also we can't conclude that the API is thread agnostic base on one of implementations.)

              Sunggook Chue

              Done

              Line 132, Patchset 15: device_switcher->GetGlobalRenderFrameHostId();
              Olga Sharonova . resolved

              device_switcher is a WeakPtr => can be null.

              Sunggook Chue

              It is direct call from the device_switcher, so leave it as it is so that we can capture the invalid call here, instead add hardening in the IO thread. thanks.

              Line 199, Patchset 9: RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
              Olga Sharonova . resolved

              Not thread-safe?

              Sunggook Chue

              ditto above, multi threads method.

              Olga Sharonova

              Same here: data race accessing render_frame_host?

              Sunggook Chue

              actually GetMainFrame can be accessed from any threads, but I've removed this one from the IO thread based on other feedback.

              Line 214, Patchset 15: device_switcher->GetGlobalRenderFrameHostId();
              Olga Sharonova . resolved

              Here and in other places: device_switcher is a WeakPtr => can be null.

              Sunggook Chue

              will add CHECK here as it should be called from the AudioOutputDeviceSwitcher object.

              Line 233, Patchset 9: RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
              Olga Sharonova . resolved

              not thread-safe?

              Sunggook Chue

              ditto,

              Olga Sharonova

              same

              Sunggook Chue

              Done

              Line 238, Patchset 8:void PreferredAudioOutputDeviceManager::RemoveRenderFrameHostEntry(
              Olga Sharonova . resolved

              There may be SetPreferredSinkIdOnIOThread() scheduled before RemoveRenderFrameHostEntryEntryOnIOThread is called.

              Sunggook Chue

              Yes, it could be, but the worst case is that SetPreferredSinkIdOnIOThread will call the SwitchAudioOutputDeviceId of the broker, but the broker could have been called if not deleted from the list yey; The broker is a WeakPtr already that will be handled gracefully there whether the Broker is still alive or not.

              Olga Sharonova

              With added weak pointers - yes.
              But how about render_frame_host deleted on UI thread before/during any IO thread calls accessing it?


              I'd prefer this CL treating RenderFrameHost* as an anonymous "group id" (and Switcher interface providing a getter for it). Would be much safer and simpler, and a better separation of concerns - as far as I can see.

              Sunggook Chue

              When RFH (RenderFrameHost) is before/deleted in the during of IO thread calls, it doesn't affect the call as it doesn't access the object on the IO thread, and WeakPtr for Switcher also protect the Broker pointer access.

              I really wish we don't have to use RenderFrameHost, but unfortunately we need to find a main RenderFrameHost whether the requested host is related to the called setDefaultSinkId. But there is no way at this time to figure out whether 2 different RenderFrameHostId belongs to same main RenderFrameHost. I added your proposal under the open issues.

              Olga Sharonova

              I'm not sure we are talking about the same problem. This code is calling methods of raw pointer (render_frame_host) while it may be being deleted on UI thread.

              Olga Sharonova

              *may have been deleted

              Sunggook Chue

              We should not access RenderFrameHost's methods in the IO thread, instead just use it. updated the code for that. thanks.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Olga Sharonova
              Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement is not satisfiedCode-Review
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
              Gerrit-Change-Number: 5664173
              Gerrit-PatchSet: 16
              Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
              Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
              Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
              Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
              Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
              Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
              Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
              Gerrit-Comment-Date: Tue, 20 Aug 2024 00:16:08 +0000
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Olga Sharonova (Gerrit)

              unread,
              Aug 21, 2024, 1:35:06 PM8/21/24
              to Sunggook Chue, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
              Attention needed from Sunggook Chue

              Olga Sharonova added 10 comments

              Patchset-level comments
              Olga Sharonova . resolved

              I still think it would probably be more effective to discuss the design of this class: where it lives, where its dependencies live, how all their lifetimes are managed, what is accessed on which threads, etc; rather than doing massive iterations on the source code.

              Sunggook Chue

              I believe I've explained few times but it looks like it isn't perfect or we are lost during conversation, basically it is same with VideoCaptureManager in terms of lifetime and its threading model if you're familiar with media components in the browser.

              Anyway, I've added threading model and dependency on the design doc. Please leave a comments if need more clarification.

              https://docs.google.com/document/d/1xVn0VwLa8w7jwXl6aeOfYn0mYK7zEc4pSmHelHAbi2g/edit?usp=sharing

              Olga Sharonova

              Thanks. This reply was also almost lost: as I asked earlier, please do not resolve the comment until we reach a consensus. It's hard to dig up the resolved comments. "Similar to something" is not helpful when looking at the new class.

              File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
              Line 10, Patchset 16 (Latest):#include "content/browser/media/audio_output_stream_broker.h"
              Olga Sharonova . unresolved

              There should be no direct dependency on output stream broker: the idea of the switcher interface is to decouple them.
              For that purpose the interface needs to be declared in this CL, and implemented in the broker in the next CL.

              Line 44, Patchset 16 (Latest):RenderFrameHost* GetRenderFrameHostOnUIThread(
              Olga Sharonova . unresolved

              GetMain... or something?

              Line 90, Patchset 16 (Latest): RenderFrameHost* main_frame) {
              Olga Sharonova . unresolved

              Hmm. Why pointers rather than GlobalRenderFrameHostId everywhere? Haven't we just agreed on that?

              Line 132, Patchset 15: device_switcher->GetGlobalRenderFrameHostId();
              Olga Sharonova . unresolved

              device_switcher is a WeakPtr => can be null.

              Sunggook Chue

              It is direct call from the device_switcher, so leave it as it is so that we can capture the invalid call here, instead add hardening in the IO thread. thanks.

              Olga Sharonova

              Then better to pass it as a reference and have a AsWeakPtr() method on the switcher.

              Line 138, Patchset 16 (Latest): &GetRenderFrameHostOnUIThread, rfh_id,
              Olga Sharonova . unresolved

              I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

              Line 166, Patchset 16 (Latest): AddSwitcherAndGetOverrideDeviceIdOnIOThread(
              Olga Sharonova . unresolved

              We need to rename these types of methods: "OnThread" naming is used if the original method is called on thread X, and it's trampolined to thread Y. In our case it starts already on IO thread.

              Line 199, Patchset 9: RenderFrameHost* main_frame = render_frame_host->GetMainFrame();
              Olga Sharonova . resolved

              Not thread-safe?

              Sunggook Chue

              ditto above, multi threads method.

              Olga Sharonova

              Same here: data race accessing render_frame_host?

              Sunggook Chue

              actually GetMainFrame can be accessed from any threads, but I've removed this one from the IO thread based on other feedback.

              Olga Sharonova

              As I said, the race was accessing *render_frame_host pointer*, not anything in its method.

              Line 214, Patchset 15: device_switcher->GetGlobalRenderFrameHostId();
              Olga Sharonova . unresolved

              Here and in other places: device_switcher is a WeakPtr => can be null.

              Sunggook Chue

              will add CHECK here as it should be called from the AudioOutputDeviceSwitcher object.

              Olga Sharonova

              What is the point of calling it with the weak pointer?

              Line 238, Patchset 16 (Latest):
              // We don't check device_switcher is valid or not during RemoveSwitcher
              // because we just use it as a interger key value for cleanup.
              Olga Sharonova . unresolved

              Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

              Open in Gerrit

              Related details

              Attention is currently required from:
              • Sunggook Chue
              Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement is not satisfiedCode-Review
                • requirement is not satisfiedNo-Unresolved-Comments
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                Gerrit-Change-Number: 5664173
                Gerrit-PatchSet: 16
                Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                Gerrit-Comment-Date: Wed, 21 Aug 2024 17:34:47 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                satisfied_requirement
                unsatisfied_requirement
                open
                diffy

                Olga Sharonova (Gerrit)

                unread,
                Aug 21, 2024, 1:42:40 PM8/21/24
                to Sunggook Chue, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                Attention needed from Sunggook Chue

                Olga Sharonova added 1 comment

                File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                Line 138, Patchset 16 (Latest): &GetRenderFrameHostOnUIThread, rfh_id,
                Olga Sharonova . unresolved

                I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

                Olga Sharonova

                See RenderFrameAudioOutputStreamFactory constructor.

                Gerrit-Comment-Date: Wed, 21 Aug 2024 17:42:25 +0000
                satisfied_requirement
                unsatisfied_requirement
                open
                diffy

                Sunggook Chue (Gerrit)

                unread,
                Aug 21, 2024, 8:59:11 PM8/21/24
                to Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                Attention needed from Olga Sharonova

                Sunggook Chue added 9 comments

                Patchset-level comments
                File-level comment, Patchset 17 (Latest):
                Sunggook Chue . resolved

                addressed comments.

                File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                Line 10, Patchset 16:#include "content/browser/media/audio_output_stream_broker.h"
                Olga Sharonova . resolved

                There should be no direct dependency on output stream broker: the idea of the switcher interface is to decouple them.
                For that purpose the interface needs to be declared in this CL, and implemented in the broker in the next CL.

                Sunggook Chue

                AudioOutputDeviceSwitcher is declared in the media/audio_output_stream_broker.h.

                I will move declare AudioOutputDeviceSwitcher in the preferred_audio_output_device_manager.h.

                Line 44, Patchset 16:RenderFrameHost* GetRenderFrameHostOnUIThread(
                Olga Sharonova . resolved

                GetMain... or something?

                Sunggook Chue

                Done

                Line 90, Patchset 16: RenderFrameHost* main_frame) {
                Olga Sharonova . resolved

                Hmm. Why pointers rather than GlobalRenderFrameHostId everywhere? Haven't we just agreed on that?

                Sunggook Chue

                We don't have to use GlobalRenderFrameHostId as RenderFrameHost* is just integer as a key.

                It is simpler even when it is called from the MediaWebContentsObserver where RenderFrameHost*.

                Line 132, Patchset 15: device_switcher->GetGlobalRenderFrameHostId();
                Olga Sharonova . resolved

                device_switcher is a WeakPtr => can be null.

                Sunggook Chue

                It is direct call from the device_switcher, so leave it as it is so that we can capture the invalid call here, instead add hardening in the IO thread. thanks.

                Olga Sharonova

                Then better to pass it as a reference and have a AsWeakPtr() method on the switcher.

                Sunggook Chue

                sounds good.

                Line 138, Patchset 16: &GetRenderFrameHostOnUIThread, rfh_id,
                Olga Sharonova . resolved

                I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

                Olga Sharonova

                See RenderFrameAudioOutputStreamFactory constructor.

                Sunggook Chue

                It looks like the object is called from the UI thread object RenderFrameHostImpl, meanwhile AudioOutputSreamBreaker, which call PreferredAudioOutputDeviceManager, is called on IO thread.

                Afaik, most of media components (video/audio) that hooks btw Renderer and Utility Services are on IO thread bound.

                If needed, we can ask Guido to review this CL (and browser side changes) if needed as he is well aware of it.

                Line 166, Patchset 16: AddSwitcherAndGetOverrideDeviceIdOnIOThread(
                Olga Sharonova . resolved

                We need to rename these types of methods: "OnThread" naming is used if the original method is called on thread X, and it's trampolined to thread Y. In our case it starts already on IO thread.

                Sunggook Chue

                that make sense, how about 'WithMainFrame'.

                Line 214, Patchset 15: device_switcher->GetGlobalRenderFrameHostId();
                Olga Sharonova . resolved

                Here and in other places: device_switcher is a WeakPtr => can be null.

                Sunggook Chue

                will add CHECK here as it should be called from the AudioOutputDeviceSwitcher object.

                Olga Sharonova

                What is the point of calling it with the weak pointer?

                Sunggook Chue

                To ensure that its object that implements AudioOutputDeviceSwitcher can be deleted before it is called like a BindOnce based callback.


                // We don't check device_switcher is valid or not during RemoveSwitcher
                // because we just use it as a interger key value for cleanup.
                Olga Sharonova . resolved

                Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                Sunggook Chue

                The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                I will add comments and test to validate it.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Olga Sharonova
                Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement is not satisfiedCode-Review
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                Gerrit-Change-Number: 5664173
                Gerrit-PatchSet: 17
                Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                Gerrit-Comment-Date: Thu, 22 Aug 2024 00:59:01 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
                satisfied_requirement
                unsatisfied_requirement
                open
                diffy

                Sunggook Chue (Gerrit)

                unread,
                Aug 22, 2024, 1:08:42 AM8/22/24
                to Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                Attention needed from Olga Sharonova

                Sunggook Chue added 1 comment

                File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                Line 90, Patchset 16: RenderFrameHost* main_frame) {
                Olga Sharonova . resolved

                Hmm. Why pointers rather than GlobalRenderFrameHostId everywhere? Haven't we just agreed on that?

                Sunggook Chue

                We don't have to use GlobalRenderFrameHostId as RenderFrameHost* is just integer as a key.

                It is simpler even when it is called from the MediaWebContentsObserver where RenderFrameHost*.

                Sunggook Chue

                rethink and using GlobalId as RenderFrameHost could mean UI thread.

                Gerrit-Comment-Date: Thu, 22 Aug 2024 05:08:29 +0000
                satisfied_requirement
                unsatisfied_requirement
                open
                diffy

                Olga Sharonova (Gerrit)

                unread,
                Aug 23, 2024, 9:27:42 AM8/23/24
                to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                Attention needed from Olga Sharonova and Sunggook Chue

                Olga Sharonova added 2 comments

                File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                Line 138, Patchset 16: &GetRenderFrameHostOnUIThread, rfh_id,
                Olga Sharonova . unresolved

                I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

                Olga Sharonova

                See RenderFrameAudioOutputStreamFactory constructor.

                Sunggook Chue

                It looks like the object is called from the UI thread object RenderFrameHostImpl, meanwhile AudioOutputSreamBreaker, which call PreferredAudioOutputDeviceManager, is called on IO thread.

                Afaik, most of media components (video/audio) that hooks btw Renderer and Utility Services are on IO thread bound.

                If needed, we can ask Guido to review this CL (and browser side changes) if needed as he is well aware of it.

                Olga Sharonova

                Sunggook, when you reply to the comments, there's a checkbox "resolved". I just asked you in the comment above **to not resolve the discussions in progress**. Please **do not mark the checkbox** for any ongoing discussion or when you are answering a question. I'll mark it as resolved when I've read an answer and have not follow-up questions. Resolved comments are getting lost. This makes my job as a reviewer unnecessary hard. And it causes situations when I have to ask the same question again.

                ---

                If you look at RenderFrameAudioOutputStreamFactory constructor (running on UI thread) you see it's constructing Core. Either RenderFrameAudioOutputStreamFactory 
                constructor or Core constructor can get the main frame id, since the construction is happening on UI thread. The rest of the Core lives on IO thread and can pass the main frame ID down the line (here https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;l=323;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa;bpv=1;bpt=1, etc); or IO thread code can just access it trough an IO thread getter at some point (to not plumb the same id through too many layers).

                I do not suggest to rewrite the code immediately, but I'm asking if this has been considered and why the current approach of dynamic fetch of the main frame id was chosen over an option of having a constant main frame id propagated to an IO thread object during construction.

                Line 238, Patchset 16:
                // We don't check device_switcher is valid or not during RemoveSwitcher
                // because we just use it as a interger key value for cleanup.
                Olga Sharonova . unresolved

                Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                Sunggook Chue

                The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                I will add comments and test to validate it.

                Olga Sharonova

                I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Olga Sharonova
                • Sunggook Chue
                Submit Requirements:
                  • requirement satisfiedCode-Coverage
                  • requirement is not satisfiedCode-Review
                  • requirement is not satisfiedNo-Unresolved-Comments
                  Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                  Gerrit-MessageType: comment
                  Gerrit-Project: chromium/src
                  Gerrit-Branch: main
                  Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                  Gerrit-Change-Number: 5664173
                  Gerrit-PatchSet: 18
                  Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                  Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                  Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                  Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                  Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                  Gerrit-CC: Olga Sharonova <ol...@google.com>
                  Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                  Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                  Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                  Gerrit-Comment-Date: Fri, 23 Aug 2024 13:27:31 +0000
                  satisfied_requirement
                  unsatisfied_requirement
                  open
                  diffy

                  Sunggook Chue (Gerrit)

                  unread,
                  Aug 23, 2024, 7:48:26 PM8/23/24
                  to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                  Attention needed from Olga Sharonova

                  Sunggook Chue added 3 comments

                  Patchset-level comments
                  File-level comment, Patchset 18 (Latest):
                  Sunggook Chue . resolved

                  replied comments, thanks.

                  File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                  Line 138, Patchset 16: &GetRenderFrameHostOnUIThread, rfh_id,
                  Olga Sharonova . resolved

                  I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

                  Olga Sharonova

                  See RenderFrameAudioOutputStreamFactory constructor.

                  Sunggook Chue

                  It looks like the object is called from the UI thread object RenderFrameHostImpl, meanwhile AudioOutputSreamBreaker, which call PreferredAudioOutputDeviceManager, is called on IO thread.

                  Afaik, most of media components (video/audio) that hooks btw Renderer and Utility Services are on IO thread bound.

                  If needed, we can ask Guido to review this CL (and browser side changes) if needed as he is well aware of it.

                  Olga Sharonova

                  Sunggook, when you reply to the comments, there's a checkbox "resolved". I just asked you in the comment above **to not resolve the discussions in progress**. Please **do not mark the checkbox** for any ongoing discussion or when you are answering a question. I'll mark it as resolved when I've read an answer and have not follow-up questions. Resolved comments are getting lost. This makes my job as a reviewer unnecessary hard. And it causes situations when I have to ask the same question again.

                  ---

                  If you look at RenderFrameAudioOutputStreamFactory constructor (running on UI thread) you see it's constructing Core. Either RenderFrameAudioOutputStreamFactory 
                  constructor or Core constructor can get the main frame id, since the construction is happening on UI thread. The rest of the Core lives on IO thread and can pass the main frame ID down the line (here https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;l=323;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa;bpv=1;bpt=1, etc); or IO thread code can just access it trough an IO thread getter at some point (to not plumb the same id through too many layers).

                  I do not suggest to rewrite the code immediately, but I'm asking if this has been considered and why the current approach of dynamic fetch of the main frame id was chosen over an option of having a constant main frame id propagated to an IO thread object during construction.

                  Sunggook Chue

                  I got your point.

                  So, we cache global Ids and its parent Ids (if it is sub frame) on IO thread through RenderFrameAudioOutputStreamFactory mechanism and retrieve the main frame global id without switching to UI thread.

                  The problem is that we need RenderFrameHostImpl object when called on the IO thread with globalId (most Media APIs is called on IO thread from the Renderer) in order to get the RenderFrameAudioOutputStreamFactory object. So switching to UI thread occurs.

                  Anything I missed?

                  Line 238, Patchset 16:
                  // We don't check device_switcher is valid or not during RemoveSwitcher
                  // because we just use it as a interger key value for cleanup.
                  Olga Sharonova . resolved

                  Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                  Sunggook Chue

                  The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                  I will add comments and test to validate it.

                  Olga Sharonova

                  I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                  Sunggook Chue

                  I will file a bug once it lands as the feature flag is disabled. We can't keep this CL open.

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Olga Sharonova
                  Submit Requirements:
                  • requirement satisfiedCode-Coverage
                  • requirement is not satisfiedCode-Review
                  Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                  Gerrit-MessageType: comment
                  Gerrit-Project: chromium/src
                  Gerrit-Branch: main
                  Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                  Gerrit-Change-Number: 5664173
                  Gerrit-PatchSet: 18
                  Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                  Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                  Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                  Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                  Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                  Gerrit-CC: Olga Sharonova <ol...@google.com>
                  Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                  Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                  Gerrit-Comment-Date: Fri, 23 Aug 2024 23:48:17 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No
                  Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                  Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
                  Comment-In-Reply-To: Olga Sharonova <ol...@google.com>
                  satisfied_requirement
                  unsatisfied_requirement
                  open
                  diffy

                  Olga Sharonova (Gerrit)

                  unread,
                  Aug 26, 2024, 4:14:45 AM8/26/24
                  to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                  Attention needed from Olga Sharonova and Sunggook Chue

                  Olga Sharonova added 2 comments

                  File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                  Line 138, Patchset 16: &GetRenderFrameHostOnUIThread, rfh_id,
                  Olga Sharonova . unresolved

                  I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

                  Olga Sharonova

                  See RenderFrameAudioOutputStreamFactory constructor.

                  Sunggook Chue

                  It looks like the object is called from the UI thread object RenderFrameHostImpl, meanwhile AudioOutputSreamBreaker, which call PreferredAudioOutputDeviceManager, is called on IO thread.

                  Afaik, most of media components (video/audio) that hooks btw Renderer and Utility Services are on IO thread bound.

                  If needed, we can ask Guido to review this CL (and browser side changes) if needed as he is well aware of it.

                  Olga Sharonova

                  Sunggook, when you reply to the comments, there's a checkbox "resolved". I just asked you in the comment above **to not resolve the discussions in progress**. Please **do not mark the checkbox** for any ongoing discussion or when you are answering a question. I'll mark it as resolved when I've read an answer and have not follow-up questions. Resolved comments are getting lost. This makes my job as a reviewer unnecessary hard. And it causes situations when I have to ask the same question again.

                  ---

                  If you look at RenderFrameAudioOutputStreamFactory constructor (running on UI thread) you see it's constructing Core. Either RenderFrameAudioOutputStreamFactory 
                  constructor or Core constructor can get the main frame id, since the construction is happening on UI thread. The rest of the Core lives on IO thread and can pass the main frame ID down the line (here https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;l=323;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa;bpv=1;bpt=1, etc); or IO thread code can just access it trough an IO thread getter at some point (to not plumb the same id through too many layers).

                  I do not suggest to rewrite the code immediately, but I'm asking if this has been considered and why the current approach of dynamic fetch of the main frame id was chosen over an option of having a constant main frame id propagated to an IO thread object during construction.

                  Sunggook Chue

                  I got your point.

                  So, we cache global Ids and its parent Ids (if it is sub frame) on IO thread through RenderFrameAudioOutputStreamFactory mechanism and retrieve the main frame global id without switching to UI thread.

                  The problem is that we need RenderFrameHostImpl object when called on the IO thread with globalId (most Media APIs is called on IO thread from the Renderer) in order to get the RenderFrameAudioOutputStreamFactory object. So switching to UI thread occurs.

                  Anything I missed?

                  Olga Sharonova

                  .

                  Line 238, Patchset 16:
                  // We don't check device_switcher is valid or not during RemoveSwitcher
                  // because we just use it as a interger key value for cleanup.
                  Olga Sharonova . unresolved

                  Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                  Sunggook Chue

                  The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                  I will add comments and test to validate it.

                  Olga Sharonova

                  I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                  Sunggook Chue

                  I will file a bug once it lands as the feature flag is disabled. We can't keep this CL open.

                  Olga Sharonova

                  .

                  Open in Gerrit

                  Related details

                  Attention is currently required from:
                  • Olga Sharonova
                  • Sunggook Chue
                  Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 18
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Mon, 26 Aug 2024 08:14:17 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Aug 26, 2024, 4:58:40 AM8/26/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    1) Could you explain why have you resolved the comment? Especially since it seems like you are asking a question.

                    2) I mean we cache the main frame global id.
                    Could you clarify "the problem"? What code are you referring to? (links, methods names?) When I described my idea, I added specific references. Could you do the same?

                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . unresolved

                    Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                    Sunggook Chue

                    The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                    I will add comments and test to validate it.

                    Olga Sharonova

                    I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                    Sunggook Chue

                    I will file a bug once it lands as the feature flag is disabled. We can't keep this CL open.

                    Olga Sharonova

                    .

                    Olga Sharonova

                    1) It was your choice to skip design discussions and iterate on the code instead. Figuring out a complex design without a clearly communicated high level vision is never easy ant takes time and many back and forth.

                    2) If you think I have any other agenda besides landing easy-to-maintain code of good quality - you are mistaken. But we cannot land it just for the sake of landing it, because it creates maintenance burden. As you noticed, the review has already uncovered multiple issues, including race conditions.
                    We need to fix the design issues before it lands.

                    3) The inconsistency of weak pointer treatment hints to a design issue. You can figure it out and fix it. Or I'll think about it when I have a bit of time.

                    4) The fact that you keep resolving in-progress discussions when I explicitly asked you not to, because it's very hard to keep track of them - I don't even know what to make of it. What's your goal?

                    Gerrit-Comment-Date: Mon, 26 Aug 2024 08:58:25 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Aug 26, 2024, 5:09:04 AM8/26/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 3 comments

                    Patchset-level comments
                    File-level comment, Patchset 18 (Latest):
                    Sunggook Chue . resolved

                    replied comments,

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    1. We have to access RenderFrameAudioOutputStreamFactory, which is a member of RenderFrameHost, which is accessed from only in the UI thread.

                    2. RenderFrameAudioOutputStreamFactory is created for every frames but preferred manager is accessed only when audio output request is made. If we cache the values for RenderFrameAudioOutputStreamFactory creation, it would increase the unnecessary cache size.

                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . unresolved

                    Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                    Sunggook Chue

                    The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                    I will add comments and test to validate it.

                    Olga Sharonova

                    I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                    Sunggook Chue

                    I will file a bug once it lands as the feature flag is disabled. We can't keep this CL open.

                    Olga Sharonova

                    .

                    Olga Sharonova

                    1) It was your choice to skip design discussions and iterate on the code instead. Figuring out a complex design without a clearly communicated high level vision is never easy ant takes time and many back and forth.

                    2) If you think I have any other agenda besides landing easy-to-maintain code of good quality - you are mistaken. But we cannot land it just for the sake of landing it, because it creates maintenance burden. As you noticed, the review has already uncovered multiple issues, including race conditions.
                    We need to fix the design issues before it lands.

                    3) The inconsistency of weak pointer treatment hints to a design issue. You can figure it out and fix it. Or I'll think about it when I have a bit of time.

                    4) The fact that you keep resolving in-progress discussions when I explicitly asked you not to, because it's very hard to keep track of them - I don't even know what to make of it. What's your goal?

                    Sunggook Chue

                    I already mentioned my design, please let me know what's your proposal. I don't see any design issue.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 18
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Mon, 26 Aug 2024 09:08:52 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Aug 26, 2024, 5:19:01 AM8/26/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    This is not answering my question though. What code are you referring to? Who "we"? When we have to access RenderFrameAudioOutputStreamFactory? What exactly are you talking about? Which operation?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 18
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Mon, 26 Aug 2024 09:18:48 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Gabriel Brito (Gerrit)

                    unread,
                    Aug 26, 2024, 7:42:57 PM8/26/24
                    to Sunggook Chue, Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova and Sunggook Chue

                    Gabriel Brito added 2 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Gabriel Brito

                    Please let me try to aid the discussion 😊

                    Olga, I think that what Sunggook is trying to say is that his mechanism of dynamically posting a `GetMainGlobalIdOnUIThread` task on the UI thread during `PreferredAudioOutputDeviceManager::AddSwitcherAndGetOverrideDeviceId`, which is called by `AudioOutputStreamBroker::CreateStream` (follow-up CL: https://chromium-review.googlesource.com/c/chromium/src/+/5685761/8), prevents the browser from caching sink ids for webpages that won't play any sound during their lifetime.

                    Given that `RenderFrameAudioOutputStreamFactory` is created for every frame regardless, if we decide to store the frame ids during the `RenderFrameAudioOutputStreamFactory` construction, we'll end up storing sink ids for all web pages (including the ones that will not play any sound). Thus, the cache size might grow unnecessarily.

                    Sunggook, is the performance gain enough to justify this "early improvement"? Like Olga suggested, maybe it could be simpler to just plumb the frame id when the `RenderFrameAudioOutputStreamFactory` is being constructed (https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa;bpv=1;bpt=1;l=223)? Also, I suggest only resolving the conversations when both parties agree and there are no more pending questions.

                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . unresolved

                    Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                    Sunggook Chue

                    The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                    I will add comments and test to validate it.

                    Olga Sharonova

                    I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                    Sunggook Chue

                    I will file a bug once it lands as the feature flag is disabled. We can't keep this CL open.

                    Olga Sharonova

                    .

                    Olga Sharonova

                    1) It was your choice to skip design discussions and iterate on the code instead. Figuring out a complex design without a clearly communicated high level vision is never easy ant takes time and many back and forth.

                    2) If you think I have any other agenda besides landing easy-to-maintain code of good quality - you are mistaken. But we cannot land it just for the sake of landing it, because it creates maintenance burden. As you noticed, the review has already uncovered multiple issues, including race conditions.
                    We need to fix the design issues before it lands.

                    3) The inconsistency of weak pointer treatment hints to a design issue. You can figure it out and fix it. Or I'll think about it when I have a bit of time.

                    4) The fact that you keep resolving in-progress discussions when I explicitly asked you not to, because it's very hard to keep track of them - I don't even know what to make of it. What's your goal?

                    Sunggook Chue

                    I already mentioned my design, please let me know what's your proposal. I don't see any design issue.

                    Gabriel Brito

                    Sunggook, maybe we can use a more "traditional" check?
                    If device_switcher is nullptr, how do we know which device_switcher in the map to erase? Maybe this method should be called only for non-null device_switcher pointers and then we can have another dedicated method to clean-up invalidated pointers. Otherwise, the method will end up doing many more things than just deleting a given frame's device switcher. For example, it could erase other device_switchers besides the one passed as an argument.

                    Gerrit-Comment-Date: Mon, 26 Aug 2024 23:42:48 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Aug 26, 2024, 8:30:11 PM8/26/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 3 comments

                    Patchset-level comments
                    File-level comment, Patchset 18:
                    Sunggook Chue . resolved

                    addressed and replied comments, thanks.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    Thanks Gabriel for chiming in, and again.

                    We have to access this RenderFrameAudioOutputStreamFactory::Core in the function of PreferredAudioOutputDeviceManager::AddSwitcherAndGetOverrideDeviceId/GetOverrideDeviceId, which is in the IO thread.

                    1. If we cache in the RenderFrameAudioOutputStreamFactory::Core object, we have to get RenderFrameAudioOutputStreamFactory::Core object through RenderFrameHost object, which is only possible in the UI threads so we can't avoid switch.

                    2. We might choose cache inside PreferredAudioOutputDeviceManager, which is called from the RenderFrameAudioOutputStreamFactory::Core, it's much better. But the problem is that RenderFrameAudioOutputStreamFactory is called for every RFH. for example, www.bing.com calls RenderFrameAudioOutputStreamFactory ctor 4 times for one tab and imagine user open 10 tabs but no audio play, we end up with 40 calls with cache that lead to worse perf than this ui/io switch cost. that's why I said we need measure perf for perf improvement decision
                    rather than premature optimization (kind of rule of thumb in perf)

                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . unresolved

                    Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                    Sunggook Chue

                    The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                    I will add comments and test to validate it.

                    Olga Sharonova

                    I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                    Sunggook Chue

                    I will file a bug once it lands as the feature flag is disabled. We can't keep this CL open.

                    Olga Sharonova

                    .

                    Olga Sharonova

                    1) It was your choice to skip design discussions and iterate on the code instead. Figuring out a complex design without a clearly communicated high level vision is never easy ant takes time and many back and forth.

                    2) If you think I have any other agenda besides landing easy-to-maintain code of good quality - you are mistaken. But we cannot land it just for the sake of landing it, because it creates maintenance burden. As you noticed, the review has already uncovered multiple issues, including race conditions.
                    We need to fix the design issues before it lands.

                    3) The inconsistency of weak pointer treatment hints to a design issue. You can figure it out and fix it. Or I'll think about it when I have a bit of time.

                    4) The fact that you keep resolving in-progress discussions when I explicitly asked you not to, because it's very hard to keep track of them - I don't even know what to make of it. What's your goal?

                    Sunggook Chue

                    I already mentioned my design, please let me know what's your proposal. I don't see any design issue.

                    Sunggook Chue

                    Hmm, I're revisited this and thinking we can improve this by caching globalId, which is called from AddSwitcherAndGetOverrideDeviceId, etc (not from RenderFrameAudioOutputStreamFactory :)).

                    thanks for suggestion of using GlobalRenderFrameHostId instead of RenderFrameHost.

                    can we resolve this one?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 19
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 27 Aug 2024 00:29:59 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Aug 28, 2024, 9:33:38 AM8/28/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 5 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 166, Patchset 20 (Latest): render_frame_host_id_to_main_frame_id_;
                    Olga Sharonova . unresolved

                    Why do we need this mapping? Please document.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    RenderFrameAudioOutputStreamFactory is created only when a frame accesses audio info/wants to play audio; it's a per-frame singleton; see RenderFrameHostImpl::CreateAudioOutputStreamFactory().

                    The size of the cached data is several bytes per frame.

                    RenderFrameAudioOutputStreamFactory::Core creates output brokers (aka switchers) - so it can pass the id during construction.
                    RenderFrameAudioOutputStreamFactory::Core::ProviderImpl::Acquire() -> ForwardingAudioStreamFactory::Core::CreateOutputStream().


                    The issue is not performance, but the design complexity.

                    In my opinion, this CL is potentially doing early memory optimization by adding unnecessary complexity in the form of extra thread hops and lifetime management complications/weak pointers.

                    Line 168, Patchset 20 (Latest): GlobalRenderFrameHostId frame_global_id,
                    Olga Sharonova . unresolved

                    Switcher already has it, hasn't it? Why passing it one more time?

                    Line 222, Patchset 20 (Latest): // It could not find it when it is called during shudown right
                    Olga Sharonova . unresolved

                    What does "during shutdown" mean?

                    Olga Sharonova

                    By how much this is better in terms of memory consumption vs storing the main frame id in the switcher?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 20
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Wed, 28 Aug 2024 13:33:26 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 1, 2024, 12:17:00 AM9/1/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 5 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 166, Patchset 20: render_frame_host_id_to_main_frame_id_;
                    Olga Sharonova . resolved

                    Why do we need this mapping? Please document.

                    Sunggook Chue

                    We want to keep the incoming RFH global id to the its main RFH global id during Add* request so that we can use it during Remove. We don't have to switch to UI thread during RemoveSwitcherEntry.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    hmm, when attaching debugger, it is called so many times for every site visit. even vising doc site like w3.org, 4 times are called.

                    Can you check it again?

                    Line 168, Patchset 20: GlobalRenderFrameHostId frame_global_id,
                    Olga Sharonova . resolved

                    Switcher already has it, hasn't it? Why passing it one more time?

                    Sunggook Chue

                    correct, thanks.

                    Line 222, Patchset 20: // It could not find it when it is called during shudown right
                    Olga Sharonova . resolved

                    What does "during shutdown" mean?

                    Sunggook Chue

                    process shutdown. I'm not clear this part 100% because RemoveSwitcherEntry is called on IO thread, can the process shutdown during IO threads cleanup? probably not, I will make this one as DCHECK so that we can catch any loophole.

                    Sunggook Chue

                    see my comment of RenderFrameAudioOutputStreamFactory creation.

                    If RenderFrameAudioOutputStreamFactory is created only for AudioOutputStreamBroker, it could increase "8 x 'number of AudioOutputStreamBroker created object'.

                    but, for design wise, it can scope the feature works on the single place, not multiple classes.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 24
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Sun, 01 Sep 2024 04:16:45 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 1, 2024, 12:37:43 PM9/1/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    In real time though, the people will listen to single source at a time, or maximum 2 so "number of AudioOutputStreamBroker" is 1 or 2 even thought they open 20 tabs.

                    meanwhile, if they open 20 tabs, the number of size by RenderFrameAudioOutputStreamFactory (based on the current observation)it would increase 20 (tabs) x 8 (cache item size) x (number of frames per tab).

                    Gerrit-Comment-Date: Sun, 01 Sep 2024 16:37:34 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 2, 2024, 1:54:14 AM9/2/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 2 comments

                    Patchset-level comments
                    File-level comment, Patchset 24 (Latest):
                    Sunggook Chue . resolved

                    thanks,

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 138, Patchset 16: &GetRenderFrameHostOnUIThread, rfh_id,
                    Olga Sharonova . unresolved

                    I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

                    Olga Sharonova

                    See RenderFrameAudioOutputStreamFactory constructor.

                    Sunggook Chue

                    It looks like the object is called from the UI thread object RenderFrameHostImpl, meanwhile AudioOutputSreamBreaker, which call PreferredAudioOutputDeviceManager, is called on IO thread.

                    Afaik, most of media components (video/audio) that hooks btw Renderer and Utility Services are on IO thread bound.

                    If needed, we can ask Guido to review this CL (and browser side changes) if needed as he is well aware of it.

                    Olga Sharonova

                    Sunggook, when you reply to the comments, there's a checkbox "resolved". I just asked you in the comment above **to not resolve the discussions in progress**. Please **do not mark the checkbox** for any ongoing discussion or when you are answering a question. I'll mark it as resolved when I've read an answer and have not follow-up questions. Resolved comments are getting lost. This makes my job as a reviewer unnecessary hard. And it causes situations when I have to ask the same question again.

                    ---

                    If you look at RenderFrameAudioOutputStreamFactory constructor (running on UI thread) you see it's constructing Core. Either RenderFrameAudioOutputStreamFactory 
                    constructor or Core constructor can get the main frame id, since the construction is happening on UI thread. The rest of the Core lives on IO thread and can pass the main frame ID down the line (here https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;l=323;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa;bpv=1;bpt=1, etc); or IO thread code can just access it trough an IO thread getter at some point (to not plumb the same id through too many layers).

                    I do not suggest to rewrite the code immediately, but I'm asking if this has been considered and why the current approach of dynamic fetch of the main frame id was chosen over an option of having a constant main frame id propagated to an IO thread object during construction.

                    Sunggook Chue

                    I got your point.

                    So, we cache global Ids and its parent Ids (if it is sub frame) on IO thread through RenderFrameAudioOutputStreamFactory mechanism and retrieve the main frame global id without switching to UI thread.

                    The problem is that we need RenderFrameHostImpl object when called on the IO thread with globalId (most Media APIs is called on IO thread from the Renderer) in order to get the RenderFrameAudioOutputStreamFactory object. So switching to UI thread occurs.

                    Anything I missed?

                    Olga Sharonova

                    .

                    Olga Sharonova

                    1) Could you explain why have you resolved the comment? Especially since it seems like you are asking a question.

                    2) I mean we cache the main frame global id.
                    Could you clarify "the problem"? What code are you referring to? (links, methods names?) When I described my idea, I added specific references. Could you do the same?

                    Sunggook Chue

                    1. We have to access RenderFrameAudioOutputStreamFactory, which is a member of RenderFrameHost, which is accessed from only in the UI thread.

                    2. RenderFrameAudioOutputStreamFactory is created for every frames but preferred manager is accessed only when audio output request is made. If we cache the values for RenderFrameAudioOutputStreamFactory creation, it would increase the unnecessary cache size.

                    Olga Sharonova

                    This is not answering my question though. What code are you referring to? Who "we"? When we have to access RenderFrameAudioOutputStreamFactory? What exactly are you talking about? Which operation?

                    Sunggook Chue

                    Thanks Gabriel for chiming in, and again.

                    We have to access this RenderFrameAudioOutputStreamFactory::Core in the function of PreferredAudioOutputDeviceManager::AddSwitcherAndGetOverrideDeviceId/GetOverrideDeviceId, which is in the IO thread.

                    1. If we cache in the RenderFrameAudioOutputStreamFactory::Core object, we have to get RenderFrameAudioOutputStreamFactory::Core object through RenderFrameHost object, which is only possible in the UI threads so we can't avoid switch.

                    2. We might choose cache inside PreferredAudioOutputDeviceManager, which is called from the RenderFrameAudioOutputStreamFactory::Core, it's much better. But the problem is that RenderFrameAudioOutputStreamFactory is called for every RFH. for example, www.bing.com calls RenderFrameAudioOutputStreamFactory ctor 4 times for one tab and imagine user open 10 tabs but no audio play, we end up with 40 calls with cache that lead to worse perf than this ui/io switch cost. that's why I said we need measure perf for perf improvement decision
                    rather than premature optimization (kind of rule of thumb in perf)

                    Olga Sharonova

                    RenderFrameAudioOutputStreamFactory is created only when a frame accesses audio info/wants to play audio; it's a per-frame singleton; see RenderFrameHostImpl::CreateAudioOutputStreamFactory().

                    The size of the cached data is several bytes per frame.

                    RenderFrameAudioOutputStreamFactory::Core creates output brokers (aka switchers) - so it can pass the id during construction.
                    RenderFrameAudioOutputStreamFactory::Core::ProviderImpl::Acquire() -> ForwardingAudioStreamFactory::Core::CreateOutputStream().


                    The issue is not performance, but the design complexity.

                    In my opinion, this CL is potentially doing early memory optimization by adding unnecessary complexity in the form of extra thread hops and lifetime management complications/weak pointers.

                    Sunggook Chue

                    hmm, when attaching debugger, it is called so many times for every site visit. even vising doc site like w3.org, 4 times are called.

                    Can you check it again?

                    Sunggook Chue

                    Here are brief call stacks to call CreateAudioOutputStreamFactory.

                    content!content::RenderFrameHostImpl::CreateAudioOutputStreamFactory
                    ..
                    blink_modules!blink::AudioOutputIPCFactory::Impl::RegisterRemoteFactoryOnIOThread
                    ..
                    blink_modules!blink::AudioOutputIPCFactory::RegisterRemoteFactory
                    ..
                    content!content::RenderFrameImpl::Initialize
                    content!content::RenderFrameImpl::CreateFrame
                    content!content::AgentSchedulingGroup::CreateFrame

                    Gerrit-Comment-Date: Mon, 02 Sep 2024 05:54:04 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 2, 2024, 6:16:30 AM9/2/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 2 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    Hmm, that's unexpected. Thanks for checking!

                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . unresolved

                    Hmm. Weak pointers will be nulled on the switcher deletion. So it2->get() == device_switcher.get()) is comparing nullptr with nullptr, and potentially deleting some other switcher. This does not add up.

                    Sunggook Chue

                    The it2 is collection that is results of the 'main_frame' so it is find to delete any value when 'it2->get() == nullptr and device_switcher.get() is nullptr even if internal it2->get() could be different Switcher from device_switcher.

                    I will add comments and test to validate it.

                    Olga Sharonova

                    I'd like to keep the discussion open, since I'm not entirely happy with how it's turning out. but have not figured an alternative proposal yet.

                    Sunggook Chue

                    I will file a bug once it lands as the feature flag is disabled. We can't keep this CL open.

                    Olga Sharonova

                    .

                    Olga Sharonova

                    1) It was your choice to skip design discussions and iterate on the code instead. Figuring out a complex design without a clearly communicated high level vision is never easy ant takes time and many back and forth.

                    2) If you think I have any other agenda besides landing easy-to-maintain code of good quality - you are mistaken. But we cannot land it just for the sake of landing it, because it creates maintenance burden. As you noticed, the review has already uncovered multiple issues, including race conditions.
                    We need to fix the design issues before it lands.

                    3) The inconsistency of weak pointer treatment hints to a design issue. You can figure it out and fix it. Or I'll think about it when I have a bit of time.

                    4) The fact that you keep resolving in-progress discussions when I explicitly asked you not to, because it's very hard to keep track of them - I don't even know what to make of it. What's your goal?

                    Sunggook Chue

                    I already mentioned my design, please let me know what's your proposal. I don't see any design issue.

                    Sunggook Chue

                    Hmm, I're revisited this and thinking we can improve this by caching globalId, which is called from AddSwitcherAndGetOverrideDeviceId, etc (not from RenderFrameAudioOutputStreamFactory :)).

                    thanks for suggestion of using GlobalRenderFrameHostId instead of RenderFrameHost.

                    can we resolve this one?

                    Olga Sharonova

                    By how much this is better in terms of memory consumption vs storing the main frame id in the switcher?

                    Sunggook Chue

                    see my comment of RenderFrameAudioOutputStreamFactory creation.

                    If RenderFrameAudioOutputStreamFactory is created only for AudioOutputStreamBroker, it could increase "8 x 'number of AudioOutputStreamBroker created object'.

                    but, for design wise, it can scope the feature works on the single place, not multiple classes.

                    Sunggook Chue

                    In real time though, the people will listen to single source at a time, or maximum 2 so "number of AudioOutputStreamBroker" is 1 or 2 even thought they open 20 tabs.

                    meanwhile, if they open 20 tabs, the number of size by RenderFrameAudioOutputStreamFactory (based on the current observation)it would increase 20 (tabs) x 8 (cache item size) x (number of frames per tab).

                    Olga Sharonova
                    So for some unknown for us reason (maybe a bug), there are 4 RenderFrameAudioOutputStreamFactory::Core objects created per frame.

                    And you are discussing saving 8 bytes per object, which is 32 bytes per frame, taking into account the current behavior.

                    Correct?

                    An idle bing.com tab is over 100 MB.

                    Do you think the above memory saving is significant enough to influence the design decisions? I don't.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 24
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Mon, 02 Sep 2024 10:16:14 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 2, 2024, 4:40:43 PM9/2/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 2 comments

                    Patchset-level comments
                    File-level comment, Patchset 24 (Latest):
                    Sunggook Chue . resolved

                    thanks,

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    It's not just about memory saving, but its call during RenderFrame initialization, which could be so many as people tend to create many tabs, and its tab has could have many sub frames (RenderFrame). (We have to consider deleting the cache entry during its RenderFrameAudioOutputStreamFactory::Core dtor). We have to access PreferredAudioOutputDeviceManager whenever RenderFrame ctor and dtor that won't be used yet all when no sound is play.

                    I also think, the benefit of this RenderFrameAudioOutputStreamFactory cache is very small; skip UI/IO switch in the 2 APIs of AddSwitcherAndGetOverrideDeviceId, GetOverrideDeviceId. These APIs are called only when user listen to something.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 24
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Mon, 02 Sep 2024 20:40:32 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 3, 2024, 8:40:39 AM9/3/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    >We have to consider deleting the cache entry during its RenderFrameAudioOutputStreamFactory::Core dtor

                    It's where the value will be cached, so I don't understand the concern. Probably you misunderstand what modifications I'm proposing? Could you take another look at the notes and code references I provided in earlier comments?

                    We have to access PreferredAudioOutputDeviceManager whenever RenderFrame ctor and dtor that won't be used yet all when no sound is play.

                    What exactly do you mean?


                    The benefits of caching are:
                    1) Eliminating most of thread hops => potential lifetime issues (of which I've already found many in earlier versions of this CL) => potential browser crashes. Thus, making the code safer.
                    2) Making the code much easier to reason about, both in terms of threading and of objects lifetime
                    3) Likely eliminating the need of weak pointers for AudioOutputDeviceSwitcher

                    All in all, reduced complexity and probability of bugs, increase maintainability.

                    As we discussed, memory benefits of the current approach are negligible. And I don't see any other.

                    And it would take just a couple of hours to sketch the "caching" approach to see if there are any issues with it.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 24
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Tue, 03 Sep 2024 12:40:29 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 3, 2024, 1:05:10 PM9/3/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 2 comments

                    Patchset-level comments
                    File-level comment, Patchset 24 (Latest):
                    Sunggook Chue . resolved

                    thanks,

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    I agree with you that it would be win if we can remove thread switches, but I'm afraid that RenderFrameAudioOutputStreamFactory::Core ctor is navigation path where perf is very important and maybe hard to get approval from the code owner. It would be great if we can find other places where it will be created only when sound plays.

                    btw, I think, switching thread is kind of common in the MediaDevicesDispatcherHost where it implements mediaDevices namespace APIs.

                    We can consider the design from each side more.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 24
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 03 Sep 2024 17:04:44 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 3, 2024, 2:03:23 PM9/3/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    Exactly which performance concerns are you referring to? Aren't we talking about passing one constant into RenderFrameAudioOutputStreamFactory::Core constructor?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 24
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Tue, 03 Sep 2024 18:03:09 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 4, 2024, 10:39:21 AM9/4/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 2 comments

                    Sunggook Chue . resolved

                    thanks,

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    My concern is about the page navigation in the RenderFrame where we have many perf bench tests in order to reduce first page navigation speed as users are concern about it. Particularly, the proposal will impact every RenderFrame navigation with not be used scenarios in most cases (if not playing sound)

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 04 Sep 2024 14:39:09 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 4, 2024, 10:45:03 AM9/4/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    Impact in which way? What change do you have in mind which would have the impact? Can you estimate the size of it?

                    (BTW the current approach increases "time to play" by an unbound value, since we hop through the main thread which may be congested)

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Wed, 04 Sep 2024 14:44:52 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 4, 2024, 1:31:12 PM9/4/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 2 comments

                    Patchset-level comments
                    File-level comment, Patchset 25 (Latest):
                    Sunggook Chue . resolved

                    thanks,

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    RenderFrameAudioOutputStreamFactory solutions needs to (1) get the main render frame frame from the requested render frame on the UI thread, and its global id, (2) it adds/delete an entry to the cache that size could be easily over 100.

                    How about having third reviewer opinion (maybe Guido or who knows about RenderFrame startup) for this?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 04 Sep 2024 17:30:59 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 4, 2024, 7:58:01 PM9/4/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova

                    Sunggook Chue added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    meanwhile, I will implement your suggestion and measure its perf, there is a chance that my concern is nothing.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Comment-Date: Wed, 04 Sep 2024 23:57:48 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 4, 2024, 8:57:40 PM9/4/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova and Olga Sharonova
                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    I've run quick test on it, and it looks worse than I thought. vising wsj.com alone create objects (calls chrome!content::RenderFrameAudioOutputStreamFactory::Core::Core) more than 100 times (it also keeps deleting them).

                    You can easily test this one after attaching debugger on the browser process.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 05 Sep 2024 00:57:30 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Steve Becker (Gerrit)

                    unread,
                    Sep 4, 2024, 11:37:19 PM9/4/24
                    to Sunggook Chue, Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova, Olga Sharonova and Sunggook Chue

                    Steve Becker added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Steve Becker

                    100 is not a large quantity for computers. What about these operations is expensive? Can we measure the amount of time spent?

                    I think we should avoid premature optimization that adds unneeded complexity.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 05 Sep 2024 03:37:08 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 5, 2024, 2:32:25 AM9/5/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova, Olga Sharonova and Steve Becker

                    Sunggook Chue added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    I'm measuring the time and couldn't tell the difference in its speed and memory usage (as it deletes what it added, I'm not clear why it does that so many times).

                    My testing is simply measuring btw JS load and window.onload. We might need perf bench as they are more delicate (probably we have to land for it though).

                    We can revisit this one at any time, so I can implement what is suggested given no visible perf degradation so far.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    • Steve Becker
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Steve Becker <ste...@microsoft.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 05 Sep 2024 06:32:12 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Steve Becker <ste...@microsoft.com>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 5, 2024, 4:39:59 AM9/5/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Sunggook Chue

                    There are few uncertainties for the RenderFrameAudioOutputStreamFactory::Core lifetime though, for example,

                    1. Does every render frame host create one whatever? Not clear.
                    2. Does deletion ever called even though renderframehost isn't deleted? It looks like, then why?
                    3. How WebAudio (media element) creation and deletion in JS affect its lifetime?
                    4. Any chance of missing ID in the PreferredManager so we have to keep both old and new algorithm?
                    5. Any chance of double registration (Core with same globalId) but deletion once (vice versa)?
                    probably more,

                    it would be great if we know these answers clearly. (probably I have to research it more :).)

                    Gerrit-Comment-Date: Thu, 05 Sep 2024 08:39:47 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 5, 2024, 8:32:58 AM9/5/24
                    to Sunggook Chue, Olga Sharonova, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova, Steve Becker and Sunggook Chue

                    Olga Sharonova added 2 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25 (Latest): return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Olga Sharonova

                    >RenderFrameAudioOutputStreamFactory solutions needs to (1) get the main render frame frame from the requested render frame on the UI thread, and its global id,
                    >(2) it adds/delete an entry to the cache that size could be easily over 100.


                    I'm not sure I understand the concern.

                    *My proposal is*:

                    in this place (this is UI thread)
                    https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;l=194;drc=8e948282d37c0e119e3102236878d6f4d5052c16;bpv=1;bpt=1


                    to call frame->GetMainFrame()->GetGlobalId() and pass it into the Core constructor.

                    That's the only thing changing for RenderFrameAudioOutputStreamFactory().

                    Later on the value can be passed to the broker here
                    https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;l=120;bpv=1;bpt=1

                    So each broker knows their main frame, and there is no need to fetch it.

                    Do you see what I mean?
                    What delays and performance implications are we discussing?


                    Re: your questions: unfortunately they are not clear enough. Could you provide more information?

                    When you invite other reviewers, please keep in mind, you need to ensure they have the full context and an overview of the proposed changes and the alternatives being discussed. Just adding more people as reviewers does not help.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Steve Becker
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 25
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Steve Becker <ste...@microsoft.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 05 Sep 2024 12:32:46 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 5, 2024, 9:36:49 PM9/5/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova

                    Sunggook Chue added 3 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Line 138, Patchset 16: &GetRenderFrameHostOnUIThread, rfh_id,
                    Olga Sharonova . resolved

                    I think I asked it before, but not sure (please don't resolve the comment, otherwise the answer will get lost): have you looked into the option of determining the main host id on the broker creation?

                    Olga Sharonova

                    See RenderFrameAudioOutputStreamFactory constructor.

                    Sunggook Chue

                    It looks like the object is called from the UI thread object RenderFrameHostImpl, meanwhile AudioOutputSreamBreaker, which call PreferredAudioOutputDeviceManager, is called on IO thread.

                    Afaik, most of media components (video/audio) that hooks btw Renderer and Utility Services are on IO thread bound.

                    If needed, we can ask Guido to review this CL (and browser side changes) if needed as he is well aware of it.

                    Olga Sharonova

                    Sunggook, when you reply to the comments, there's a checkbox "resolved". I just asked you in the comment above **to not resolve the discussions in progress**. Please **do not mark the checkbox** for any ongoing discussion or when you are answering a question. I'll mark it as resolved when I've read an answer and have not follow-up questions. Resolved comments are getting lost. This makes my job as a reviewer unnecessary hard. And it causes situations when I have to ask the same question again.

                    ---

                    If you look at RenderFrameAudioOutputStreamFactory constructor (running on UI thread) you see it's constructing Core. Either RenderFrameAudioOutputStreamFactory 
                    constructor or Core constructor can get the main frame id, since the construction is happening on UI thread. The rest of the Core lives on IO thread and can pass the main frame ID down the line (here https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/media/render_frame_audio_output_stream_factory.cc;l=323;drc=82dff63dbf9db05e9274e11d9128af7b9f51ceaa;bpv=1;bpt=1, etc); or IO thread code can just access it trough an IO thread getter at some point (to not plumb the same id through too many layers).

                    I do not suggest to rewrite the code immediately, but I'm asking if this has been considered and why the current approach of dynamic fetch of the main frame id was chosen over an option of having a constant main frame id propagated to an IO thread object during construction.

                    Sunggook Chue

                    I got your point.

                    So, we cache global Ids and its parent Ids (if it is sub frame) on IO thread through RenderFrameAudioOutputStreamFactory mechanism and retrieve the main frame global id without switching to UI thread.

                    The problem is that we need RenderFrameHostImpl object when called on the IO thread with globalId (most Media APIs is called on IO thread from the Renderer) in order to get the RenderFrameAudioOutputStreamFactory object. So switching to UI thread occurs.

                    Anything I missed?

                    Olga Sharonova

                    .

                    Olga Sharonova

                    1) Could you explain why have you resolved the comment? Especially since it seems like you are asking a question.

                    Sunggook Chue

                    I will resolve this one as well, reactivate if needed. thanks.

                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . resolved
                    Sunggook Chue

                    initial implementation and tests is positive. updated. thanks.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 26
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Comment-Date: Fri, 06 Sep 2024 01:36:38 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 6, 2024, 5:36:16 AM9/6/24
                    to Sunggook Chue, Olga Sharonova, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova, Steve Becker and Sunggook Chue

                    Olga Sharonova added 22 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 136, Patchset 27 (Latest):
                    class RenderFrameHostSinkId {
                    public:
                    RenderFrameHostSinkId();
                    ~RenderFrameHostSinkId();

                    RenderFrameHostSinkId(RenderFrameHostSinkId&&);
                    RenderFrameHostSinkId& operator=(RenderFrameHostSinkId&&);
                    RenderFrameHostSinkId(const RenderFrameHostSinkId&) = delete;
                    RenderFrameHostSinkId& operator=(const RenderFrameHostSinkId&) = delete;

                    void set_preferred_sink_id(const std::string& sink_id) {
                    preferred_sink_id_ = sink_id;
                    }

                    std::string preferred_sink_id() const { return preferred_sink_id_; }
                    std::vector<AudioOutputDeviceSwitcher*>& active_device_switchers() {
                    return active_device_switchers_;
                    }

                    private:
                    // The preferred sink id for the top-level page as well as all the sub
                    // frames.
                    std::string preferred_sink_id_;

                    // The active streaming device_switchers that are using the system default
                    // audio.
                    std::vector<AudioOutputDeviceSwitcher*> active_device_switchers_;
                    };

                    // The map of incoming GlobalRenderFrameHostId to the main
                    // RenderFrameHostSinkId. We add and delete RenderFrameHostSinkId with the
                    // main RenderFrameHostSinkId in the
                    // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    // `RenderFrameAudioOutputStreamFactory::Core` object.
                    std::map<GlobalRenderFrameHostId, GlobalRenderFrameHostId>
                    render_frame_host_id_to_main_frame_id_;

                    // The map of GlobalRenderFrameHostId to RenderFrameHostSinkId. It should be
                    // accessed only in the IO thread.
                    std::map</*main frame globalId=*/GlobalRenderFrameHostId,
                    RenderFrameHostSinkId>
                    render_frame_host_sink_ids_;
                    Olga Sharonova . unresolved

                    This looks a bit overly complicated.

                    Generally, the relationship is

                    [main_rfh_id] 1-1 [preferred_sink_id]
                    1
                    |
                    *
                    [rfh_id]
                    0
                    |
                    *
                    [switchers]

                    you need to be able to look up
                    (1) [rfh_id]->[main_rfh_id] for setPreferredSinkId
                    (2) [main_rfh_id]->switchers for setPreferredSinkId
                    (3) probably [rfh_id]->switchers for navigation?

                    right?
                    anything else?

                    When do you expect entries to be added/removed, and how many entries do you expect?

                    Line 137, Patchset 27 (Latest): class RenderFrameHostSinkId {
                    Olga Sharonova . unresolved

                    Please document

                    Line 103, Patchset 27 (Latest): void AddRenderFrameHostid(GlobalRenderFrameHostId rfh_id,
                    GlobalRenderFrameHostId main_frame_global_id);
                    void DeleteRenderFrameHostid(GlobalRenderFrameHostId rfh_id);
                    Olga Sharonova . unresolved

                    Please document
                    HostId
                    Also use the same naming scheme, for example rfh_id/main_rfh_id

                    Line 98, Patchset 27 (Latest): void RemoveRenderFrameHostEntry(RenderFrameHost* render_frame_host);
                    Olga Sharonova . unresolved

                    Which entry? You have two maps.
                    Please document what it does and name it accordingly. "UnregisterSwitchersFoFrame" or something.

                    Line 91, Patchset 27 (Latest): void RemoveSwitcherEntry(GlobalRenderFrameHostId rfh_id,
                    Olga Sharonova . unresolved

                    RemoveSwitcher

                    Line 90, Patchset 27 (Latest): // It should be called on IO thread only.
                    Olga Sharonova . unresolved

                    You can add one overarching comment that all methods except specifically mentioned are called on IO thread.

                    Line 85, Patchset 27 (Latest): std::string GetOverrideDeviceId(GlobalRenderFrameHostId rfh_id);
                    Olga Sharonova . unresolved

                    GetPreferrdSinkId (name in pairs: set/get)

                    Line 83, Patchset 27 (Latest): // It will overrided device id if found, or empty string.
                    Olga Sharonova . unresolved

                    What does it mean?

                    Line 79, Patchset 27 (Latest): // `process_id` is the id of the process. It is used for retrieving the
                    // render frame host object.
                    Olga Sharonova . unresolved

                    What's the purpose of this sentense?

                    Line 78, Patchset 27 (Latest): // Get the override device id for the render frame host if an entry exists.
                    Olga Sharonova . unresolved

                    And if it does not?

                    Line 75, Patchset 27 (Latest): void RegisterDeviceOutputSwitcher(GlobalRenderFrameHostId rfh_id,
                    Olga Sharonova . unresolved

                    Please name them in a pair: Just AddSwitcher()/RemoveSwitcher()

                    Line 69, Patchset 27 (Latest): // Add the device switcher to the active device switchers list and get the
                    // override device id for the render frame host if an entry exists.
                    // `device_switcher` is the device switcher to be added to the active device.
                    // switchers list.
                    // It returns
                    Olga Sharonova . unresolved

                    please fix

                    Line 68, Patchset 27 (Latest): GlobalRenderFrameHostId rfh_id);
                    Olga Sharonova . unresolved

                    Should be the first parameter

                    Line 67, Patchset 27 (Latest): SetPreferredSinkIdCallback callback,
                    Olga Sharonova . unresolved

                    should be the last parameter

                    Line 66, Patchset 27 (Latest): virtual void SetPreferredSinkId(const std::string& sink_id,
                    Olga Sharonova . unresolved

                    Please document what it actually does (switches the default sink for all subframes of some frame something something)

                    Line 50, Patchset 27 (Latest):// from the WebContentsObserver. Synchronization locks are not used for
                    // accessing the cache; instead, it is accessed exclusively on the IO thread,
                    // So if an API is called on the IO thread with a render frame host ID, the
                    // request is forwarded to the UI thread to get the RenderFrameHost object
                    // and then returns to the IO thread to manage the cache.
                    Olga Sharonova . unresolved

                    Not relevant any longer?
                    Also, please do not document implementation in the header.

                    Line 47, Patchset 27 (Latest):// The class is created and destroyed on the IO thread during
                    // MediaStreamManager initialization and destruction. While most APIs are
                    Olga Sharonova . unresolved

                    Please do not add implicit assumptions not guaranteed by the class.

                    Line 39, Patchset 27 (Latest):// frame as well as all the sub pages if they use system default audio output.
                    // It caches the preferred sink id with each top RenderFrameHost object and
                    // forwards the request to the corresponding audio output stream in the
                    // audio service if streaming is in active. The cached sink id also will be
                    // substituted for the new audio output stream if the requested stream is
                    // default. The cache's key is RenderFrameHost object, which can be retrieved
                    // only in the UI thread from render frame host id.
                    Olga Sharonova . unresolved

                    Please move implementation details description into .cc. Please discuss the API from the client perspective in the header.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Line 76, Patchset 27 (Latest): base::BindOnce(&CreateAudioOutputAuthHandlerOnUIThread, rfh_id),
                    Olga Sharonova . unresolved

                    There is no need to create the handler every time, please reconsider.
                    See RenderFrameAudioOutputStreamFactory::Core

                    Line 213, Patchset 27 (Latest):std::string PreferredAudioOutputDeviceManager::GetOverrideDeviceIdWithMainFrame(
                    Olga Sharonova . unresolved

                    Instead of adding a second layer of "WithMainFrame" methods, it's much more readable to add getMainRenderFrameHostId(GlobalRenderFrameHostId rfh_id)

                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . unresolved
                    Olga Sharonova

                    Since you modified the proposal above - please provide a high-level description and considerations, so the reviewers don't have to read between the lines.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Steve Becker
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 27
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Steve Becker <ste...@microsoft.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Fri, 06 Sep 2024 09:36:03 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 6, 2024, 9:05:38 AM9/6/24
                    to Sunggook Chue, Olga Sharonova, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova, Steve Becker and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 169, Patchset 27 (Latest): // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    Olga Sharonova . unresolved

                    Is the code there?
                    (Also please do not refer to the external context)

                    Gerrit-Comment-Date: Fri, 06 Sep 2024 13:05:26 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 7, 2024, 7:51:22 PM9/7/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Gabriel Brito, Olga Sharonova, Olga Sharonova and Steve Becker

                    Sunggook Chue added 23 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h

                    class RenderFrameHostSinkId {
                    public:
                    RenderFrameHostSinkId();
                    ~RenderFrameHostSinkId();

                    RenderFrameHostSinkId(RenderFrameHostSinkId&&);
                    RenderFrameHostSinkId& operator=(RenderFrameHostSinkId&&);
                    RenderFrameHostSinkId(const RenderFrameHostSinkId&) = delete;
                    RenderFrameHostSinkId& operator=(const RenderFrameHostSinkId&) = delete;

                    void set_preferred_sink_id(const std::string& sink_id) {
                    preferred_sink_id_ = sink_id;
                    }

                    std::string preferred_sink_id() const { return preferred_sink_id_; }
                    std::vector<AudioOutputDeviceSwitcher*>& active_device_switchers() {
                    return active_device_switchers_;
                    }

                    private:
                    // The preferred sink id for the top-level page as well as all the sub
                    // frames.
                    std::string preferred_sink_id_;

                    // The active streaming device_switchers that are using the system default
                    // audio.
                    std::vector<AudioOutputDeviceSwitcher*> active_device_switchers_;
                    };

                    // The map of incoming GlobalRenderFrameHostId to the main
                    // RenderFrameHostSinkId. We add and delete RenderFrameHostSinkId with the
                    // main RenderFrameHostSinkId in the
                    // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    // `RenderFrameAudioOutputStreamFactory::Core` object.
                    std::map<GlobalRenderFrameHostId, GlobalRenderFrameHostId>
                    render_frame_host_id_to_main_frame_id_;

                    // The map of GlobalRenderFrameHostId to RenderFrameHostSinkId. It should be
                    // accessed only in the IO thread.
                    std::map</*main frame globalId=*/GlobalRenderFrameHostId,
                    RenderFrameHostSinkId>
                    render_frame_host_sink_ids_;
                    Olga Sharonova . resolved

                    This looks a bit overly complicated.

                    Generally, the relationship is

                    [main_rfh_id] 1-1 [preferred_sink_id]
                    1
                    |
                    *
                    [rfh_id]
                    0
                    |
                    *
                    [switchers]

                    you need to be able to look up
                    (1) [rfh_id]->[main_rfh_id] for setPreferredSinkId
                    (2) [main_rfh_id]->switchers for setPreferredSinkId
                    (3) probably [rfh_id]->switchers for navigation?

                    right?
                    anything else?

                    When do you expect entries to be added/removed, and how many entries do you expect?

                    Sunggook Chue

                    yes, it is right. I don't see anything else.

                    for render_frame_host_sink_ids, the max entries will be same with the number of playing Switchers that are AudioOutputStreamBroker in the browser. people could playing sound from all of their frames but they listen 1 or 2 at that time. the paused play will terminate the AudioOutputStreamBroker after certain threshold. So the maximum number won't be much, less than 3. I guess.

                    for render_frame_host_id_to_main_frame_id_, it is more interesting one. In theory (you know this one more than I do) it is as many as RenderFrameAudioInputStreamFactory::Core object, which could be per frame. When quick testing though, it is quite smaller than number of frames even though it is created per frame initially but deleted somehow later. In the end, the frame that creates RenderFrameAudioInputStreamFactory::Core looks have RenderFrameAudioInputStreamFactory::Core objects.

                    so I expects this one is also same with render_frame_host_sink_ids.

                    Please reactivate this one if you have requests as it is about the question and I answered so I resolve it (few unresolved help focus on discussion).

                    Line 169, Patchset 27: // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    Olga Sharonova . resolved

                    Is the code there?
                    (Also please do not refer to the external context)

                    Sunggook Chue

                    but you know it is correct if you see the next CL? I thought the benefit of these relation CL is to know the future work so we can have complete class that doesn't have to updated the next CL.

                    anyway, I will remove this one.

                    Line 137, Patchset 27: class RenderFrameHostSinkId {
                    Olga Sharonova . resolved

                    Please document

                    Sunggook Chue

                    Done

                    Line 103, Patchset 27: void AddRenderFrameHostid(GlobalRenderFrameHostId rfh_id,

                    GlobalRenderFrameHostId main_frame_global_id);
                    void DeleteRenderFrameHostid(GlobalRenderFrameHostId rfh_id);
                    Olga Sharonova . resolved

                    Please document
                    HostId
                    Also use the same naming scheme, for example rfh_id/main_rfh_id

                    Sunggook Chue

                    Done

                    Line 98, Patchset 27: void RemoveRenderFrameHostEntry(RenderFrameHost* render_frame_host);
                    Olga Sharonova . resolved

                    Which entry? You have two maps.
                    Please document what it does and name it accordingly. "UnregisterSwitchersFoFrame" or something.

                    Sunggook Chue

                    Done

                    Line 91, Patchset 27: void RemoveSwitcherEntry(GlobalRenderFrameHostId rfh_id,
                    Olga Sharonova . resolved

                    RemoveSwitcher

                    Sunggook Chue

                    using RemoveDeviceOutputSwitcher.

                    Line 90, Patchset 27: // It should be called on IO thread only.
                    Olga Sharonova . resolved

                    You can add one overarching comment that all methods except specifically mentioned are called on IO thread.

                    Sunggook Chue

                    thanks,

                    Line 85, Patchset 27: std::string GetOverrideDeviceId(GlobalRenderFrameHostId rfh_id);
                    Olga Sharonova . resolved

                    GetPreferrdSinkId (name in pairs: set/get)

                    Sunggook Chue

                    good name.

                    Line 83, Patchset 27: // It will overrided device id if found, or empty string.
                    Olga Sharonova . resolved

                    What does it mean?

                    Sunggook Chue

                    removed as it is confusing.

                    Line 79, Patchset 27: // `process_id` is the id of the process. It is used for retrieving the

                    // render frame host object.
                    Olga Sharonova . resolved

                    What's the purpose of this sentense?

                    Sunggook Chue

                    no needed anymore.

                    Line 78, Patchset 27: // Get the override device id for the render frame host if an entry exists.
                    Olga Sharonova . resolved

                    And if it does not?

                    Sunggook Chue

                    Done

                    Line 75, Patchset 27: void RegisterDeviceOutputSwitcher(GlobalRenderFrameHostId rfh_id,
                    Olga Sharonova . resolved

                    Please name them in a pair: Just AddSwitcher()/RemoveSwitcher()

                    Sunggook Chue

                    Done

                    Line 69, Patchset 27: // Add the device switcher to the active device switchers list and get the

                    // override device id for the render frame host if an entry exists.
                    // `device_switcher` is the device switcher to be added to the active device.
                    // switchers list.
                    // It returns
                    Olga Sharonova . resolved

                    please fix

                    Sunggook Chue

                    Done

                    Line 68, Patchset 27: GlobalRenderFrameHostId rfh_id);
                    Olga Sharonova . resolved

                    Should be the first parameter

                    Sunggook Chue

                    Done

                    Line 67, Patchset 27: SetPreferredSinkIdCallback callback,
                    Olga Sharonova . resolved

                    should be the last parameter

                    Sunggook Chue

                    Done

                    Line 66, Patchset 27: virtual void SetPreferredSinkId(const std::string& sink_id,
                    Olga Sharonova . resolved

                    Please document what it actually does (switches the default sink for all subframes of some frame something something)

                    Sunggook Chue

                    Done

                    Line 50, Patchset 27:// from the WebContentsObserver. Synchronization locks are not used for

                    // accessing the cache; instead, it is accessed exclusively on the IO thread,
                    // So if an API is called on the IO thread with a render frame host ID, the
                    // request is forwarded to the UI thread to get the RenderFrameHost object
                    // and then returns to the IO thread to manage the cache.
                    Olga Sharonova . resolved

                    Not relevant any longer?
                    Also, please do not document implementation in the header.

                    Sunggook Chue

                    Done

                    Line 47, Patchset 27:// The class is created and destroyed on the IO thread during

                    // MediaStreamManager initialization and destruction. While most APIs are
                    Olga Sharonova . resolved

                    Please do not add implicit assumptions not guaranteed by the class.

                    Sunggook Chue

                    replaced "The class is expected to be created and destroyed on the IO thread as
                    // as singleton per the browser instance"

                    Line 39, Patchset 27:// frame as well as all the sub pages if they use system default audio output.

                    // It caches the preferred sink id with each top RenderFrameHost object and
                    // forwards the request to the corresponding audio output stream in the
                    // audio service if streaming is in active. The cached sink id also will be
                    // substituted for the new audio output stream if the requested stream is
                    // default. The cache's key is RenderFrameHost object, which can be retrieved
                    // only in the UI thread from render frame host id.
                    Olga Sharonova . resolved

                    Please move implementation details description into .cc. Please discuss the API from the client perspective in the header.

                    Sunggook Chue

                    Move to the RegisterDeviceOutputSwitcher API definition.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Olga Sharonova

                    I only see it marked as resolved https://chromium-review.googlesource.com/c/chromium/src/+/5686893/comment/a78938d3_bad42416/

                    Sunggook Chue

                    Did you suggest to register process id from the ::Core like main RHF ID?

                    I think setPreferredSinkId can be called even when ::Core object isn't called as ::Core object is created only when audio play is requested?

                    Line 76, Patchset 27: base::BindOnce(&CreateAudioOutputAuthHandlerOnUIThread, rfh_id),
                    Olga Sharonova . unresolved

                    There is no need to create the handler every time, please reconsider.
                    See RenderFrameAudioOutputStreamFactory::Core

                    Sunggook Chue

                    yes, you're right, we can have per process authorization_handler_, hmm, do you think have to have another table for "process - authorization_handler",

                    Isn't it clean design to create authorization_handler for every request as (1) we don't expect many setPreferredSinkId calls for the main page lifetime (assuming main page run on its own render process), (2) no need to listen to process termination to clean it (not sure if chromium has such event)?

                    Line 213, Patchset 27:std::string PreferredAudioOutputDeviceManager::GetOverrideDeviceIdWithMainFrame(
                    Olga Sharonova . resolved

                    Instead of adding a second layer of "WithMainFrame" methods, it's much more readable to add getMainRenderFrameHostId(GlobalRenderFrameHostId rfh_id)

                    Sunggook Chue

                    Done

                    Sunggook Chue

                    updated description, if needed, you can update it if it helps. thanks.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Gabriel Brito
                    • Olga Sharonova
                    • Olga Sharonova
                    • Steve Becker
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 29
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Steve Becker <ste...@microsoft.com>
                    Gerrit-Attention: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Sat, 07 Sep 2024 23:51:11 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 10, 2024, 4:57:41 AM9/10/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova

                    Sunggook Chue added 2 comments

                    Patchset-level comments
                    File-level comment, Patchset 29 (Latest):
                    Sunggook Chue . resolved

                    Hi Olga, Please let me know if you have any more comments on this CL, thanks.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 238, Patchset 16:
                    // We don't check device_switcher is valid or not during RemoveSwitcher
                    // because we just use it as a interger key value for cleanup.
                    Olga Sharonova . resolved
                    Sunggook Chue

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 29
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Comment-Date: Tue, 10 Sep 2024 08:57:29 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 12, 2024, 8:26:12 AM9/12/24
                    to Sunggook Chue, Olga Sharonova, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Sunggook Chue

                    Olga Sharonova added 8 comments

                    Patchset-level comments
                    File-level comment, Patchset 30 (Latest):
                    Olga Sharonova . unresolved

                    1) Please fix the CL chain, and keep it up to date for all next review rounds.
                    2) Please restore the design doc and close it for public editing.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Olga Sharonova . unresolved

                    This looks a bit overly complicated.

                    Generally, the relationship is

                    [main_rfh_id] 1-1 [preferred_sink_id]
                    1
                    |
                    *
                    [rfh_id]
                    0
                    |
                    *
                    [switchers]

                    you need to be able to look up
                    (1) [rfh_id]->[main_rfh_id] for setPreferredSinkId
                    (2) [main_rfh_id]->switchers for setPreferredSinkId
                    (3) probably [rfh_id]->switchers for navigation?

                    right?
                    anything else?

                    When do you expect entries to be added/removed, and how many entries do you expect?

                    Sunggook Chue

                    yes, it is right. I don't see anything else.

                    for render_frame_host_sink_ids, the max entries will be same with the number of playing Switchers that are AudioOutputStreamBroker in the browser. people could playing sound from all of their frames but they listen 1 or 2 at that time. the paused play will terminate the AudioOutputStreamBroker after certain threshold. So the maximum number won't be much, less than 3. I guess.

                    for render_frame_host_id_to_main_frame_id_, it is more interesting one. In theory (you know this one more than I do) it is as many as RenderFrameAudioInputStreamFactory::Core object, which could be per frame. When quick testing though, it is quite smaller than number of frames even though it is created per frame initially but deleted somehow later. In the end, the frame that creates RenderFrameAudioInputStreamFactory::Core looks have RenderFrameAudioInputStreamFactory::Core objects.

                    so I expects this one is also same with render_frame_host_sink_ids.

                    Please reactivate this one if you have requests as it is about the question and I answered so I resolve it (few unresolved help focus on discussion).

                    Olga Sharonova

                    Please don't resolve when you answer questions, I already explained why: exactly to keep the focus on the discussion The reviewers will resolve if they are happy with the answer and have no follow-up questions.

                    Since you expect only a handful of objects, there is no need to use maps, a search in a vector is just as fast.

                    Let's say you have a vector (or a map if you like) of {main_frame_id, preferred_sink_id}
                    and a vector of
                    {Switcher, frame_id, main_frame_id}

                    Wouldn't it make the code easier to reason about? (GlobalRenderFrameHostId to GlobalRenderFrameHostId is a bit too hard on the eye)

                    Also, in my initial proposal I meant for Switcher to store both main frame id and frame id inside itself - they would make the code and the API even simpler

                    Line 169, Patchset 27: // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    Olga Sharonova . unresolved

                    Is the code there?
                    (Also please do not refer to the external context)

                    Sunggook Chue

                    but you know it is correct if you see the next CL? I thought the benefit of these relation CL is to know the future work so we can have complete class that doesn't have to updated the next CL.

                    anyway, I will remove this one.

                    Olga Sharonova

                    It was not in the next CL. and the CL chain is broken.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Olga Sharonova

                    I only see it marked as resolved https://chromium-review.googlesource.com/c/chromium/src/+/5686893/comment/a78938d3_bad42416/

                    Sunggook Chue

                    Did you suggest to register process id from the ::Core like main RHF ID?

                    I think setPreferredSinkId can be called even when ::Core object isn't called as ::Core object is created only when audio play is requested?

                    Olga Sharonova

                    In this specific comment we were discussing on which thread AudioOutputAuthorizationHandler is created.

                    Could you clarify the question you are asking, and ask it in the relevant place of the CL?

                    Line 76, Patchset 27: base::BindOnce(&CreateAudioOutputAuthHandlerOnUIThread, rfh_id),
                    Olga Sharonova . unresolved

                    There is no need to create the handler every time, please reconsider.
                    See RenderFrameAudioOutputStreamFactory::Core

                    Sunggook Chue

                    yes, you're right, we can have per process authorization_handler_, hmm, do you think have to have another table for "process - authorization_handler",

                    Isn't it clean design to create authorization_handler for every request as (1) we don't expect many setPreferredSinkId calls for the main page lifetime (assuming main page run on its own render process), (2) no need to listen to process termination to clean it (not sure if chromium has such event)?

                    Olga Sharonova

                    Don't you listen to the process termination already?

                    Line 209, Patchset 30 (Latest):std::string PreferredAudioOutputDeviceManager::GetPreferredSinkId(
                    Olga Sharonova . unresolved

                    const std::string& (no need to make early copies)

                    Line 253, Patchset 30 (Latest):void PreferredAudioOutputDeviceManager::UnregisterSwitchersFoFrame(
                    Olga Sharonova . unresolved

                    Just UnregisterMainFrame?
                    In any case, please indicate in the name that's it's only the main frame

                    Line 291, Patchset 30 (Latest):GlobalRenderFrameHostId
                    Olga Sharonova . unresolved

                    const GlobalRenderFrameHostId&

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 30
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Thu, 12 Sep 2024 12:26:00 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 13, 2024, 3:10:50 AM9/13/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova

                    Sunggook Chue added 8 comments

                    Patchset-level comments
                    File-level comment, Patchset 30:
                    Olga Sharonova . resolved

                    1) Please fix the CL chain, and keep it up to date for all next review rounds.
                    2) Please restore the design doc and close it for public editing.

                    Sunggook Chue

                    The latest CL are 4 and it is up to date, I abandoned not used ones. please let me know if there is anything else I need to do.

                    I repaired the doc, I restricted the commentor with invite based from link.

                    File-level comment, Patchset 30:
                    Sunggook Chue . resolved

                    addressed and replied comments.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Sunggook Chue

                    for map vs vector, I said that the end result is handful, but not in the middle of it. what I've observed that RenderFrameAudioInputStreamFactory::Core can be created 100 times, but deleted 100 times as well. so at some point, it could be large numbers so using map seems better.


                    map<GlobalRenderFrameHostId to GlobalRenderFrameHostId> is called from the RenderFrameAudioInputStreamFactory::Core when no Switcher is available. Switcher will read access of it after the entry was inserted by Core.

                    I might change the internal class name of RenderFrameHostSinkId as 'PreferredSinkIdToSwitcher' because RenderFrameHostSinkId is confusing with a name of GlobalRenderFrameHostId. please suggest if you have better name.

                    Line 169, Patchset 27: // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    Olga Sharonova . resolved

                    Is the code there?
                    (Also please do not refer to the external context)

                    Sunggook Chue

                    but you know it is correct if you see the next CL? I thought the benefit of these relation CL is to know the future work so we can have complete class that doesn't have to updated the next CL.

                    anyway, I will remove this one.

                    Olga Sharonova

                    It was not in the next CL. and the CL chain is broken.

                    Sunggook Chue

                    the next CL is https://chromium-review.googlesource.com/c/chromium/src/+/5814796/6. Please ignore any gray color (abandoned), somehow gerrit does not remove it automatically, maybe I have to unset and upload for the abandoned, I will try it.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Olga Sharonova

                    I only see it marked as resolved https://chromium-review.googlesource.com/c/chromium/src/+/5686893/comment/a78938d3_bad42416/

                    Sunggook Chue

                    Did you suggest to register process id from the ::Core like main RHF ID?

                    I think setPreferredSinkId can be called even when ::Core object isn't called as ::Core object is created only when audio play is requested?

                    Olga Sharonova

                    In this specific comment we were discussing on which thread AudioOutputAuthorizationHandler is created.

                    Could you clarify the question you are asking, and ask it in the relevant place of the CL?

                    Sunggook Chue

                    It looks you ask static render process ID for AudioOutputAuthorizationHandler; do not create AudioOutputAuthorizationHandler everytime.

                    we can discuss it on the below comment.

                    Line 76, Patchset 27: base::BindOnce(&CreateAudioOutputAuthHandlerOnUIThread, rfh_id),
                    Olga Sharonova . unresolved

                    There is no need to create the handler every time, please reconsider.
                    See RenderFrameAudioOutputStreamFactory::Core

                    Sunggook Chue

                    yes, you're right, we can have per process authorization_handler_, hmm, do you think have to have another table for "process - authorization_handler",

                    Isn't it clean design to create authorization_handler for every request as (1) we don't expect many setPreferredSinkId calls for the main page lifetime (assuming main page run on its own render process), (2) no need to listen to process termination to clean it (not sure if chromium has such event)?

                    Olga Sharonova

                    Don't you listen to the process termination already?

                    Sunggook Chue

                    no, we don't listen to, just Render frame host termination. multiple render frame hosts can be in the single system process, or even sub frame can have its own system process.

                    We might adjust the code little bit such that we check the sub or main frames before creating AudioOutputAuthorizationHandler, and create/cache for main frame RFH with preferred sink id.

                    I will update it, please let me know if you have better idea.

                    Line 209, Patchset 30:std::string PreferredAudioOutputDeviceManager::GetPreferredSinkId(
                    Olga Sharonova . unresolved

                    const std::string& (no need to make early copies)

                    Sunggook Chue

                    it is a return value, and returning

                    Line 291, Patchset 30:GlobalRenderFrameHostId
                    Olga Sharonova . resolved

                    const GlobalRenderFrameHostId&

                    Sunggook Chue

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 30
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Comment-Date: Fri, 13 Sep 2024 07:10:35 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 13, 2024, 4:06:04 AM9/13/24
                    to Sunggook Chue, Olga Sharonova, Guido Urdaneta, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Sunggook Chue

                    Olga Sharonova added 6 comments

                    Patchset-level comments
                    File-level comment, Patchset 30:
                    Olga Sharonova . unresolved

                    1) Please fix the CL chain, and keep it up to date for all next review rounds.
                    2) Please restore the design doc and close it for public editing.

                    Sunggook Chue

                    The latest CL are 4 and it is up to date, I abandoned not used ones. please let me know if there is anything else I need to do.

                    I repaired the doc, I restricted the commentor with invite based from link.

                    Olga Sharonova

                    Thanks.
                    The CL chain needs to be rebased, now all follow-up CLs are "indirect relation"

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Olga Sharonova

                    How about Switcher storing its main and native frame ids?
                    I'd like the code to be a bit more readable.

                    Line 169, Patchset 27: // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    Olga Sharonova . unresolved

                    Is the code there?
                    (Also please do not refer to the external context)

                    Sunggook Chue

                    but you know it is correct if you see the next CL? I thought the benefit of these relation CL is to know the future work so we can have complete class that doesn't have to updated the next CL.

                    anyway, I will remove this one.

                    Olga Sharonova

                    It was not in the next CL. and the CL chain is broken.

                    Sunggook Chue

                    the next CL is https://chromium-review.googlesource.com/c/chromium/src/+/5814796/6. Please ignore any gray color (abandoned), somehow gerrit does not remove it automatically, maybe I have to unset and upload for the abandoned, I will try it.

                    Olga Sharonova

                    Have you tried

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Olga Sharonova

                    I only see it marked as resolved https://chromium-review.googlesource.com/c/chromium/src/+/5686893/comment/a78938d3_bad42416/

                    Sunggook Chue

                    Did you suggest to register process id from the ::Core like main RHF ID?

                    I think setPreferredSinkId can be called even when ::Core object isn't called as ::Core object is created only when audio play is requested?

                    Olga Sharonova

                    In this specific comment we were discussing on which thread AudioOutputAuthorizationHandler is created.

                    Could you clarify the question you are asking, and ask it in the relevant place of the CL?

                    Sunggook Chue

                    It looks you ask static render process ID for AudioOutputAuthorizationHandler; do not create AudioOutputAuthorizationHandler everytime.

                    we can discuss it on the below comment.

                    Olga Sharonova

                    Could you please take a look at the original CL, where we are discussing that creating AudioOutputAuthorizationHandler on UI thread does not look reasonable, since AudioOutputAuthorizationHandler documentation sats explicitly that this is an IO thread class.

                    Line 76, Patchset 27: base::BindOnce(&CreateAudioOutputAuthHandlerOnUIThread, rfh_id),
                    Olga Sharonova . resolved

                    There is no need to create the handler every time, please reconsider.
                    See RenderFrameAudioOutputStreamFactory::Core

                    Sunggook Chue

                    yes, you're right, we can have per process authorization_handler_, hmm, do you think have to have another table for "process - authorization_handler",

                    Isn't it clean design to create authorization_handler for every request as (1) we don't expect many setPreferredSinkId calls for the main page lifetime (assuming main page run on its own render process), (2) no need to listen to process termination to clean it (not sure if chromium has such event)?

                    Olga Sharonova

                    Don't you listen to the process termination already?

                    Sunggook Chue

                    no, we don't listen to, just Render frame host termination. multiple render frame hosts can be in the single system process, or even sub frame can have its own system process.

                    We might adjust the code little bit such that we check the sub or main frames before creating AudioOutputAuthorizationHandler, and create/cache for main frame RFH with preferred sink id.

                    I will update it, please let me know if you have better idea.

                    Olga Sharonova

                    Ok, let's put caching aside for now.

                    Line 209, Patchset 30:std::string PreferredAudioOutputDeviceManager::GetPreferredSinkId(
                    Olga Sharonova . unresolved

                    const std::string& (no need to make early copies)

                    Sunggook Chue

                    it is a return value, and returning

                    Olga Sharonova

                    ?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 31
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Fri, 13 Sep 2024 08:05:49 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 14, 2024, 5:36:48 PM9/14/24
                    to Olga Sharonova, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Olga Sharonova

                    Sunggook Chue added 7 comments

                    Patchset-level comments
                    File-level comment, Patchset 32 (Latest):
                    Sunggook Chue . resolved

                    The latest patch is #32. thanks.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Sunggook Chue

                    Single frame id could have multiple DeviceSwitchers, so frame id doesn't 1:1 match with frame id, instead providing a method to DeviceSwitcher for retrieving frame ids seems better idea only when it is needed.

                    Line 169, Patchset 27: // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    Olga Sharonova . unresolved

                    Is the code there?
                    (Also please do not refer to the external context)

                    Sunggook Chue

                    but you know it is correct if you see the next CL? I thought the benefit of these relation CL is to know the future work so we can have complete class that doesn't have to updated the next CL.

                    anyway, I will remove this one.

                    Olga Sharonova

                    It was not in the next CL. and the CL chain is broken.

                    Sunggook Chue

                    the next CL is https://chromium-review.googlesource.com/c/chromium/src/+/5814796/6. Please ignore any gray color (abandoned), somehow gerrit does not remove it automatically, maybe I have to unset and upload for the abandoned, I will try it.

                    Olga Sharonova

                    Have you tried

                    Sunggook Chue

                    I tried, git cl upload command does not work yet all as it said it is abandoned. It is my first time of using relation CLs, many mistakes, sorry about that.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Olga Sharonova

                    I only see it marked as resolved https://chromium-review.googlesource.com/c/chromium/src/+/5686893/comment/a78938d3_bad42416/

                    Sunggook Chue

                    Did you suggest to register process id from the ::Core like main RHF ID?

                    I think setPreferredSinkId can be called even when ::Core object isn't called as ::Core object is created only when audio play is requested?

                    Olga Sharonova

                    In this specific comment we were discussing on which thread AudioOutputAuthorizationHandler is created.

                    Could you clarify the question you are asking, and ask it in the relevant place of the CL?

                    Sunggook Chue

                    It looks you ask static render process ID for AudioOutputAuthorizationHandler; do not create AudioOutputAuthorizationHandler everytime.

                    we can discuss it on the below comment.

                    Olga Sharonova

                    Could you please take a look at the original CL, where we are discussing that creating AudioOutputAuthorizationHandler on UI thread does not look reasonable, since AudioOutputAuthorizationHandler documentation sats explicitly that this is an IO thread class.

                    Sunggook Chue

                    It isn't just AudioOutputAuthorizationHandler anymore.

                    We also check if the given RFH id is main or not for setPreferredSinkId when there is Core object ever called before it. The only way is to check is calling RenderFrameHost::GetMainFrame, which is doable (getting RenderFrameHost object from the ID) only in the UI thread.

                    The latest commit has really minimized the UI thread use; just once per the unique RFH, which takes place only in the first setPreferredSinkId request.

                    Line 76, Patchset 27: base::BindOnce(&CreateAudioOutputAuthHandlerOnUIThread, rfh_id),
                    Olga Sharonova . resolved

                    There is no need to create the handler every time, please reconsider.
                    See RenderFrameAudioOutputStreamFactory::Core

                    Sunggook Chue

                    yes, you're right, we can have per process authorization_handler_, hmm, do you think have to have another table for "process - authorization_handler",

                    Isn't it clean design to create authorization_handler for every request as (1) we don't expect many setPreferredSinkId calls for the main page lifetime (assuming main page run on its own render process), (2) no need to listen to process termination to clean it (not sure if chromium has such event)?

                    Olga Sharonova

                    Don't you listen to the process termination already?

                    Sunggook Chue

                    no, we don't listen to, just Render frame host termination. multiple render frame hosts can be in the single system process, or even sub frame can have its own system process.

                    We might adjust the code little bit such that we check the sub or main frames before creating AudioOutputAuthorizationHandler, and create/cache for main frame RFH with preferred sink id.

                    I will update it, please let me know if you have better idea.

                    Olga Sharonova

                    Ok, let's put caching aside for now.

                    Sunggook Chue

                    see the latest code, I cached it for render frame host as suggested, but not by process id. it works well. thanks.

                    Line 209, Patchset 30:std::string PreferredAudioOutputDeviceManager::GetPreferredSinkId(
                    Olga Sharonova . resolved

                    const std::string& (no need to make early copies)

                    Sunggook Chue

                    it is a return value, and returning

                    Olga Sharonova

                    ?

                    Sunggook Chue

                    updated as suggested,

                    Line 253, Patchset 30:void PreferredAudioOutputDeviceManager::UnregisterSwitchersFoFrame(
                    Olga Sharonova . resolved

                    Just UnregisterMainFrame?
                    In any case, please indicate in the name that's it's only the main frame

                    Sunggook Chue

                    yes, it is updated since #31.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 32
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Comment-Date: Sat, 14 Sep 2024 21:36:37 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 20, 2024, 11:02:08 AM9/20/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta and Sunggook Chue

                    Olga Sharonova added 7 comments

                    File content/browser/renderer_host/media/audio_output_authorization_handler.h
                    Line 64, Patchset 32 (Latest): virtual void RequestDeviceAuthorization(
                    Olga Sharonova . unresolved

                    Ditto.

                    Line 58, Patchset 32 (Latest): virtual ~AudioOutputAuthorizationHandler();
                    Olga Sharonova . unresolved

                    If making virtual for tests, please note it in the comment.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 175, Patchset 32 (Latest): std::unique_ptr<AudioOutputAuthorizationHandler> authorization_handler_;
                    Olga Sharonova . unresolved

                    I think a frame has to use its own authorization handler, because a cross-origin frame does not necessarily have the same permissions as the main one.
                    +Guido.

                    Olga Sharonova

                    Could you clarify? I did not understand the statement.
                    Also, could you provide the reasoning?

                    My reasoning is external mapping needs maintenance and thus is error-prone. I don't see any particular issues with mapping not being 1:1.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 20, Patchset 32 (Latest):// AudioOutputAuthorizationHandler is created per main RenderFrameHost object,
                    Olga Sharonova . unresolved

                    Haven't we agreed to not cache it a while back?

                    Line 37, Patchset 32 (Latest): // Sub frame can't call the API.
                    Olga Sharonova . unresolved

                    Wny?

                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . unresolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Olga Sharonova

                    I only see it marked as resolved https://chromium-review.googlesource.com/c/chromium/src/+/5686893/comment/a78938d3_bad42416/

                    Sunggook Chue

                    Did you suggest to register process id from the ::Core like main RHF ID?

                    I think setPreferredSinkId can be called even when ::Core object isn't called as ::Core object is created only when audio play is requested?

                    Olga Sharonova

                    In this specific comment we were discussing on which thread AudioOutputAuthorizationHandler is created.

                    Could you clarify the question you are asking, and ask it in the relevant place of the CL?

                    Sunggook Chue

                    It looks you ask static render process ID for AudioOutputAuthorizationHandler; do not create AudioOutputAuthorizationHandler everytime.

                    we can discuss it on the below comment.

                    Olga Sharonova

                    Could you please take a look at the original CL, where we are discussing that creating AudioOutputAuthorizationHandler on UI thread does not look reasonable, since AudioOutputAuthorizationHandler documentation sats explicitly that this is an IO thread class.

                    Sunggook Chue

                    It isn't just AudioOutputAuthorizationHandler anymore.

                    We also check if the given RFH id is main or not for setPreferredSinkId when there is Core object ever called before it. The only way is to check is calling RenderFrameHost::GetMainFrame, which is doable (getting RenderFrameHost object from the ID) only in the UI thread.

                    The latest commit has really minimized the UI thread use; just once per the unique RFH, which takes place only in the first setPreferredSinkId request.

                    Olga Sharonova

                    Please see my previous comments: what I'm asking is to move authorization handler creation to IO thread. There is nothing preventing it, no matter what needs to be done on UI thread prior to that.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 32
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Fri, 20 Sep 2024 15:01:55 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 20, 2024, 11:16:04 AM9/20/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 30, Patchset 32 (Latest): media::AudioSystem* audio_system =
                    BrowserMainLoop::GetInstance()->audio_system();
                    MediaStreamManager* media_stream_manager =
                    BrowserMainLoop::GetInstance()->media_stream_manager();
                    Olga Sharonova . unresolved

                    These can be passed into PreferredAudioOutputDeviceManager constructor, no need to access BrowserMainLoop.

                    Gerrit-Comment-Date: Fri, 20 Sep 2024 15:15:53 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 20, 2024, 11:47:14 AM9/20/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta and Olga Sharonova

                    Sunggook Chue added 2 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 175, Patchset 32 (Latest): std::unique_ptr<AudioOutputAuthorizationHandler> authorization_handler_;
                    Olga Sharonova . unresolved

                    I think a frame has to use its own authorization handler, because a cross-origin frame does not necessarily have the same permissions as the main one.
                    +Guido.

                    Sunggook Chue

                    Authorization handler is used by the main frame alone, not from the sub frames. The code returns an error if it is a sub frame before calling auth handler.

                    Do we still have an issue here?

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 20, Patchset 32 (Latest):// AudioOutputAuthorizationHandler is created per main RenderFrameHost object,
                    Olga Sharonova . unresolved

                    Haven't we agreed to not cache it a while back?

                    Sunggook Chue

                    yes, we did, but I realized that we could cache per main RenderFrameHost that will help less creation of auth handler.

                    Please let me know if there is an issue here?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 32
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Comment-Date: Fri, 20 Sep 2024 15:47:03 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 21, 2024, 9:27:49 PM9/21/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 9 comments

                    Patchset-level comments
                    Olga Sharonova . unresolved

                    1) Please fix the CL chain, and keep it up to date for all next review rounds.
                    2) Please restore the design doc and close it for public editing.

                    Sunggook Chue

                    The latest CL are 4 and it is up to date, I abandoned not used ones. please let me know if there is anything else I need to do.

                    I repaired the doc, I restricted the commentor with invite based from link.

                    Olga Sharonova

                    Thanks.
                    The CL chain needs to be rebased, now all follow-up CLs are "indirect relation"

                    Sunggook Chue

                    I created the next branch with -b command, and --set-upstream-to=localBranch. it works fine in terms of 'fetch' command.

                    Based on research, i tried to convert indirect to direct by resetting --set-upstream-to=origin/localBranch instead of --set-upstream-to=localBranch, it failed due to missing origin/localBranch. will researching it.

                    File content/browser/renderer_host/media/audio_output_authorization_handler.h
                    Line 64, Patchset 32: virtual void RequestDeviceAuthorization(
                    Olga Sharonova . resolved

                    Ditto.

                    Sunggook Chue

                    Done

                    Line 58, Patchset 32: virtual ~AudioOutputAuthorizationHandler();
                    Olga Sharonova . resolved

                    If making virtual for tests, please note it in the comment.

                    Sunggook Chue

                    Done

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 175, Patchset 32: std::unique_ptr<AudioOutputAuthorizationHandler> authorization_handler_;
                    Olga Sharonova . resolved

                    I think a frame has to use its own authorization handler, because a cross-origin frame does not necessarily have the same permissions as the main one.
                    +Guido.

                    Sunggook Chue

                    Authorization handler is used by the main frame alone, not from the sub frames. The code returns an error if it is a sub frame before calling auth handler.

                    Do we still have an issue here?

                    Sunggook Chue

                    I think it again, we can avoid this cross-origin issue yet all by creating AudioOutputAuthorizationHandler per request as it is on IO thread now, so much effective.

                    Olga Sharonova . resolved
                    Sunggook Chue

                    I'm fine to have it, see how it looks like.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 20, Patchset 32:// AudioOutputAuthorizationHandler is created per main RenderFrameHost object,
                    Olga Sharonova . resolved

                    Haven't we agreed to not cache it a while back?

                    Sunggook Chue

                    yes, we did, but I realized that we could cache per main RenderFrameHost that will help less creation of auth handler.

                    Please let me know if there is an issue here?

                    Sunggook Chue

                    ok, I will remove the cache for allowing cross-origin sub frames can call it.

                    Line 30, Patchset 32: media::AudioSystem* audio_system =

                    BrowserMainLoop::GetInstance()->audio_system();
                    MediaStreamManager* media_stream_manager =
                    BrowserMainLoop::GetInstance()->media_stream_manager();
                    Olga Sharonova . resolved

                    These can be passed into PreferredAudioOutputDeviceManager constructor, no need to access BrowserMainLoop.

                    Sunggook Chue

                    it's good idea, PreferredAudioOutputDeviceManager relies on the MediaStreamManager and created from it. I will update it. thanks.

                    Line 37, Patchset 32: // Sub frame can't call the API.
                    Olga Sharonova . resolved

                    Wny?

                    Sunggook Chue

                    Initially, I proposed no allowance from the sub frames and but realized that we allow it later. sorry for confusion.

                    Line 73, Patchset 25: return std::make_unique<AudioOutputAuthorizationHandler>(
                    Olga Sharonova . resolved

                    Please do not forget to address the comments from the previous CL. You can add them here, to keep them in mind.

                    Sunggook Chue

                    I think all are resolved, see https://chromium-review.googlesource.com/c/chromium/src/+/5686893/7?tab=comments.

                    Olga Sharonova

                    I only see it marked as resolved https://chromium-review.googlesource.com/c/chromium/src/+/5686893/comment/a78938d3_bad42416/

                    Sunggook Chue

                    Did you suggest to register process id from the ::Core like main RHF ID?

                    I think setPreferredSinkId can be called even when ::Core object isn't called as ::Core object is created only when audio play is requested?

                    Olga Sharonova

                    In this specific comment we were discussing on which thread AudioOutputAuthorizationHandler is created.

                    Could you clarify the question you are asking, and ask it in the relevant place of the CL?

                    Sunggook Chue

                    It looks you ask static render process ID for AudioOutputAuthorizationHandler; do not create AudioOutputAuthorizationHandler everytime.

                    we can discuss it on the below comment.

                    Olga Sharonova

                    Could you please take a look at the original CL, where we are discussing that creating AudioOutputAuthorizationHandler on UI thread does not look reasonable, since AudioOutputAuthorizationHandler documentation sats explicitly that this is an IO thread class.

                    Sunggook Chue

                    It isn't just AudioOutputAuthorizationHandler anymore.

                    We also check if the given RFH id is main or not for setPreferredSinkId when there is Core object ever called before it. The only way is to check is calling RenderFrameHost::GetMainFrame, which is doable (getting RenderFrameHost object from the ID) only in the UI thread.

                    The latest commit has really minimized the UI thread use; just once per the unique RFH, which takes place only in the first setPreferredSinkId request.

                    Olga Sharonova

                    Please see my previous comments: what I'm asking is to move authorization handler creation to IO thread. There is nothing preventing it, no matter what needs to be done on UI thread prior to that.

                    Sunggook Chue

                    thanks, done with passing MediaStreamManager to it.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 33
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Sun, 22 Sep 2024 01:27:37 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 23, 2024, 11:13:00 AM9/23/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 20 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 193, Patchset 33 (Latest): GlobalRenderFrameHostId main_frame_id_for_testing_;
                    Olga Sharonova . unresolved

                    The role of this is not clear. Why do we need it , if we can provide a custom authorization_handler_for_testing_ which could reject whatever frame we want to reject?

                    Line 185, Patchset 33 (Latest): std::map</*main RFH id=*/GlobalRenderFrameHostId, PreferredSinkIdToSwitcher>
                    Olga Sharonova . unresolved

                    This does not need to be a map, as main RFH id is a part of "PreferredSinkIdToSwitcher". So set is enough. (Otherwise we store main RFH id twice)

                    Line 172, Patchset 33 (Latest): std::vector<DeviceSwitcher> active_device_switchers_;
                    Olga Sharonova . unresolved

                    Why are they called "active"? Are there any passive ones?

                    Line 170, Patchset 33 (Latest): GlobalRenderFrameHostId main_frame_global_id_;
                    Olga Sharonova . unresolved

                    const, and move it up?

                    Line 156, Patchset 33 (Latest): preferred_sink_id_ = sink_id;
                    Olga Sharonova . unresolved

                    Shouldn't the setter also update the switchers if necessary?

                    Line 146, Patchset 33 (Latest): PreferredSinkIdToSwitcher();
                    Olga Sharonova . unresolved

                    Should take main_frame_global_id?

                    Line 143, Patchset 33 (Latest): raw_ptr<AudioOutputDeviceSwitcher> output_device_switcher;
                    Olga Sharonova . unresolved

                    "native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read. OOC: Why do you want to track it externally?

                    Line 137, Patchset 33 (Latest): class PreferredSinkIdToSwitcher {
                    Olga Sharonova . unresolved

                    Naming is not very descriptive. Maybe MainFramePreferredSinkIdConfig, or something along the line? (it's not SinkId to a switcher, there are multiple switcher)

                    Line 128, Patchset 33 (Latest): const GlobalRenderFrameHostId& GetMainRenderFrameHostId(
                    Olga Sharonova . unresolved

                    Since the whole API it passing GlobalRenderFrameHostId by value, we can return it by value here as well (I think it was me who suggested to return const ref - sorry for misleading)

                    Line 49, Patchset 33 (Latest):// The methods are virtual for testing purpose.
                    Olga Sharonova . unresolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 64, Patchset 33 (Latest):
                    std::unique_ptr<AudioOutputAuthorizationHandler> authorization_handler;
                    if (authorization_handler_for_testing_) {
                    authorization_handler = std::move(authorization_handler_for_testing_);
                    }
                    Olga Sharonova . unresolved

                    Move after "if" below and adjust? According to the main logic, authorization handler is only created for a non-default device.

                    Also, this approach allows for only one call to SetPreferredSinkId(), unless there's another SetAuthorizationForTesting() call. Please document that for SetAuthorizationForTesting() in the header.

                    A cleaner way would be to inject into the constructor an optional callback "create authorization handler for testing".

                    Line 144, Patchset 33 (Latest):// The cache already exists, it will update the preferred sink id for the
                    Olga Sharonova . unresolved

                    If?

                    Line 182, Patchset 33 (Latest): const GlobalRenderFrameHostId& main_frame_id =
                    Olga Sharonova . unresolved

                    GlobalRenderFrameHostId

                    Line 184, Patchset 33 (Latest):
                    Olga Sharonova . unresolved

                    What if (!main_frame_id)?

                    Line 202, Patchset 33 (Latest): const GlobalRenderFrameHostId& main_frame_id =
                    Olga Sharonova . unresolved

                    GlobalRenderFrameHostId

                    Line 222, Patchset 33 (Latest): const GlobalRenderFrameHostId& main_frame_id =
                    Olga Sharonova . unresolved

                    value, not const ref

                    Line 224, Patchset 33 (Latest):
                    Olga Sharonova . unresolved

                    What if (!main_frame_id)?

                    Line 278, Patchset 33 (Latest): preferred_sink_id_switchers_.erase(main_frame_id);
                    Olga Sharonova . unresolved

                    DCHECK as well?

                    Line 282, Patchset 33 (Latest):PreferredAudioOutputDeviceManager::GetMainRenderFrameHostId(
                    Olga Sharonova . unresolved

                    MaybeGetCachedMainRenderFrameHostId()

                    and document that it will return an empty id if there is no entry

                    Line 297, Patchset 33 (Latest): AudioOutputDeviceSwitcher* device_switcher) {
                    Olga Sharonova . unresolved

                    It always seems to be null, why do we need it?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 33
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Mon, 23 Sep 2024 15:12:51 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 23, 2024, 9:08:04 PM9/23/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 23 comments

                    Patchset-level comments
                    File-level comment, Patchset 30:
                    Olga Sharonova . resolved

                    1) Please fix the CL chain, and keep it up to date for all next review rounds.
                    2) Please restore the design doc and close it for public editing.

                    Sunggook Chue

                    The latest CL are 4 and it is up to date, I abandoned not used ones. please let me know if there is anything else I need to do.

                    I repaired the doc, I restricted the commentor with invite based from link.

                    Olga Sharonova

                    Thanks.
                    The CL chain needs to be rebased, now all follow-up CLs are "indirect relation"

                    Sunggook Chue

                    I created the next branch with -b command, and --set-upstream-to=localBranch. it works fine in terms of 'fetch' command.

                    Based on research, i tried to convert indirect to direct by resetting --set-upstream-to=origin/localBranch instead of --set-upstream-to=localBranch, it failed due to missing origin/localBranch. will researching it.

                    Sunggook Chue

                    It looks indirect is disappear for me. please reactive it if it is shown to you.

                    File-level comment, Patchset 35 (Latest):
                    Sunggook Chue . resolved

                    Thanks a lot!

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 193, Patchset 33: GlobalRenderFrameHostId main_frame_id_for_testing_;
                    Olga Sharonova . resolved

                    The role of this is not clear. Why do we need it , if we can provide a custom authorization_handler_for_testing_ which could reject whatever frame we want to reject?

                    Sunggook Chue

                    yes, we can delete it. thanks.

                    Line 185, Patchset 33: std::map</*main RFH id=*/GlobalRenderFrameHostId, PreferredSinkIdToSwitcher>
                    Olga Sharonova . resolved

                    This does not need to be a map, as main RFH id is a part of "PreferredSinkIdToSwitcher". So set is enough. (Otherwise we store main RFH id twice)

                    Sunggook Chue

                    we can use vector here.

                    Line 172, Patchset 33: std::vector<DeviceSwitcher> active_device_switchers_;
                    Olga Sharonova . resolved

                    Why are they called "active"? Are there any passive ones?

                    Sunggook Chue

                    good questions, no passive. updated to simply 'device_switchers'.

                    Line 170, Patchset 33: GlobalRenderFrameHostId main_frame_global_id_;
                    Olga Sharonova . resolved

                    const, and move it up?

                    Sunggook Chue

                    Done

                    Line 156, Patchset 33: preferred_sink_id_ = sink_id;
                    Olga Sharonova . unresolved

                    Shouldn't the setter also update the switchers if necessary?

                    Sunggook Chue

                    switcher is updated by active_device_switchers() directly because device_swithcer could be added multiple times for single 'preferred sink id' ('single PreferredSinkIdToSwitcher will have single 'preferred sink id').

                    Line 146, Patchset 33: PreferredSinkIdToSwitcher();
                    Olga Sharonova . resolved

                    Should take main_frame_global_id?

                    Sunggook Chue

                    thanks,

                    Line 143, Patchset 33: raw_ptr<AudioOutputDeviceSwitcher> output_device_switcher;
                    Olga Sharonova . unresolved

                    "native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read. OOC: Why do you want to track it externally?

                    Sunggook Chue

                    Initially it was private, but active_device_switchers() is public that returns the structure so move the structure to the public as 'native frame id' and 'device switcher' should be paired.

                    If we really keep it under private, then we can modify the active_device_switchers().

                    MainFramePreferredSinkIdConfig.AddSwitcher('main frame id', 'native frame id', 'device switcher object').

                    MainFramePreferredSinkIdConfig.GetDeviceSwitchers('main frame id'): The implementation has to create new vector of 'device switcher object' from the internal std::vector<DeviceSwitcher>.

                    The alternative seems more complex to understand the code. maybe other way to implement, any suggestion?

                    Line 137, Patchset 33: class PreferredSinkIdToSwitcher {
                    Olga Sharonova . resolved

                    Naming is not very descriptive. Maybe MainFramePreferredSinkIdConfig, or something along the line? (it's not SinkId to a switcher, there are multiple switcher)

                    Sunggook Chue

                    MainFramePreferredSinkIdConfig sounds good. thanks.

                    Line 128, Patchset 33: const GlobalRenderFrameHostId& GetMainRenderFrameHostId(
                    Olga Sharonova . resolved

                    Since the whole API it passing GlobalRenderFrameHostId by value, we can return it by value here as well (I think it was me who suggested to return const ref - sorry for misleading)

                    Sunggook Chue

                    Done

                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . resolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    Sunggook Chue

                    Done

                    Line 169, Patchset 27: // `RenderFrameAudioOutputStreamFactory::Core::Init()` and deletion of the
                    Olga Sharonova . resolved

                    Is the code there?
                    (Also please do not refer to the external context)

                    Sunggook Chue

                    but you know it is correct if you see the next CL? I thought the benefit of these relation CL is to know the future work so we can have complete class that doesn't have to updated the next CL.

                    anyway, I will remove this one.

                    Olga Sharonova

                    It was not in the next CL. and the CL chain is broken.

                    Sunggook Chue

                    the next CL is https://chromium-review.googlesource.com/c/chromium/src/+/5814796/6. Please ignore any gray color (abandoned), somehow gerrit does not remove it automatically, maybe I have to unset and upload for the abandoned, I will try it.

                    Olga Sharonova

                    Have you tried

                    Sunggook Chue

                    I tried, git cl upload command does not work yet all as it said it is abandoned. It is my first time of using relation CLs, many mistakes, sorry about that.

                    Sunggook Chue

                    It looks indirect is disappear for me. please reactive it if it is shown to you.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc

                    std::unique_ptr<AudioOutputAuthorizationHandler> authorization_handler;
                    if (authorization_handler_for_testing_) {
                    authorization_handler = std::move(authorization_handler_for_testing_);
                    }
                    Olga Sharonova . resolved

                    Move after "if" below and adjust? According to the main logic, authorization handler is only created for a non-default device.

                    Also, this approach allows for only one call to SetPreferredSinkId(), unless there's another SetAuthorizationForTesting() call. Please document that for SetAuthorizationForTesting() in the header.

                    A cleaner way would be to inject into the constructor an optional callback "create authorization handler for testing".

                    Sunggook Chue

                    I follow the above 2 suggestions, but adding optional para for the testing code touched the product code where I'd like to avoid if possible; testing code is isolated clearly as much as possible.

                    I resolve this one, please reactive if you think adding optional param is better.

                    Line 144, Patchset 33:// The cache already exists, it will update the preferred sink id for the
                    Olga Sharonova . resolved

                    If?

                    Sunggook Chue

                    Done

                    Line 182, Patchset 33: const GlobalRenderFrameHostId& main_frame_id =
                    Olga Sharonova . resolved

                    GlobalRenderFrameHostId

                    Sunggook Chue

                    use const GlobalRenderFrameHostId.

                    Line 184, Patchset 33:
                    Olga Sharonova . resolved

                    What if (!main_frame_id)?

                    Sunggook Chue

                    it should exist at this time if the contract is correct, adding CHECK.

                    Line 202, Patchset 33: const GlobalRenderFrameHostId& main_frame_id =
                    Olga Sharonova . resolved

                    GlobalRenderFrameHostId

                    Sunggook Chue

                    const GlobalRenderFrameHostId

                    Line 222, Patchset 33: const GlobalRenderFrameHostId& main_frame_id =
                    Olga Sharonova . resolved

                    value, not const ref

                    Sunggook Chue

                    Done

                    Line 224, Patchset 33:
                    Olga Sharonova . resolved

                    What if (!main_frame_id)?

                    Sunggook Chue

                    It failed on the preferred_sink_id_switchers_.find(main_frame_id) or (new API of FindSinkIdConfig) that does nothing.

                    Line 278, Patchset 33: preferred_sink_id_switchers_.erase(main_frame_id);
                    Olga Sharonova . resolved

                    DCHECK as well?

                    Sunggook Chue

                    no, preferred_sink_id_switchers_ has an entry only when SetSink* API is called or AddSwticher is called. but UnregisterMainFrameOnIOThread will be called when RFH is deleted regardless of these APIs are called.

                    Please reactive it if it is different from your understanding.

                    Line 282, Patchset 33:PreferredAudioOutputDeviceManager::GetMainRenderFrameHostId(
                    Olga Sharonova . resolved

                    MaybeGetCachedMainRenderFrameHostId()

                    and document that it will return an empty id if there is no entry

                    Sunggook Chue

                    Done

                    Line 297, Patchset 33: AudioOutputDeviceSwitcher* device_switcher) {
                    Olga Sharonova . resolved

                    It always seems to be null, why do we need it?

                    Sunggook Chue

                    no, if it is also called from the AddSwitcher where the value exists.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 35
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 24 Sep 2024 01:07:52 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 24, 2024, 8:00:05 AM9/24/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    Patchset-level comments
                    File-level comment, Patchset 35 (Latest):
                    Olga Sharonova . unresolved

                    Please unmark as "resolved" the answers to the questions which have meanings conceptually different from "done".

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 35
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 24 Sep 2024 11:59:54 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 24, 2024, 8:01:42 AM9/24/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    Patchset-level comments
                    Olga Sharonova . unresolved

                    And please update the CL chain.

                    Gerrit-Comment-Date: Tue, 24 Sep 2024 12:01:31 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 25, 2024, 2:35:40 AM9/25/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 3 comments

                    Patchset-level comments
                    Olga Sharonova . unresolved

                    Please unmark as "resolved" the answers to the questions which have meanings conceptually different from "done".

                    Sunggook Chue

                    I just uploaded this CL, not the next so it looks it causes indirection on this relation.

                    upload next CLs, then its indirection disappeared.

                    Olga Sharonova . resolved

                    And please update the CL chain.

                    Sunggook Chue

                    Done

                    Sunggook Chue . resolved

                    thanks!

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 35
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 25 Sep 2024 06:35:31 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 25, 2024, 6:10:36 PM9/25/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . unresolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    Sunggook Chue

                    Done

                    Sunggook Chue

                    Interface looks meaning there are multiple implementations for the feature (manager), but not for us. I don't see many media side code example that introduced the interface for the Mock test only even they Mock is common for test.

                    If you still think interface is good, I could support it though.

                    Gerrit-Comment-Date: Wed, 25 Sep 2024 22:10:20 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 26, 2024, 4:22:58 AM9/26/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . unresolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    Sunggook Chue

                    Done

                    Sunggook Chue

                    Interface looks meaning there are multiple implementations for the feature (manager), but not for us. I don't see many media side code example that introduced the interface for the Mock test only even they Mock is common for test.

                    If you still think interface is good, I could support it though.

                    Olga Sharonova

                    The fact that you made it all virtual for testing means that you already have at least two implementations, doesn't it?
                    It's a common practice in chromium when an object is an external dependency and needs to be mocked. And it's cleaner than making all the methods virtual for testing and engaging in implementation inheritance.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 35
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 26 Sep 2024 08:22:49 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Sep 26, 2024, 9:29:32 PM9/26/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 2 comments

                    Patchset-level comments
                    File-level comment, Patchset 35:
                    Sunggook Chue . resolved

                    thanks,

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . resolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    Sunggook Chue

                    Done

                    Sunggook Chue

                    Interface looks meaning there are multiple implementations for the feature (manager), but not for us. I don't see many media side code example that introduced the interface for the Mock test only even they Mock is common for test.

                    If you still think interface is good, I could support it though.

                    Olga Sharonova

                    The fact that you made it all virtual for testing means that you already have at least two implementations, doesn't it?
                    It's a common practice in chromium when an object is an external dependency and needs to be mocked. And it's cleaner than making all the methods virtual for testing and engaging in implementation inheritance.

                    Sunggook Chue

                    One of concern I had was that we have to force the Mock class to provide all virtual methods, which can bloat the test code where it Mock only single method now.

                    If we use single file for Mock, then it would be harder for selective Mock methods to have different implementation by test requirement.

                    so, even if we provide an interface, the test code will have to Mock the AudioOutputAuthorizationHandler directly. updated.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 35
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Fri, 27 Sep 2024 01:29:21 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Sep 30, 2024, 12:05:31 PM9/30/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 2 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 143, Patchset 33: raw_ptr<AudioOutputDeviceSwitcher> output_device_switcher;
                    Olga Sharonova . unresolved

                    "native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read. OOC: Why do you want to track it externally?

                    Sunggook Chue

                    Initially it was private, but active_device_switchers() is public that returns the structure so move the structure to the public as 'native frame id' and 'device switcher' should be paired.

                    If we really keep it under private, then we can modify the active_device_switchers().

                    MainFramePreferredSinkIdConfig.AddSwitcher('main frame id', 'native frame id', 'device switcher object').

                    MainFramePreferredSinkIdConfig.GetDeviceSwitchers('main frame id'): The implementation has to create new vector of 'device switcher object' from the internal std::vector<DeviceSwitcher>.

                    The alternative seems more complex to understand the code. maybe other way to implement, any suggestion?

                    Olga Sharonova

                    What do you refer to as "it was private"?
                    What I mean is, if I remember correctly, the device switcher interface had the frame ID as a getter at some point. AudioOutputDeviceSwitcher can have GetOwnFrameId() (so DeviceSwitcher struct won't be needed) - and even GetMainFrameId() as well if we wish so.

                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . unresolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    Sunggook Chue

                    Done

                    Sunggook Chue

                    Interface looks meaning there are multiple implementations for the feature (manager), but not for us. I don't see many media side code example that introduced the interface for the Mock test only even they Mock is common for test.

                    If you still think interface is good, I could support it though.

                    Olga Sharonova

                    The fact that you made it all virtual for testing means that you already have at least two implementations, doesn't it?
                    It's a common practice in chromium when an object is an external dependency and needs to be mocked. And it's cleaner than making all the methods virtual for testing and engaging in implementation inheritance.

                    Sunggook Chue

                    One of concern I had was that we have to force the Mock class to provide all virtual methods, which can bloat the test code where it Mock only single method now.

                    If we use single file for Mock, then it would be harder for selective Mock methods to have different implementation by test requirement.

                    so, even if we provide an interface, the test code will have to Mock the AudioOutputAuthorizationHandler directly. updated.

                    Olga Sharonova

                    Could you please place interface and Impl into the same header file (it's fine), and rename all the files back? Gerrit does not see similarities after this rename, so I can't see the diff (here: https://chromium-review.googlesource.com/c/chromium/src/+/5664173/33..36) and can't do an incremental review.

                    Could you clarify "If we use single file for Mock" part - what do you mean?
                    There can be a common mock for multiple test suits if convenient, but also tests suits can customize that mock and write their own.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 36
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Mon, 30 Sep 2024 16:05:20 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 1, 2024, 2:07:02 AM10/1/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 4 comments

                    Patchset-level comments
                    File-level comment, Patchset 35:
                    Olga Sharonova . resolved

                    Please unmark as "resolved" the answers to the questions which have meanings conceptually different from "done".

                    Sunggook Chue

                    I just uploaded this CL, not the next so it looks it causes indirection on this relation.

                    upload next CLs, then its indirection disappeared.

                    Sunggook Chue

                    Acknowledged

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 156, Patchset 33: preferred_sink_id_ = sink_id;
                    Olga Sharonova . resolved

                    Shouldn't the setter also update the switchers if necessary?

                    Sunggook Chue

                    switcher is updated by active_device_switchers() directly because device_swithcer could be added multiple times for single 'preferred sink id' ('single PreferredSinkIdToSwitcher will have single 'preferred sink id').

                    Sunggook Chue

                    Please reactivate it if my above explanation isn't sufficient. thanks.

                    Line 143, Patchset 33: raw_ptr<AudioOutputDeviceSwitcher> output_device_switcher;
                    Olga Sharonova . unresolved

                    "native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read. OOC: Why do you want to track it externally?

                    Sunggook Chue

                    Initially it was private, but active_device_switchers() is public that returns the structure so move the structure to the public as 'native frame id' and 'device switcher' should be paired.

                    If we really keep it under private, then we can modify the active_device_switchers().

                    MainFramePreferredSinkIdConfig.AddSwitcher('main frame id', 'native frame id', 'device switcher object').

                    MainFramePreferredSinkIdConfig.GetDeviceSwitchers('main frame id'): The implementation has to create new vector of 'device switcher object' from the internal std::vector<DeviceSwitcher>.

                    The alternative seems more complex to understand the code. maybe other way to implement, any suggestion?

                    Olga Sharonova

                    What do you refer to as "it was private"?
                    What I mean is, if I remember correctly, the device switcher interface had the frame ID as a getter at some point. AudioOutputDeviceSwitcher can have GetOwnFrameId() (so DeviceSwitcher struct won't be needed) - and even GetMainFrameId() as well if we wish so.

                    Sunggook Chue

                    I'm confused, can you help me understand?

                    'native_frame_id' in the DeviceSwitcher isn't required in terms of functionality but it is introduced for better readability as your feedback.

                    We can get 'native_frame_id' if we enforce the implementor of the AudioOutputDeviceSwitcher to provide 'GetOwnFrameId'. But this will add unnecessary burden to the implementor even when it isn't used for functionality, and it also hide readability that was initial feedback?

                    maybe I misunderstood your initial feedback ""native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read.".

                    If you're okay, we can remove "native_frame_id" and DeviceSwitcher yet all from this class and no GetOwnFrameId yet all.

                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . unresolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    Sunggook Chue

                    Done

                    Sunggook Chue

                    Interface looks meaning there are multiple implementations for the feature (manager), but not for us. I don't see many media side code example that introduced the interface for the Mock test only even they Mock is common for test.

                    If you still think interface is good, I could support it though.

                    Olga Sharonova

                    The fact that you made it all virtual for testing means that you already have at least two implementations, doesn't it?
                    It's a common practice in chromium when an object is an external dependency and needs to be mocked. And it's cleaner than making all the methods virtual for testing and engaging in implementation inheritance.

                    Sunggook Chue

                    One of concern I had was that we have to force the Mock class to provide all virtual methods, which can bloat the test code where it Mock only single method now.

                    If we use single file for Mock, then it would be harder for selective Mock methods to have different implementation by test requirement.

                    so, even if we provide an interface, the test code will have to Mock the AudioOutputAuthorizationHandler directly. updated.

                    Olga Sharonova

                    Could you please place interface and Impl into the same header file (it's fine), and rename all the files back? Gerrit does not see similarities after this rename, so I can't see the diff (here: https://chromium-review.googlesource.com/c/chromium/src/+/5664173/33..36) and can't do an incremental review.

                    Could you clarify "If we use single file for Mock" part - what do you mean?
                    There can be a common mock for multiple test suits if convenient, but also tests suits can customize that mock and write their own.

                    Sunggook Chue

                    yes, I mentioned common mock, but looks didn't provide any value as each test customize the mock (no common mock is used). we avoid this common mock by mocking the directly the PreferredAudioOutputDeviceManagerImpl.

                    I update to merge the file to single one. thanks.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 36
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 01 Oct 2024 06:06:50 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
                    Comment-In-Reply-To: Olga Sharonova <ol...@google.com>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 1, 2024, 11:06:38 AM10/1/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 7 comments

                    Patchset-level comments
                    File-level comment, Patchset 37 (Latest):
                    Olga Sharonova . resolved

                    Thanks for renaming back!

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 181, Patchset 37 (Latest): std::vector<DeviceSwitcher>& device_switchers() {
                    Olga Sharonova . unresolved

                    Please remove it and introduce a proper API: add / update sink/ clear - whatever.

                    Line 156, Patchset 33: preferred_sink_id_ = sink_id;
                    Olga Sharonova . unresolved

                    Shouldn't the setter also update the switchers if necessary?

                    Sunggook Chue

                    switcher is updated by active_device_switchers() directly because device_swithcer could be added multiple times for single 'preferred sink id' ('single PreferredSinkIdToSwitcher will have single 'preferred sink id').

                    Sunggook Chue

                    Please reactivate it if my above explanation isn't sufficient. thanks.

                    Olga Sharonova

                    I've asked earlier on many occasions to not resolve the comments which are discussions. I will resolve them when I'm satisfied with the outcome of the discussion. Resolved comments, as I explain, get lost, and it's a waste of my time to recall a discussion and search for it.

                    I won't be reviewing at all the uploads which do not satisfy this request. Thank you for understanding.

                    ---

                    I don't understand this explanation, please see the other comments.

                    Line 143, Patchset 33: raw_ptr<AudioOutputDeviceSwitcher> output_device_switcher;
                    Olga Sharonova . unresolved

                    "native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read. OOC: Why do you want to track it externally?

                    Sunggook Chue

                    Initially it was private, but active_device_switchers() is public that returns the structure so move the structure to the public as 'native frame id' and 'device switcher' should be paired.

                    If we really keep it under private, then we can modify the active_device_switchers().

                    MainFramePreferredSinkIdConfig.AddSwitcher('main frame id', 'native frame id', 'device switcher object').

                    MainFramePreferredSinkIdConfig.GetDeviceSwitchers('main frame id'): The implementation has to create new vector of 'device switcher object' from the internal std::vector<DeviceSwitcher>.

                    The alternative seems more complex to understand the code. maybe other way to implement, any suggestion?

                    Olga Sharonova

                    What do you refer to as "it was private"?
                    What I mean is, if I remember correctly, the device switcher interface had the frame ID as a getter at some point. AudioOutputDeviceSwitcher can have GetOwnFrameId() (so DeviceSwitcher struct won't be needed) - and even GetMainFrameId() as well if we wish so.

                    Sunggook Chue

                    I'm confused, can you help me understand?

                    'native_frame_id' in the DeviceSwitcher isn't required in terms of functionality but it is introduced for better readability as your feedback.

                    We can get 'native_frame_id' if we enforce the implementor of the AudioOutputDeviceSwitcher to provide 'GetOwnFrameId'. But this will add unnecessary burden to the implementor even when it isn't used for functionality, and it also hide readability that was initial feedback?

                    maybe I misunderstood your initial feedback ""native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read.".

                    If you're okay, we can remove "native_frame_id" and DeviceSwitcher yet all from this class and no GetOwnFrameId yet all.

                    Olga Sharonova

                    It must be some misunderstanding: I have not proposed to store it just for fun - the mapping was there. If the mapping between switcher and its frame id is not needed, feel free to remove it.

                    To be clear, what I'm proposing here is to change the API to:

                      virtual void AddSwitcher(AudioOutputDeviceSwitcher* device_switcher) = 0;
                    virtual void RemoveSwitcher(AudioOutputDeviceSwitcher* device_switcher) = 0;

                    in case you need to look up a native frame id for the switcher. If you don't - ignore it.

                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . unresolved

                    Since all public methods are virtual, could you split it into an interface and an implementation?

                    Sunggook Chue

                    Done

                    Sunggook Chue

                    Interface looks meaning there are multiple implementations for the feature (manager), but not for us. I don't see many media side code example that introduced the interface for the Mock test only even they Mock is common for test.

                    If you still think interface is good, I could support it though.

                    Olga Sharonova

                    The fact that you made it all virtual for testing means that you already have at least two implementations, doesn't it?
                    It's a common practice in chromium when an object is an external dependency and needs to be mocked. And it's cleaner than making all the methods virtual for testing and engaging in implementation inheritance.

                    Sunggook Chue

                    One of concern I had was that we have to force the Mock class to provide all virtual methods, which can bloat the test code where it Mock only single method now.

                    If we use single file for Mock, then it would be harder for selective Mock methods to have different implementation by test requirement.

                    so, even if we provide an interface, the test code will have to Mock the AudioOutputAuthorizationHandler directly. updated.

                    Olga Sharonova

                    Could you please place interface and Impl into the same header file (it's fine), and rename all the files back? Gerrit does not see similarities after this rename, so I can't see the diff (here: https://chromium-review.googlesource.com/c/chromium/src/+/5664173/33..36) and can't do an incremental review.

                    Could you clarify "If we use single file for Mock" part - what do you mean?
                    There can be a common mock for multiple test suits if convenient, but also tests suits can customize that mock and write their own.

                    Sunggook Chue

                    yes, I mentioned common mock, but looks didn't provide any value as each test customize the mock (no common mock is used). we avoid this common mock by mocking the directly the PreferredAudioOutputDeviceManagerImpl.

                    I update to merge the file to single one. thanks.

                    Olga Sharonova

                    " we avoid this common mock" - what's the benefit of it?

                    Mock class is very simple. Also the mocked methods you have now in the follow-up do not have any behavior defined, so you can just as well introduce a common mock.

                    Even if a specific method needs to be customized, you can override it for the test.

                    Please do not inherit from PreferredAudioOutputDeviceManagerImpl for mocking.
                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 151, Patchset 37 (Latest): if (config->preferred_sink_id() != raw_device_id) {
                    for (auto& device_switcher : config->device_switchers()) {
                    device_switcher.output_device_switcher->SwitchAudioOutputDeviceId(
                    raw_device_id);
                    }
                    Olga Sharonova . unresolved

                    This logic should be in set_preferred_sink_id() below

                    Line 305, Patchset 37 (Latest): preferred_sink_id_config->device_switchers().emplace_back(native_frame_id,
                    Olga Sharonova . unresolved

                    shouldn't the sink be switched for the switcher?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 37
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 01 Oct 2024 15:06:27 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 1, 2024, 11:45:58 PM10/1/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 6 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 181, Patchset 37: std::vector<DeviceSwitcher>& device_switchers() {
                    Olga Sharonova . resolved

                    Please remove it and introduce a proper API: add / update sink/ clear - whatever.

                    Sunggook Chue

                    replaced, thanks.

                    Line 156, Patchset 33: preferred_sink_id_ = sink_id;
                    Olga Sharonova . unresolved

                    Shouldn't the setter also update the switchers if necessary?

                    Sunggook Chue

                    switcher is updated by active_device_switchers() directly because device_swithcer could be added multiple times for single 'preferred sink id' ('single PreferredSinkIdToSwitcher will have single 'preferred sink id').

                    Sunggook Chue

                    Please reactivate it if my above explanation isn't sufficient. thanks.

                    Olga Sharonova

                    I've asked earlier on many occasions to not resolve the comments which are discussions. I will resolve them when I'm satisfied with the outcome of the discussion. Resolved comments, as I explain, get lost, and it's a waste of my time to recall a discussion and search for it.

                    I won't be reviewing at all the uploads which do not satisfy this request. Thank you for understanding.

                    ---

                    I don't understand this explanation, please see the other comments.

                    Sunggook Chue

                    Config has (1) preferred sink id (2) device switcher list for 'main frame id'.

                    The inserting of (1) and (2) comes from the different times (SetPreferredSinkId for (1), and AddSwitcher for (2).

                    So, there is no need to edit the (2) during SetPreferredSinkId API call.

                    Line 143, Patchset 33: raw_ptr<AudioOutputDeviceSwitcher> output_device_switcher;
                    Olga Sharonova . resolved

                    "native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read. OOC: Why do you want to track it externally?

                    Sunggook Chue

                    Initially it was private, but active_device_switchers() is public that returns the structure so move the structure to the public as 'native frame id' and 'device switcher' should be paired.

                    If we really keep it under private, then we can modify the active_device_switchers().

                    MainFramePreferredSinkIdConfig.AddSwitcher('main frame id', 'native frame id', 'device switcher object').

                    MainFramePreferredSinkIdConfig.GetDeviceSwitchers('main frame id'): The implementation has to create new vector of 'device switcher object' from the internal std::vector<DeviceSwitcher>.

                    The alternative seems more complex to understand the code. maybe other way to implement, any suggestion?

                    Olga Sharonova

                    What do you refer to as "it was private"?
                    What I mean is, if I remember correctly, the device switcher interface had the frame ID as a getter at some point. AudioOutputDeviceSwitcher can have GetOwnFrameId() (so DeviceSwitcher struct won't be needed) - and even GetMainFrameId() as well if we wish so.

                    Sunggook Chue

                    I'm confused, can you help me understand?

                    'native_frame_id' in the DeviceSwitcher isn't required in terms of functionality but it is introduced for better readability as your feedback.

                    We can get 'native_frame_id' if we enforce the implementor of the AudioOutputDeviceSwitcher to provide 'GetOwnFrameId'. But this will add unnecessary burden to the implementor even when it isn't used for functionality, and it also hide readability that was initial feedback?

                    maybe I misunderstood your initial feedback ""native_frame_id" info was a part of the switcher API at some point, and that was a bit more compact and easier to read.".

                    If you're okay, we can remove "native_frame_id" and DeviceSwitcher yet all from this class and no GetOwnFrameId yet all.

                    Olga Sharonova

                    It must be some misunderstanding: I have not proposed to store it just for fun - the mapping was there. If the mapping between switcher and its frame id is not needed, feel free to remove it.

                    To be clear, what I'm proposing here is to change the API to:

                      virtual void AddSwitcher(AudioOutputDeviceSwitcher* device_switcher) = 0;
                    virtual void RemoveSwitcher(AudioOutputDeviceSwitcher* device_switcher) = 0;

                    in case you need to look up a native frame id for the switcher. If you don't - ignore it.

                    Sunggook Chue

                    thanks for clarification, I will ignore it as we don't use it.

                    Line 49, Patchset 33:// The methods are virtual for testing purpose.
                    Olga Sharonova . resolved
                    Sunggook Chue

                    Done

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 151, Patchset 37: if (config->preferred_sink_id() != raw_device_id) {

                    for (auto& device_switcher : config->device_switchers()) {
                    device_switcher.output_device_switcher->SwitchAudioOutputDeviceId(
                    raw_device_id);
                    }
                    Olga Sharonova . resolved

                    This logic should be in set_preferred_sink_id() below

                    Sunggook Chue

                    set_preferred_sink_id(raw_device_id) updates the sink_id, then it will make config->preferred_sink_id() is always raw_device_id.

                    I will put the 'for loop' below the set_preferred_sink_id that might be clearer for the code.

                    Line 305, Patchset 37: preferred_sink_id_config->device_switchers().emplace_back(native_frame_id,
                    Olga Sharonova . unresolved

                    shouldn't the sink be switched for the switcher?

                    Sunggook Chue

                    can you clarify the question?

                    Config has (1) single preferred sink id and (2) multiple switchers. The above line just adding one of switcher when it was requested from the AddSwitcher.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 37
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 02 Oct 2024 03:45:48 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 2, 2024, 9:17:55 AM10/2/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 3 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 181, Patchset 37: std::vector<DeviceSwitcher>& device_switchers() {
                    Olga Sharonova . unresolved

                    Please remove it and introduce a proper API: add / update sink/ clear - whatever.

                    Sunggook Chue

                    replaced, thanks.

                    Olga Sharonova

                    Please change it so that Config manages switchers, rather than the external code. I.e. no GetDeviceSwitcherByIndex().

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 151, Patchset 37: if (config->preferred_sink_id() != raw_device_id) {
                    for (auto& device_switcher : config->device_switchers()) {
                    device_switcher.output_device_switcher->SwitchAudioOutputDeviceId(
                    raw_device_id);
                    }
                    Olga Sharonova . unresolved

                    This logic should be in set_preferred_sink_id() below

                    Sunggook Chue

                    set_preferred_sink_id(raw_device_id) updates the sink_id, then it will make config->preferred_sink_id() is always raw_device_id.

                    I will put the 'for loop' below the set_preferred_sink_id that might be clearer for the code.

                    Olga Sharonova

                    Sorry, I don't understand what is written here.

                    Config should be responsible for calling SwitchAudioOutputDeviceId() for its switchers. There should be no GetDeviceSwitcherByIndex() method.

                    Line 305, Patchset 37: preferred_sink_id_config->device_switchers().emplace_back(native_frame_id,
                    Olga Sharonova . unresolved

                    shouldn't the sink be switched for the switcher?

                    Sunggook Chue

                    can you clarify the question?

                    Config has (1) single preferred sink id and (2) multiple switchers. The above line just adding one of switcher when it was requested from the AddSwitcher.

                    Olga Sharonova

                    Switchers added to a config should all have the output device controlled by SwitchAudioOutputDeviceId(). You add a switcher but do not update its output device to sink_id.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 38
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Wed, 02 Oct 2024 13:17:46 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 2, 2024, 7:44:23 PM10/2/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 4 comments

                    Patchset-level comments
                    File-level comment, Patchset 38:
                    Sunggook Chue . resolved

                    Thanks!

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 181, Patchset 37: std::vector<DeviceSwitcher>& device_switchers() {
                    Olga Sharonova . resolved

                    Please remove it and introduce a proper API: add / update sink/ clear - whatever.

                    Sunggook Chue

                    replaced, thanks.

                    Olga Sharonova

                    Please change it so that Config manages switchers, rather than the external code. I.e. no GetDeviceSwitcherByIndex().

                    Sunggook Chue

                    got it, thanks. updated.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 151, Patchset 37: if (config->preferred_sink_id() != raw_device_id) {
                    for (auto& device_switcher : config->device_switchers()) {
                    device_switcher.output_device_switcher->SwitchAudioOutputDeviceId(
                    raw_device_id);
                    }
                    Olga Sharonova . resolved

                    This logic should be in set_preferred_sink_id() below

                    Sunggook Chue

                    set_preferred_sink_id(raw_device_id) updates the sink_id, then it will make config->preferred_sink_id() is always raw_device_id.

                    I will put the 'for loop' below the set_preferred_sink_id that might be clearer for the code.

                    Olga Sharonova

                    Sorry, I don't understand what is written here.

                    Config should be responsible for calling SwitchAudioOutputDeviceId() for its switchers. There should be no GetDeviceSwitcherByIndex() method.

                    Sunggook Chue

                    updated,

                    Line 305, Patchset 37: preferred_sink_id_config->device_switchers().emplace_back(native_frame_id,
                    Olga Sharonova . resolved

                    shouldn't the sink be switched for the switcher?

                    Sunggook Chue

                    can you clarify the question?

                    Config has (1) single preferred sink id and (2) multiple switchers. The above line just adding one of switcher when it was requested from the AddSwitcher.

                    Olga Sharonova

                    Switchers added to a config should all have the output device controlled by SwitchAudioOutputDeviceId(). You add a switcher but do not update its output device to sink_id.

                    Sunggook Chue

                    It calls SwitchAudioOutputDeviceId under the for loop for switchers, but as you suggested, move this to Config with new method of UpdateSinkIdForSwitchersIfNeeded().

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 38
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 02 Oct 2024 23:44:09 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
                    Comment-In-Reply-To: Olga Sharonova <ol...@google.com>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 3, 2024, 11:22:14 AM10/3/24
                    to Sunggook Chue, Guido Urdaneta, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 11 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 171, Patchset 39 (Latest): preferred_sink_id_switchers_;
                    Olga Sharonova . unresolved

                    Why is it still called like that? preferred_sink_id_configs_?

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 30, Patchset 39 (Latest):// The class to store the preferred sink id for the render frame host and its
                    // all sub frames. For this purpose, it stores audio device switchers
                    // as well as preferred sink id by the main render frame host id.
                    Olga Sharonova . unresolved

                    This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame.

                    ---
                    "it stores audio device switchers as well as preferred sink id by the main render frame host id." is written in c++ below, no need to add it to the comment.

                    Line 36, Patchset 39 (Latest): GlobalRenderFrameHostId main_frame_global_id);
                    Olga Sharonova . unresolved

                    make it take sink_id as a parameter

                    Line 44, Patchset 39 (Latest): void SetPreferredSinkId(const std::string& sink_id) {
                    Olga Sharonova . unresolved

                    I tried to explain several times: this method is pretty useless as stand-alone, please remove it.

                    The contract of the class is all added switchers are rendering to the current prefered sink. This partial methods break the contract.

                    Line 55, Patchset 39 (Latest): device_switchers_.push_back(device_switcher);
                    Olga Sharonova . unresolved

                    device_switcher->SwitchAudioOutputDeviceId(preferred_sink_id_);

                    Line 65, Patchset 39 (Latest): size_t GetDeviceSwitcherCount() const { return device_switchers_.size(); }
                    Olga Sharonova . unresolved

                    IsEmpty()

                    Line 67, Patchset 39 (Latest): void MaybeUpdateSinkIdForSwitchers(const std::string& new_device_id) {
                    Olga Sharonova . unresolved

                    It's enough to call it SetPreferredSinkId(). Updating switchers is a part of the contract.

                    Line 77, Patchset 39 (Latest): SetPreferredSinkId(new_device_id);
                    Olga Sharonova . unresolved

                    remove

                    Line 270, Patchset 39 (Latest): UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . unresolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Line 305, Patchset 37: preferred_sink_id_config->device_switchers().emplace_back(native_frame_id,
                    Olga Sharonova . unresolved

                    shouldn't the sink be switched for the switcher?

                    Sunggook Chue

                    can you clarify the question?

                    Config has (1) single preferred sink id and (2) multiple switchers. The above line just adding one of switcher when it was requested from the AddSwitcher.

                    Olga Sharonova

                    Switchers added to a config should all have the output device controlled by SwitchAudioOutputDeviceId(). You add a switcher but do not update its output device to sink_id.

                    Sunggook Chue

                    It calls SwitchAudioOutputDeviceId under the for loop for switchers, but as you suggested, move this to Config with new method of UpdateSinkIdForSwitchersIfNeeded().

                    Olga Sharonova

                    Which loop are we talking about here? You just added a switcher and the sink is not updated. Where is the update happening?

                    Line 355, Patchset 39 (Latest): config->SetPreferredSinkId(sink_id);
                    Olga Sharonova . unresolved

                    pass sink_id into constructor?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 39
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Comment-Date: Thu, 03 Oct 2024 15:22:04 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 4, 2024, 12:50:59 AM10/4/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 12 comments

                    Patchset-level comments
                    File-level comment, Patchset 39:
                    Sunggook Chue . resolved

                    thanks.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 171, Patchset 39: preferred_sink_id_switchers_;
                    Olga Sharonova . resolved

                    Why is it still called like that? preferred_sink_id_configs_?

                    Sunggook Chue

                    renamed preferred_sink_id_config_.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 30, Patchset 39:// The class to store the preferred sink id for the render frame host and its

                    // all sub frames. For this purpose, it stores audio device switchers
                    // as well as preferred sink id by the main render frame host id.
                    Olga Sharonova . resolved

                    This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame.

                    ---
                    "it stores audio device switchers as well as preferred sink id by the main render frame host id." is written in c++ below, no need to add it to the comment.

                    Sunggook Chue

                    removed the latter part.

                    Line 36, Patchset 39: GlobalRenderFrameHostId main_frame_global_id);
                    Olga Sharonova . resolved

                    make it take sink_id as a parameter

                    Sunggook Chue

                    Done

                    Line 44, Patchset 39: void SetPreferredSinkId(const std::string& sink_id) {
                    Olga Sharonova . resolved

                    I tried to explain several times: this method is pretty useless as stand-alone, please remove it.

                    The contract of the class is all added switchers are rendering to the current prefered sink. This partial methods break the contract.

                    Sunggook Chue

                    We have to update the sink_id at any time by the call of 'SetPreferredSinkId' from the JS side, but not we created MaybeUpdateSinkIdForSwitchers so we can remove it now. updated.

                    Line 55, Patchset 39: device_switchers_.push_back(device_switcher);
                    Olga Sharonova . unresolved

                    device_switcher->SwitchAudioOutputDeviceId(preferred_sink_id_);

                    Sunggook Chue

                    calling device_switcher->SwitchAudioOutputDeviceId(preferred_sink_id_) does not work because 'AddSwitcher' is called before stream is created from the AudioOutputStreamBroker::CreateStream. If needed, the caller (i.e. AudioOutputStreamBroker::CreateStream) can call SwitchAudioOutputDeviceId directly after comparing GetPreferredSinkId. btw, The previous API was a single call AddAndGet*, but splitting into two (GetPreferredSinkId/AddSwitcher) that provide cleaner interface for the client.

                    I updated the comment of 'AddSwitcher'.

                    Line 65, Patchset 39: size_t GetDeviceSwitcherCount() const { return device_switchers_.size(); }
                    Olga Sharonova . resolved

                    IsEmpty()

                    Sunggook Chue

                    Done

                    Line 67, Patchset 39: void MaybeUpdateSinkIdForSwitchers(const std::string& new_device_id) {
                    Olga Sharonova . resolved

                    It's enough to call it SetPreferredSinkId(). Updating switchers is a part of the contract.

                    Sunggook Chue

                    I removed SetPreferredSinkId() instead, and will change this method name to the MaybeSetPreferredSinkId since if the sink_id is same with the old one, there is no action.

                    Line 77, Patchset 39: SetPreferredSinkId(new_device_id);
                    Olga Sharonova . resolved

                    remove

                    Sunggook Chue

                    update it directly, remove SetPreferredSinkId

                    Line 270, Patchset 39: UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . resolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Sunggook Chue

                    You're right, we have to Unregister only when the config's sink id is 'default'. thanks.

                    Line 305, Patchset 37: preferred_sink_id_config->device_switchers().emplace_back(native_frame_id,
                    Olga Sharonova . unresolved

                    shouldn't the sink be switched for the switcher?

                    Sunggook Chue

                    can you clarify the question?

                    Config has (1) single preferred sink id and (2) multiple switchers. The above line just adding one of switcher when it was requested from the AddSwitcher.

                    Olga Sharonova

                    Switchers added to a config should all have the output device controlled by SwitchAudioOutputDeviceId(). You add a switcher but do not update its output device to sink_id.

                    Sunggook Chue

                    It calls SwitchAudioOutputDeviceId under the for loop for switchers, but as you suggested, move this to Config with new method of UpdateSinkIdForSwitchersIfNeeded().

                    Olga Sharonova

                    Which loop are we talking about here? You just added a switcher and the sink is not updated. Where is the update happening?

                    Sunggook Chue

                    I explained on the AddDeviceSwitcher comment, SwitchAudioOutputDeviceId shouldn't be called during AddSwitcher.

                    Line 355, Patchset 39: config->SetPreferredSinkId(sink_id);
                    Olga Sharonova . resolved

                    pass sink_id into constructor?

                    Sunggook Chue

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 39
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Fri, 04 Oct 2024 04:50:51 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 8, 2024, 10:49:51 AM10/8/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 6 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 171, Patchset 39: preferred_sink_id_switchers_;
                    Olga Sharonova . unresolved

                    Why is it still called like that? preferred_sink_id_configs_?

                    Sunggook Chue

                    renamed preferred_sink_id_config_.

                    Olga Sharonova

                    preferred_sink_id_configs_? (it's a vector)

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 30, Patchset 39:// The class to store the preferred sink id for the render frame host and its
                    // all sub frames. For this purpose, it stores audio device switchers
                    // as well as preferred sink id by the main render frame host id.
                    Olga Sharonova . unresolved

                    This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame.

                    ---
                    "it stores audio device switchers as well as preferred sink id by the main render frame host id." is written in c++ below, no need to add it to the comment.

                    Sunggook Chue

                    removed the latter part.

                    Olga Sharonova

                    Could you please fix the comment. What is store is not interesting, it's important what it is responsible for.

                    Line 55, Patchset 39: device_switchers_.push_back(device_switcher);
                    Olga Sharonova . unresolved

                    device_switcher->SwitchAudioOutputDeviceId(preferred_sink_id_);

                    Sunggook Chue

                    calling device_switcher->SwitchAudioOutputDeviceId(preferred_sink_id_) does not work because 'AddSwitcher' is called before stream is created from the AudioOutputStreamBroker::CreateStream. If needed, the caller (i.e. AudioOutputStreamBroker::CreateStream) can call SwitchAudioOutputDeviceId directly after comparing GetPreferredSinkId. btw, The previous API was a single call AddAndGet*, but splitting into two (GetPreferredSinkId/AddSwitcher) that provide cleaner interface for the client.

                    I updated the comment of 'AddSwitcher'.

                    Olga Sharonova

                    There is nothing in the switcher contract about that, so the switcher implementation needs to be fixed to fulfill its contract, rather than we adapt to implementation details of the interface.

                    Line 67, Patchset 39: void MaybeUpdateSinkIdForSwitchers(const std::string& new_device_id) {
                    Olga Sharonova . unresolved

                    It's enough to call it SetPreferredSinkId(). Updating switchers is a part of the contract.

                    Sunggook Chue

                    I removed SetPreferredSinkId() instead, and will change this method name to the MaybeSetPreferredSinkId since if the sink_id is same with the old one, there is no action.

                    Olga Sharonova

                    Please remove "Maybe", it's not normally used when the action is not performed due to a redundancy.

                    Line 77, Patchset 39: SetPreferredSinkId(new_device_id);
                    Olga Sharonova . unresolved

                    remove

                    Sunggook Chue

                    update it directly, remove SetPreferredSinkId

                    Olga Sharonova

                    Move it before "for"? Usually the value is set, and then the update is done.

                    Line 270, Patchset 39: UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . unresolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Sunggook Chue

                    You're right, we have to Unregister only when the config's sink id is 'default'. thanks.

                    Olga Sharonova

                    1) Which uint tests would cover this case?
                    2) I don't think we need to remove it at all. It will be removed when the main frame is gone, wouldn't it?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 40
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 08 Oct 2024 14:49:39 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 8, 2024, 10:54:49 AM10/8/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    Patchset-level comments
                    File-level comment, Patchset 40 (Latest):
                    Olga Sharonova . unresolved

                    See the other CL re: how to fix the switcher

                    Gerrit-Comment-Date: Tue, 08 Oct 2024 14:54:38 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 9, 2024, 12:36:23 AM10/9/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 8 comments

                    Patchset-level comments
                    File-level comment, Patchset 40:
                    Sunggook Chue . resolved

                    thanks

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 171, Patchset 39: preferred_sink_id_switchers_;
                    Olga Sharonova . resolved

                    Why is it still called like that? preferred_sink_id_configs_?

                    Sunggook Chue

                    renamed preferred_sink_id_config_.

                    Olga Sharonova

                    preferred_sink_id_configs_? (it's a vector)

                    Sunggook Chue

                    Done

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 30, Patchset 39:// The class to store the preferred sink id for the render frame host and its
                    // all sub frames. For this purpose, it stores audio device switchers
                    // as well as preferred sink id by the main render frame host id.
                    Olga Sharonova . resolved

                    This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame.

                    ---
                    "it stores audio device switchers as well as preferred sink id by the main render frame host id." is written in c++ below, no need to add it to the comment.

                    Sunggook Chue

                    removed the latter part.

                    Olga Sharonova

                    Could you please fix the comment. What is store is not interesting, it's important what it is responsible for.

                    Sunggook Chue

                    updated "The class to provide switchers and preferred sink id for the main frame if
                    the preferred sink id is set for the main frame.".

                    please suggest if you have any others in mind?

                    Line 55, Patchset 39: device_switchers_.push_back(device_switcher);
                    Olga Sharonova . resolved

                    device_switcher->SwitchAudioOutputDeviceId(preferred_sink_id_);

                    Sunggook Chue

                    calling device_switcher->SwitchAudioOutputDeviceId(preferred_sink_id_) does not work because 'AddSwitcher' is called before stream is created from the AudioOutputStreamBroker::CreateStream. If needed, the caller (i.e. AudioOutputStreamBroker::CreateStream) can call SwitchAudioOutputDeviceId directly after comparing GetPreferredSinkId. btw, The previous API was a single call AddAndGet*, but splitting into two (GetPreferredSinkId/AddSwitcher) that provide cleaner interface for the client.

                    I updated the comment of 'AddSwitcher'.

                    Olga Sharonova

                    There is nothing in the switcher contract about that, so the switcher implementation needs to be fixed to fulfill its contract, rather than we adapt to implementation details of the interface.

                    Sunggook Chue

                    ok, then, I will SwitchAudioOutputDeviceId and see how it looks like.

                    Line 67, Patchset 39: void MaybeUpdateSinkIdForSwitchers(const std::string& new_device_id) {
                    Olga Sharonova . resolved

                    It's enough to call it SetPreferredSinkId(). Updating switchers is a part of the contract.

                    Sunggook Chue

                    I removed SetPreferredSinkId() instead, and will change this method name to the MaybeSetPreferredSinkId since if the sink_id is same with the old one, there is no action.

                    Olga Sharonova

                    Please remove "Maybe", it's not normally used when the action is not performed due to a redundancy.

                    Sunggook Chue

                    Done

                    Line 77, Patchset 39: SetPreferredSinkId(new_device_id);
                    Olga Sharonova . resolved

                    remove

                    Sunggook Chue

                    update it directly, remove SetPreferredSinkId

                    Olga Sharonova

                    Move it before "for"? Usually the value is set, and then the update is done.

                    Sunggook Chue

                    Done

                    Line 270, Patchset 39: UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . resolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Sunggook Chue

                    You're right, we have to Unregister only when the config's sink id is 'default'. thanks.

                    Olga Sharonova

                    1) Which uint tests would cover this case?
                    2) I don't think we need to remove it at all. It will be removed when the main frame is gone, wouldn't it?

                    Sunggook Chue

                    ok,

                    Line 305, Patchset 37: preferred_sink_id_config->device_switchers().emplace_back(native_frame_id,
                    Olga Sharonova . resolved

                    shouldn't the sink be switched for the switcher?

                    Sunggook Chue

                    can you clarify the question?

                    Config has (1) single preferred sink id and (2) multiple switchers. The above line just adding one of switcher when it was requested from the AddSwitcher.

                    Olga Sharonova

                    Switchers added to a config should all have the output device controlled by SwitchAudioOutputDeviceId(). You add a switcher but do not update its output device to sink_id.

                    Sunggook Chue

                    It calls SwitchAudioOutputDeviceId under the for loop for switchers, but as you suggested, move this to Config with new method of UpdateSinkIdForSwitchersIfNeeded().

                    Olga Sharonova

                    Which loop are we talking about here? You just added a switcher and the sink is not updated. Where is the update happening?

                    Sunggook Chue

                    I explained on the AddDeviceSwitcher comment, SwitchAudioOutputDeviceId shouldn't be called during AddSwitcher.

                    Sunggook Chue

                    update AddSwitcher to call Switch* API.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 41
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 09 Oct 2024 04:36:14 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 9, 2024, 8:54:23 AM10/9/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 15 comments

                    Patchset-level comments
                    File-level comment, Patchset 41 (Latest):
                    Olga Sharonova . resolved

                    (Have not looked though authorization yet, publishing what I had time for)

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 102, Patchset 41 (Latest):// It can switch to UI thread for retrieving the main frame id for the given
                    // given native frame id in the call of SetPreferredSinkId(). Once it is
                    // retrieved, it will be cached.
                    Olga Sharonova . unresolved

                    Implementation details, remove from the header.

                    Line 95, Patchset 41 (Latest):// as singleton per the browser instance. While most APIs are
                    // called on the IO thread, certain APIs are called on the UI thread when called
                    // from the WebContentsObserver.
                    Olga Sharonova . unresolved

                    Remove: repetition

                    Line 91, Patchset 41 (Latest):// The class is responsible for managing the audio output device for top-level
                    // frame as well as all the sub pages if they use system default audio output.
                    Olga Sharonova . unresolved

                    This belongs to the interface description.

                    Line 87, Patchset 41 (Latest): virtual void DeleteRenderFrameHostid(
                    Olga Sharonova . unresolved

                    DeleteRenderFrameHostId

                    Line 81, Patchset 41 (Latest): virtual void AddRenderFrameHostid(GlobalRenderFrameHostId native_frame_id,
                    Olga Sharonova . unresolved

                    AddRenderFrameHostId

                    Line 75, Patchset 41 (Latest): virtual void UnregisterMainFrame(RenderFrameHost* render_frame_host) = 0;
                    Olga Sharonova . unresolved

                    Let's call it UnregisterMainFrameOnUIThread()?

                    Line 45, Patchset 41 (Latest): virtual void SetPreferredSinkId(GlobalRenderFrameHostId native_frame_id,
                    Olga Sharonova . unresolved

                    Could you remind me why it is called "native"?

                    Line 32, Patchset 41 (Latest):// output device for the page whether it is main or sub frames.
                    Olga Sharonova . unresolved

                    Could you give a better explanation re: main/sub frames?

                    Line 156, Patchset 33: preferred_sink_id_ = sink_id;
                    Olga Sharonova . resolved

                    Shouldn't the setter also update the switchers if necessary?

                    Sunggook Chue

                    switcher is updated by active_device_switchers() directly because device_swithcer could be added multiple times for single 'preferred sink id' ('single PreferredSinkIdToSwitcher will have single 'preferred sink id').

                    Sunggook Chue

                    Please reactivate it if my above explanation isn't sufficient. thanks.

                    Olga Sharonova

                    I've asked earlier on many occasions to not resolve the comments which are discussions. I will resolve them when I'm satisfied with the outcome of the discussion. Resolved comments, as I explain, get lost, and it's a waste of my time to recall a discussion and search for it.

                    I won't be reviewing at all the uploads which do not satisfy this request. Thank you for understanding.

                    ---

                    I don't understand this explanation, please see the other comments.

                    Sunggook Chue

                    Config has (1) preferred sink id (2) device switcher list for 'main frame id'.

                    The inserting of (1) and (2) comes from the different times (SetPreferredSinkId for (1), and AddSwitcher for (2).

                    So, there is no need to edit the (2) during SetPreferredSinkId API call.

                    Olga Sharonova

                    I guess this it no applicable any longer.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 30, Patchset 39:// The class to store the preferred sink id for the render frame host and its
                    // all sub frames. For this purpose, it stores audio device switchers
                    // as well as preferred sink id by the main render frame host id.
                    Olga Sharonova . unresolved

                    This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame.

                    ---
                    "it stores audio device switchers as well as preferred sink id by the main render frame host id." is written in c++ below, no need to add it to the comment.

                    Sunggook Chue

                    removed the latter part.

                    Olga Sharonova

                    Could you please fix the comment. What is store is not interesting, it's important what it is responsible for.

                    Sunggook Chue

                    updated "The class to provide switchers and preferred sink id for the main frame if
                    the preferred sink id is set for the main frame.".

                    please suggest if you have any others in mind?

                    Olga Sharonova

                    Okay, but "if" part is not true: switchers are always registered.

                    I proposed the wording in the very first comment:

                    "This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame."

                    Maybe correct it if something is wrong and use it?

                    Line 51, Patchset 41 (Latest): if (!media::AudioDeviceDescription::IsDefaultDevice(preferred_sink_id())) {
                    Olga Sharonova . unresolved

                    We don't need to check IsDefaultDevice(). Switchers knows how to deal with the default device. Also we don't check for it in other places.

                    Line 270, Patchset 39: UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . unresolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Sunggook Chue

                    You're right, we have to Unregister only when the config's sink id is 'default'. thanks.

                    Olga Sharonova

                    1) Which uint tests would cover this case?
                    2) I don't think we need to remove it at all. It will be removed when the main frame is gone, wouldn't it?

                    Sunggook Chue

                    ok,

                    Olga Sharonova

                    We need a unit test, sine we had a bug which was not discovered in tests.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager_unittest.cc
                    Line 1, Patchset 41 (Latest):// Copyright 2024 The Chromium Authors
                    Olga Sharonova . unresolved

                    It looks like we need more testing, especially regarding addition/removal of entities (see my other comment). Could you please identify various sequences of events to test and add the appropriate testing?

                    Line 232, Patchset 41 (Latest): EXPECT_CALL(*main_frame_switcher.get(),
                    Olga Sharonova . unresolved

                    Everywhere: Please set expectations before operations

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 41
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 09 Oct 2024 12:54:13 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 10, 2024, 1:53:15 AM10/10/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 15 comments

                    Patchset-level comments
                    File-level comment, Patchset 40:
                    Olga Sharonova . resolved

                    See the other CL re: how to fix the switcher

                    Sunggook Chue

                    updated, please reactivate if not resolved as you intended.

                    Sunggook Chue . resolved

                    thanks

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 102, Patchset 41 (Latest):// It can switch to UI thread for retrieving the main frame id for the given
                    // given native frame id in the call of SetPreferredSinkId(). Once it is
                    // retrieved, it will be cached.
                    Olga Sharonova . resolved

                    Implementation details, remove from the header.

                    Sunggook Chue

                    Done

                    Line 95, Patchset 41 (Latest):// as singleton per the browser instance. While most APIs are
                    // called on the IO thread, certain APIs are called on the UI thread when called
                    // from the WebContentsObserver.
                    Olga Sharonova . resolved

                    Remove: repetition

                    Sunggook Chue

                    Done

                    Line 91, Patchset 41 (Latest):// The class is responsible for managing the audio output device for top-level
                    // frame as well as all the sub pages if they use system default audio output.
                    Olga Sharonova . resolved

                    This belongs to the interface description.

                    Sunggook Chue

                    Done

                    Line 87, Patchset 41 (Latest): virtual void DeleteRenderFrameHostid(
                    Olga Sharonova . resolved

                    DeleteRenderFrameHostId

                    Sunggook Chue

                    Done

                    Line 81, Patchset 41 (Latest): virtual void AddRenderFrameHostid(GlobalRenderFrameHostId native_frame_id,
                    Olga Sharonova . resolved

                    AddRenderFrameHostId

                    Sunggook Chue

                    Done

                    Line 75, Patchset 41 (Latest): virtual void UnregisterMainFrame(RenderFrameHost* render_frame_host) = 0;
                    Olga Sharonova . resolved

                    Let's call it UnregisterMainFrameOnUIThread()?

                    Sunggook Chue

                    Done

                    Line 45, Patchset 41 (Latest): virtual void SetPreferredSinkId(GlobalRenderFrameHostId native_frame_id,
                    Olga Sharonova . unresolved

                    Could you remind me why it is called "native"?

                    Sunggook Chue

                    I believe it was initially commented by you and I agreed that as it clearly suggest it is the original frame id that was requested. We can rename it as 'requested_frame_id' or just 'frame_id'.

                    Line 32, Patchset 41 (Latest):// output device for the page whether it is main or sub frames.
                    Olga Sharonova . resolved

                    Could you give a better explanation re: main/sub frames?

                    Sunggook Chue

                    add more details, please suggest if not sufficient. thanks.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 30, Patchset 39:// The class to store the preferred sink id for the render frame host and its
                    // all sub frames. For this purpose, it stores audio device switchers
                    // as well as preferred sink id by the main render frame host id.
                    Olga Sharonova . resolved

                    This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame.

                    ---
                    "it stores audio device switchers as well as preferred sink id by the main render frame host id." is written in c++ below, no need to add it to the comment.

                    Sunggook Chue

                    removed the latter part.

                    Olga Sharonova

                    Could you please fix the comment. What is store is not interesting, it's important what it is responsible for.

                    Sunggook Chue

                    updated "The class to provide switchers and preferred sink id for the main frame if
                    the preferred sink id is set for the main frame.".

                    please suggest if you have any others in mind?

                    Olga Sharonova

                    Okay, but "if" part is not true: switchers are always registered.

                    I proposed the wording in the very first comment:

                    "This class controls preferred sink id for all switchers registered as belonging to a tree of a given main frame."

                    Maybe correct it if something is wrong and use it?

                    Sunggook Chue

                    thanks for suggestion, it would be much easier for me to suggest comment like this :).

                    Line 51, Patchset 41 (Latest): if (!media::AudioDeviceDescription::IsDefaultDevice(preferred_sink_id())) {
                    Olga Sharonova . resolved

                    We don't need to check IsDefaultDevice(). Switchers knows how to deal with the default device. Also we don't check for it in other places.

                    Sunggook Chue

                    Done

                    Line 270, Patchset 39: UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . unresolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Sunggook Chue

                    You're right, we have to Unregister only when the config's sink id is 'default'. thanks.

                    Olga Sharonova

                    1) Which uint tests would cover this case?
                    2) I don't think we need to remove it at all. It will be removed when the main frame is gone, wouldn't it?

                    Sunggook Chue

                    ok,

                    Olga Sharonova

                    We need a unit test, sine we had a bug which was not discovered in tests.

                    Sunggook Chue

                    CleanupWithDeletedSwitchers, RemoveSwitcherDoesNotCallSwitchDeviceOnActiveStream, RemoveSwitcherMainFrameDoesNotCallSwitchDeviceOnActiveStream will hit this API.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager_unittest.cc
                    Line 1, Patchset 41 (Latest):// Copyright 2024 The Chromium Authors
                    Olga Sharonova . unresolved

                    It looks like we need more testing, especially regarding addition/removal of entities (see my other comment). Could you please identify various sequences of events to test and add the appropriate testing?

                    Sunggook Chue

                    It already has few, but add more.

                    Line 232, Patchset 41 (Latest): EXPECT_CALL(*main_frame_switcher.get(),
                    Olga Sharonova . resolved

                    Everywhere: Please set expectations before operations

                    Sunggook Chue

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 41
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 10 Oct 2024 05:53:03 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 11, 2024, 5:09:43 AM10/11/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 2 comments

                    Patchset-level comments
                    Sunggook Chue . unresolved

                    thanks

                    Olga Sharonova

                    I think you forgot to upload the new PS?

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 45, Patchset 41 (Latest): virtual void SetPreferredSinkId(GlobalRenderFrameHostId native_frame_id,
                    Olga Sharonova . unresolved

                    Could you remind me why it is called "native"?

                    Sunggook Chue

                    I believe it was initially commented by you and I agreed that as it clearly suggest it is the original frame id that was requested. We can rename it as 'requested_frame_id' or just 'frame_id'.

                    Olga Sharonova

                    I don't recall suggesting the word "native" specifically. It's a bit confusing in the current context. Using frame_id and main_frame_id sounds good.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 41
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Fri, 11 Oct 2024 09:09:31 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 13, 2024, 1:56:54 AM10/13/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 3 comments

                    Patchset-level comments
                    File-level comment, Patchset 41:
                    Sunggook Chue . resolved

                    thanks

                    Olga Sharonova

                    I think you forgot to upload the new PS?

                    Sunggook Chue . resolved

                    thanks

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 45, Patchset 41: virtual void SetPreferredSinkId(GlobalRenderFrameHostId native_frame_id,
                    Olga Sharonova . resolved

                    Could you remind me why it is called "native"?

                    Sunggook Chue

                    I believe it was initially commented by you and I agreed that as it clearly suggest it is the original frame id that was requested. We can rename it as 'requested_frame_id' or just 'frame_id'.

                    Olga Sharonova

                    I don't recall suggesting the word "native" specifically. It's a bit confusing in the current context. Using frame_id and main_frame_id sounds good.

                    Sunggook Chue

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 42
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Sun, 13 Oct 2024 05:56:45 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 15, 2024, 11:03:19 AM10/15/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 22 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 95, Patchset 42 (Latest): // Removes the entry for the render frame host.
                    Olga Sharonova . unresolved

                    Unregisters a subframe

                    Line 88, Patchset 42 (Latest): // Adds the entry for the render frame host.
                    Olga Sharonova . unresolved

                    Registers a frame as a subframe of a given main frame.

                    What if frame_id and main_frame_is are the same?

                    Line 81, Patchset 42 (Latest): // Removes the entry for the render frame host.
                    Olga Sharonova . unresolved

                    Unregisters the main frame and all its subframes with their switchers

                    Line 73, Patchset 42 (Latest): // Gets the preferred device id for the render frame host if an entry exists.
                    Olga Sharonova . unresolved

                    if it is registered, or an empty stream otherwise

                    Line 73, Patchset 42 (Latest): // Gets the preferred device id for the render frame host if an entry exists.
                    Olga Sharonova . unresolved

                    Returns

                    Line 69, Patchset 42 (Latest): // device switchers list.
                    Olga Sharonova . unresolved

                    frame_id is

                    Line 59, Patchset 42 (Latest): // `frame_id` is the id of the render frame host where the audio
                    // playback is is requested. `device_switcher` is the device switcher to be
                    Olga Sharonova . unresolved

                    the switcher belongs to.
                    (there is nothing about audio playback in this API)

                    Line 58, Patchset 42 (Latest): // Adds the device switcher to the active device switchers list.
                    Olga Sharonova . unresolved

                    remove "active" everywhere

                    Line 50, Patchset 42 (Latest): // `frame_id` is the id of the render frame host. It is expected that
                    // it is main frame's id. If not, the API will return authorization error.
                    // `hashed_sink_id` is the id of the sink to be set as the preferred sink.
                    Olga Sharonova . unresolved

                    It does not seem implementation follows this. What is the actual intent?

                    Line 48, Patchset 42 (Latest): // any added device switcher will be notified with preferred sink id if
                    Olga Sharonova . unresolved

                    updated

                    Line 48, Patchset 42 (Latest): // any added device switcher will be notified with preferred sink id if
                    Olga Sharonova . unresolved

                    All switchers belonging to frames in this main frame tree

                    Line 47, Patchset 42 (Latest): // Sets the preferred sink id for the render frame host. At this moment,
                    Olga Sharonova . unresolved

                    the main frame and all its subframes.

                    Line 40, Patchset 42 (Latest):// This manager ensures that audio output can be adjusted for both
                    // types of frames, providing a seamless audio experience across the
                    // entire webpage.
                    Olga Sharonova . unresolved

                    What is the intent of this message?

                    Line 37, Patchset 42 (Latest):// contain separate documents or applications. These sub frames may
                    // require their own audio output settings, allowing for independent
                    // audio control within the context of the overall page.
                    Olga Sharonova . unresolved

                    What does this mean? What do you refer to?

                    Line 36, Patchset 42 (Latest):// Sub Frame: A secondary content area, such as an iframe, that can
                    // contain separate documents or applications. These sub frames may
                    Olga Sharonova . unresolved

                    Not needed

                    Line 35, Patchset 42 (Latest):// in the main frame affect the primary audio stream for the user.
                    Olga Sharonova . unresolved

                    There is no concept of "primary audio stream".

                    Line 33, Patchset 42 (Latest):// Main Frame: The primary content area of the webpage, typically where
                    // the main application or document resides. Changes to the audio output
                    Olga Sharonova . unresolved

                    not needed

                    Line 30, Patchset 42 (Latest):// This abstract class manages the preferred audio output device.
                    Olga Sharonova . unresolved

                    Please fix all the documentation for this class and use consistent terminology throughout all the comments. I added some recommendations below.

                    Class-level comment can be as simple as something like

                    This class keeps track of which frame tree each switcher belong to, and applies preferred output device changes to all switchers belonging to a tree of a given main frame.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 126, Patchset 42 (Latest): // of its permission state.
                    Olga Sharonova . unresolved

                    The header says it should fail if frame_id is not the main frame

                    Line 270, Patchset 39: UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . unresolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Sunggook Chue

                    You're right, we have to Unregister only when the config's sink id is 'default'. thanks.

                    Olga Sharonova

                    1) Which uint tests would cover this case?
                    2) I don't think we need to remove it at all. It will be removed when the main frame is gone, wouldn't it?

                    Sunggook Chue

                    ok,

                    Olga Sharonova

                    We need a unit test, sine we had a bug which was not discovered in tests.

                    Sunggook Chue

                    CleanupWithDeletedSwitchers, RemoveSwitcherDoesNotCallSwitchDeviceOnActiveStream, RemoveSwitcherMainFrameDoesNotCallSwitchDeviceOnActiveStream will hit this API.

                    Olga Sharonova

                    Which test does exactly what is described above? (Oct 03 coment)

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager_unittest.cc
                    Line 230, Patchset 42 (Latest):TEST_F(PreferredAudioOutputDeviceManagerImplTest, SwitchDeviceOnActiveStream) {
                    Olga Sharonova . unresolved

                    There is no concept of active streams in this area of the code. Could you chose another name? (I'm not sure what you want to say, so don't have a proposal)

                    Line 329, Patchset 42 (Latest): SetPrefferedSinkIdFromSubframeDoesSwitchDevice) {
                    Olga Sharonova . unresolved

                    Could you clarify: SetPreferredSinkId() documentation says that it can only be called for the main frame. What does the test name mean and what are we testing here?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 42
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Tue, 15 Oct 2024 15:03:09 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Comment-In-Reply-To: Olga Sharonova <ol...@chromium.org>
                    Comment-In-Reply-To: Sunggook Chue <sun...@microsoft.com>
                    Comment-In-Reply-To: Olga Sharonova <ol...@google.com>
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 15, 2024, 8:52:28 PM10/15/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 24 comments

                    Patchset-level comments
                    File-level comment, Patchset 42:
                    Sunggook Chue . resolved

                    thanks, please reactivate if resolution isn't appropriate. thanks.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 95, Patchset 42: // Removes the entry for the render frame host.
                    Olga Sharonova . resolved

                    Unregisters a subframe

                    Sunggook Chue

                    Done

                    Line 88, Patchset 42: // Adds the entry for the render frame host.
                    Olga Sharonova . resolved

                    Registers a frame as a subframe of a given main frame.

                    What if frame_id and main_frame_is are the same?

                    Sunggook Chue

                    If doesn't check whether it is same or not, just add them. updated comments.

                    Line 81, Patchset 42: // Removes the entry for the render frame host.
                    Olga Sharonova . resolved

                    Unregisters the main frame and all its subframes with their switchers

                    Sunggook Chue

                    Done

                    Line 73, Patchset 42: // Gets the preferred device id for the render frame host if an entry exists.
                    Olga Sharonova . resolved

                    Returns

                    Sunggook Chue

                    Done

                    Line 73, Patchset 42: // Gets the preferred device id for the render frame host if an entry exists.
                    Olga Sharonova . resolved

                    if it is registered, or an empty stream otherwise

                    Sunggook Chue

                    Done

                    Line 69, Patchset 42: // device switchers list.
                    Olga Sharonova . resolved

                    frame_id is

                    Sunggook Chue

                    Done

                    Line 59, Patchset 42: // `frame_id` is the id of the render frame host where the audio

                    // playback is is requested. `device_switcher` is the device switcher to be
                    Olga Sharonova . resolved

                    the switcher belongs to.
                    (there is nothing about audio playback in this API)

                    Sunggook Chue

                    Done

                    Line 58, Patchset 42: // Adds the device switcher to the active device switchers list.
                    Olga Sharonova . resolved

                    remove "active" everywhere

                    Sunggook Chue

                    Done

                    Line 50, Patchset 42: // `frame_id` is the id of the render frame host. It is expected that

                    // it is main frame's id. If not, the API will return authorization error.
                    // `hashed_sink_id` is the id of the sink to be set as the preferred sink.
                    Olga Sharonova . resolved

                    It does not seem implementation follows this. What is the actual intent?

                    Sunggook Chue

                    remove the line if it is confusing and doesn't add any value.

                    Line 48, Patchset 42: // any added device switcher will be notified with preferred sink id if
                    Olga Sharonova . resolved

                    updated

                    Sunggook Chue

                    Done

                    Line 48, Patchset 42: // any added device switcher will be notified with preferred sink id if
                    Olga Sharonova . resolved

                    All switchers belonging to frames in this main frame tree

                    Sunggook Chue

                    Done

                    Line 47, Patchset 42: // Sets the preferred sink id for the render frame host. At this moment,
                    Olga Sharonova . resolved

                    the main frame and all its subframes.

                    Sunggook Chue

                    Done

                    Line 40, Patchset 42:// This manager ensures that audio output can be adjusted for both

                    // types of frames, providing a seamless audio experience across the
                    // entire webpage.
                    Olga Sharonova . resolved

                    What is the intent of this message?

                    Sunggook Chue

                    Done

                    Line 37, Patchset 42:// contain separate documents or applications. These sub frames may

                    // require their own audio output settings, allowing for independent
                    // audio control within the context of the overall page.
                    Olga Sharonova . resolved

                    What does this mean? What do you refer to?

                    Sunggook Chue

                    Done

                    Line 36, Patchset 42:// Sub Frame: A secondary content area, such as an iframe, that can

                    // contain separate documents or applications. These sub frames may
                    Olga Sharonova . resolved

                    Not needed

                    Sunggook Chue

                    Done

                    Line 35, Patchset 42:// in the main frame affect the primary audio stream for the user.
                    Olga Sharonova . resolved

                    There is no concept of "primary audio stream".

                    Sunggook Chue

                    Done

                    Line 33, Patchset 42:// Main Frame: The primary content area of the webpage, typically where

                    // the main application or document resides. Changes to the audio output
                    Olga Sharonova . resolved

                    not needed

                    Sunggook Chue

                    Done

                    Line 30, Patchset 42:// This abstract class manages the preferred audio output device.
                    Olga Sharonova . resolved

                    Please fix all the documentation for this class and use consistent terminology throughout all the comments. I added some recommendations below.

                    Class-level comment can be as simple as something like

                    This class keeps track of which frame tree each switcher belong to, and applies preferred output device changes to all switchers belonging to a tree of a given main frame.

                    Sunggook Chue

                    Done

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 126, Patchset 42: // of its permission state.
                    Olga Sharonova . resolved

                    The header says it should fail if frame_id is not the main frame

                    Sunggook Chue

                    no in header (anymore). it will be allowed as long as AudioOutputAuthorizationHandler allows it.

                    Line 270, Patchset 39: UnregisterMainFrameOnIOThread(main_frame_id);
                    Olga Sharonova . resolved

                    Is it correct? What if SetPreferredSinkId is called, then a switcher is added, then it's removed, then a new one is added? The information about preferred sink is lost, new switcher's device id won't be updated.
                    (You also need a unit test for that case.)

                    Sunggook Chue

                    You're right, we have to Unregister only when the config's sink id is 'default'. thanks.

                    Olga Sharonova

                    1) Which uint tests would cover this case?
                    2) I don't think we need to remove it at all. It will be removed when the main frame is gone, wouldn't it?

                    Sunggook Chue

                    ok,

                    Olga Sharonova

                    We need a unit test, sine we had a bug which was not discovered in tests.

                    Sunggook Chue

                    CleanupWithDeletedSwitchers, RemoveSwitcherDoesNotCallSwitchDeviceOnActiveStream, RemoveSwitcherMainFrameDoesNotCallSwitchDeviceOnActiveStream will hit this API.

                    Olga Sharonova

                    Which test does exactly what is described above? (Oct 03 coment)

                    Sunggook Chue

                    Added new test that test the exact one: AddAterRemovalAfterSetId

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager_unittest.cc
                    Line 1, Patchset 41:// Copyright 2024 The Chromium Authors
                    Olga Sharonova . resolved

                    It looks like we need more testing, especially regarding addition/removal of entities (see my other comment). Could you please identify various sequences of events to test and add the appropriate testing?

                    Sunggook Chue

                    It already has few, but add more.

                    Sunggook Chue

                    Done

                    Line 230, Patchset 42:TEST_F(PreferredAudioOutputDeviceManagerImplTest, SwitchDeviceOnActiveStream) {
                    Olga Sharonova . resolved

                    There is no concept of active streams in this area of the code. Could you chose another name? (I'm not sure what you want to say, so don't have a proposal)

                    Sunggook Chue

                    I tried to mean, playing one. replace it with Playing.

                    Line 329, Patchset 42: SetPrefferedSinkIdFromSubframeDoesSwitchDevice) {
                    Olga Sharonova . unresolved

                    Could you clarify: SetPreferredSinkId() documentation says that it can only be called for the main frame. What does the test name mean and what are we testing here?

                    Sunggook Chue

                    I think I removed that one a while ago, it will follow the pattern of the setSinkId where AudioOutputAuthorizationHandler will validate it.

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 42
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 16 Oct 2024 00:52:18 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 16, 2024, 7:17:16 AM10/16/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 17 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 93, Patchset 43 (Latest): virtual void DeleteRenderFrameHostId(GlobalRenderFrameHostId frame_id) = 0;
                    Olga Sharonova . unresolved

                    What happens with switchers?

                    Line 82, Patchset 43 (Latest): // Registers a frame as a subframe of a given main frame.
                    Olga Sharonova . unresolved

                    See above: either we call it "frame" everywhere, or "render frame host". (and it's quite awkward to use "render frame host", so again, I propose "frame")

                    Line 76, Patchset 43 (Latest): // `render_frame_host` is the render frame host for which the entry is to be
                    Olga Sharonova . unresolved

                    Either we call it "frame" everywhere, or "render frame host". (I suggest "frame" because it shorter and clear anyways, but up to you)

                    Line 70, Patchset 43 (Latest): // `frame_id` is the id of the render frame host where the switcher belongs
                    // to.
                    virtual const std::string& GetPreferredSinkId(
                    Olga Sharonova . unresolved

                    There is nothing about switchers here.

                    Line 54, Patchset 43 (Latest): // added to the device. switchers list.
                    Olga Sharonova . unresolved

                    remove

                    Line 42, Patchset 43 (Latest): // will be updated with preferred sink id if its main frame id matches.
                    Olga Sharonova . unresolved

                    this is essentially "belonging to the frame tree", so can be dropped, because already stated earlier

                    Line 41, Patchset 43 (Latest): // At this moment, All switchers belonging to frames in this main frame tree
                    Olga Sharonova . unresolved

                    if frame_id does not have to be the main frame, then
                    "all switchers belonging to the same frame tree as the given frame"

                    Line 30, Patchset 43 (Latest):// This class keeps track of which frame tree each switcher belong to,
                    Olga Sharonova . unresolved

                    nit: belongs

                    Line 50, Patchset 42: // `frame_id` is the id of the render frame host. It is expected that
                    // it is main frame's id. If not, the API will return authorization error.
                    // `hashed_sink_id` is the id of the sink to be set as the preferred sink.
                    Olga Sharonova . unresolved

                    It does not seem implementation follows this. What is the actual intent?

                    Sunggook Chue

                    remove the line if it is confusing and doesn't add any value.

                    Olga Sharonova

                    This is a significant change of the contract. Could you explain the decision?

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 121, Patchset 43 (Latest): // HTMLMediaElement::setSinkId. AudioOutputAuthorizationHandler will validate
                    // against for it.
                    Olga Sharonova . unresolved

                    will validate it.

                    Line 127, Patchset 43 (Latest): AuthorizationCompleted(frame_id, hashed_sink_id, std::move(callback),
                    Olga Sharonova . unresolved

                    We have indeterministic behavior here: if SetPreferredSinkId() is called with a non-default device, it goes to the authorization handler and jumps through some thread, but if it's called with a default device, it's processed immediately. And then we potentially jump through UI thread to get the main frame.

                    So it's possible that
                    SetPreferredSinkId(non-default); SetPreferredSinkId(default)
                    will result in a sequence
                    OnGetMainFrameId(default), OnGetMainFrameId(non-default).

                    I.e. the order sink switches are applied is not the same they are called in.

                    One way to fix it is something like this:
                    introduce per main frame request id counter which is incremented every time SetPreferredSinkId() is called, and pass it all the way to OnGetMainFrameId(). Then in OnGetMainFrameId() if the request_number is lower than the current counter value, then we just don't do anything. I.e. we always apply only the latest preferred sink if there was a rapid sequence of SetPreferredSinkId() calls for a given main frame tree.

                    Line 186, Patchset 43 (Latest): // The main frame id is not cached yet.
                    Olga Sharonova . unresolved

                    Under what circumstances is it possible?

                    If it's possible, then why would we have two difference mechanisms to obtain mapping? If we keep this code, why would we not just drop Add/RemoveRenderFrameHostId?

                    Line 205, Patchset 43 (Latest):void PreferredAudioOutputDeviceManagerImpl::OnGetMainFrameId(
                    Olga Sharonova . unresolved

                    OnMainFrameIdReceived

                    Line 309, Patchset 43 (Latest):void PreferredAudioOutputDeviceManagerImpl::DeleteRenderFrameHostId(
                    Olga Sharonova . unresolved

                    Add/Remove (not Delete)

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager_unittest.cc
                    Line 230, Patchset 43 (Latest):TEST_F(PreferredAudioOutputDeviceManagerImplTest, SwitchDeviceOnPlaying) {
                    Olga Sharonova . unresolved

                    Do you mean during playing? And during playing what? The tests do not actively start playing anything. OnPlaying is still confusing (everywhere). Could you formulate it in concepts of the CL?

                    Line 329, Patchset 42: SetPrefferedSinkIdFromSubframeDoesSwitchDevice) {
                    Olga Sharonova . resolved

                    Could you clarify: SetPreferredSinkId() documentation says that it can only be called for the main frame. What does the test name mean and what are we testing here?

                    Sunggook Chue

                    I think I removed that one a while ago, it will follow the pattern of the setSinkId where AudioOutputAuthorizationHandler will validate it.

                    Olga Sharonova

                    Acknowledged

                    Line 652, Patchset 43 (Latest): // It adss switcher after removal that does not lose the registered
                    Olga Sharonova . unresolved

                    adds

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 43
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Wed, 16 Oct 2024 11:17:04 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 17, 2024, 1:06:10 AM10/17/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 17 comments

                    Sunggook Chue . resolved

                    thanks

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 93, Patchset 43: virtual void DeleteRenderFrameHostId(GlobalRenderFrameHostId frame_id) = 0;
                    Olga Sharonova . unresolved

                    What happens with switchers?

                    Sunggook Chue

                    can you clarify question? The caller removes frame_id from the cache when it won't be used anymore by any switchers.

                    Line 82, Patchset 43: // Registers a frame as a subframe of a given main frame.
                    Olga Sharonova . resolved

                    See above: either we call it "frame" everywhere, or "render frame host". (and it's quite awkward to use "render frame host", so again, I propose "frame")

                    Sunggook Chue

                    Done

                    Line 76, Patchset 43: // `render_frame_host` is the render frame host for which the entry is to be
                    Olga Sharonova . resolved

                    Either we call it "frame" everywhere, or "render frame host". (I suggest "frame" because it shorter and clear anyways, but up to you)

                    Sunggook Chue

                    ok, uses frame.

                    Line 70, Patchset 43: // `frame_id` is the id of the render frame host where the switcher belongs

                    // to.
                    virtual const std::string& GetPreferredSinkId(
                    Olga Sharonova . resolved

                    There is nothing about switchers here.

                    Sunggook Chue

                    Done

                    Line 54, Patchset 43: // added to the device. switchers list.
                    Olga Sharonova . resolved

                    remove

                    Sunggook Chue

                    Done

                    Line 42, Patchset 43: // will be updated with preferred sink id if its main frame id matches.
                    Olga Sharonova . resolved

                    this is essentially "belonging to the frame tree", so can be dropped, because already stated earlier

                    Sunggook Chue

                    Done

                    Line 41, Patchset 43: // At this moment, All switchers belonging to frames in this main frame tree
                    Olga Sharonova . resolved

                    if frame_id does not have to be the main frame, then
                    "all switchers belonging to the same frame tree as the given frame"

                    Sunggook Chue

                    Done

                    Line 30, Patchset 43:// This class keeps track of which frame tree each switcher belong to,
                    Olga Sharonova . resolved

                    nit: belongs

                    Sunggook Chue

                    Done

                    Line 50, Patchset 42: // `frame_id` is the id of the render frame host. It is expected that
                    // it is main frame's id. If not, the API will return authorization error.
                    // `hashed_sink_id` is the id of the sink to be set as the preferred sink.
                    Olga Sharonova . unresolved

                    It does not seem implementation follows this. What is the actual intent?

                    Sunggook Chue

                    remove the line if it is confusing and doesn't add any value.

                    Olga Sharonova

                    This is a significant change of the contract. Could you explain the decision?

                    Sunggook Chue

                    It was my initial proposal to support main frame only, but it was suggested internal review to follow existing setSinkId pattern as we thought JS developer are more familiar with that API. However, it is open to change based on the partners' feedback until we will enable the feature.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 121, Patchset 43: // HTMLMediaElement::setSinkId. AudioOutputAuthorizationHandler will validate
                    // against for it.
                    Olga Sharonova . resolved

                    will validate it.

                    Sunggook Chue

                    Done

                    Line 127, Patchset 43: AuthorizationCompleted(frame_id, hashed_sink_id, std::move(callback),
                    Olga Sharonova . resolved

                    We have indeterministic behavior here: if SetPreferredSinkId() is called with a non-default device, it goes to the authorization handler and jumps through some thread, but if it's called with a default device, it's processed immediately. And then we potentially jump through UI thread to get the main frame.

                    So it's possible that
                    SetPreferredSinkId(non-default); SetPreferredSinkId(default)
                    will result in a sequence
                    OnGetMainFrameId(default), OnGetMainFrameId(non-default).

                    I.e. the order sink switches are applied is not the same they are called in.

                    One way to fix it is something like this:
                    introduce per main frame request id counter which is incremented every time SetPreferredSinkId() is called, and pass it all the way to OnGetMainFrameId(). Then in OnGetMainFrameId() if the request_number is lower than the current counter value, then we just don't do anything. I.e. we always apply only the latest preferred sink if there was a rapid sequence of SetPreferredSinkId() calls for a given main frame tree.

                    Sunggook Chue

                    sounds good for your suggested algorithm.

                    Line 186, Patchset 43: // The main frame id is not cached yet.
                    Olga Sharonova . unresolved

                    Under what circumstances is it possible?

                    If it's possible, then why would we have two difference mechanisms to obtain mapping? If we keep this code, why would we not just drop Add/RemoveRenderFrameHostId?

                    Sunggook Chue

                    If SetPreferredSinkId called before any AddSwitcher, then it would hit this one.

                    We could drop it. However, if it hits cache, then we could avoid UI thread switching.

                    Please let me know what you think as initially it was your idea (register frameId/mainFrameId) to avoid UI thread switching as much as possible.

                    Line 205, Patchset 43:void PreferredAudioOutputDeviceManagerImpl::OnGetMainFrameId(
                    Olga Sharonova . resolved

                    OnMainFrameIdReceived

                    Sunggook Chue

                    Done

                    Line 309, Patchset 43:void PreferredAudioOutputDeviceManagerImpl::DeleteRenderFrameHostId(
                    Olga Sharonova . resolved

                    Add/Remove (not Delete)

                    Sunggook Chue

                    Done

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager_unittest.cc
                    Line 230, Patchset 43:TEST_F(PreferredAudioOutputDeviceManagerImplTest, SwitchDeviceOnPlaying) {
                    Olga Sharonova . unresolved

                    Do you mean during playing? And during playing what? The tests do not actively start playing anything. OnPlaying is still confusing (everywhere). Could you formulate it in concepts of the CL?

                    Sunggook Chue

                    I'm not sure which name is appropriate for this. Initially ActiveStream seems right wording as it is after CreateStream is called.

                    How about removing this word, it seems clearer.

                    Line 652, Patchset 43: // It adss switcher after removal that does not lose the registered
                    Olga Sharonova . resolved

                    adds

                    Sunggook Chue

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 44
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 17 Oct 2024 05:06:00 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 17, 2024, 4:42:31 AM10/17/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 5 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 176, Patchset 44 (Latest): // non-default and default are called back to back.
                    Olga Sharonova . unresolved

                    Not only that, there is also a jump via UI thread sometimes.

                    "To serialize SetSinkId calls when them jump through different threads." would be a sufficient comment.

                    Line 93, Patchset 43: virtual void DeleteRenderFrameHostId(GlobalRenderFrameHostId frame_id) = 0;
                    Olga Sharonova . unresolved

                    What happens with switchers?

                    Sunggook Chue

                    can you clarify question? The caller removes frame_id from the cache when it won't be used anymore by any switchers.

                    Olga Sharonova

                    So it's expected that if any switchers were added earlier, they are removed by now, right? If so - please add that to the comment, and make sure we have a corresponding CHECK in the implementation.

                    Line 50, Patchset 42: // `frame_id` is the id of the render frame host. It is expected that
                    // it is main frame's id. If not, the API will return authorization error.
                    // `hashed_sink_id` is the id of the sink to be set as the preferred sink.
                    Olga Sharonova . resolved

                    It does not seem implementation follows this. What is the actual intent?

                    Sunggook Chue

                    remove the line if it is confusing and doesn't add any value.

                    Olga Sharonova

                    This is a significant change of the contract. Could you explain the decision?

                    Sunggook Chue

                    It was my initial proposal to support main frame only, but it was suggested internal review to follow existing setSinkId pattern as we thought JS developer are more familiar with that API. However, it is open to change based on the partners' feedback until we will enable the feature.

                    Olga Sharonova

                    Ok, thanks for clarification.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 127, Patchset 43: AuthorizationCompleted(frame_id, hashed_sink_id, std::move(callback),
                    Olga Sharonova . unresolved

                    We have indeterministic behavior here: if SetPreferredSinkId() is called with a non-default device, it goes to the authorization handler and jumps through some thread, but if it's called with a default device, it's processed immediately. And then we potentially jump through UI thread to get the main frame.

                    So it's possible that
                    SetPreferredSinkId(non-default); SetPreferredSinkId(default)
                    will result in a sequence
                    OnGetMainFrameId(default), OnGetMainFrameId(non-default).

                    I.e. the order sink switches are applied is not the same they are called in.

                    One way to fix it is something like this:
                    introduce per main frame request id counter which is incremented every time SetPreferredSinkId() is called, and pass it all the way to OnGetMainFrameId(). Then in OnGetMainFrameId() if the request_number is lower than the current counter value, then we just don't do anything. I.e. we always apply only the latest preferred sink if there was a rapid sequence of SetPreferredSinkId() calls for a given main frame tree.

                    Sunggook Chue

                    sounds good for your suggested algorithm.

                    Olga Sharonova

                    The caveat is the counter needs to be per main frame - see my comment above. Otherwise we may be dropping requests from a different frame tree.

                    Hmmm.. So we'll have to reverse the order: first look up the main frame and update its request id, then do the authorization. Will this work?

                    We can make request_id a part of MainFramePreferredSinkIdConfig, add GetNextRequestId() and have SetPreferredSinkId(..., request_id) there which would do nothing if the request has expired. Does it make sense?

                    Line 186, Patchset 43: // The main frame id is not cached yet.
                    Olga Sharonova . unresolved

                    Under what circumstances is it possible?

                    If it's possible, then why would we have two difference mechanisms to obtain mapping? If we keep this code, why would we not just drop Add/RemoveRenderFrameHostId?

                    Sunggook Chue

                    If SetPreferredSinkId called before any AddSwitcher, then it would hit this one.

                    We could drop it. However, if it hits cache, then we could avoid UI thread switching.

                    Please let me know what you think as initially it was your idea (register frameId/mainFrameId) to avoid UI thread switching as much as possible.

                    Olga Sharonova

                    Again, the way caching is done was your proposal, mine was to cache it in the switcher :)
                    Ok, I see what you mean. But it's not if SetPreferredSinkId is called before any AddSwitcher, but rather if SetPreferredSinkId is called before the frame accessed RendererAudioOutputStreamFactory for the first time - that's when we call AddRenderFrameHostId - right?
                    If so - could you document it? Something like "SetSinkId() is called before AddRenderFrameHostId(), i.e. the frame called SetSinkId() before creating any audio outputs"

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 44
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Thu, 17 Oct 2024 08:42:18 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Sunggook Chue (Gerrit)

                    unread,
                    Oct 18, 2024, 12:32:29 AM10/18/24
                    to Guido Urdaneta, Olga Sharonova, AyeAye, Olga Sharonova, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Olga Sharonova

                    Sunggook Chue added 5 comments

                    Sunggook Chue . resolved

                    thanks

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.h
                    Line 176, Patchset 44: // non-default and default are called back to back.
                    Olga Sharonova . resolved

                    Not only that, there is also a jump via UI thread sometimes.

                    "To serialize SetSinkId calls when them jump through different threads." would be a sufficient comment.

                    Sunggook Chue

                    removed request_id_

                    Line 93, Patchset 43: virtual void DeleteRenderFrameHostId(GlobalRenderFrameHostId frame_id) = 0;
                    Olga Sharonova . resolved

                    What happens with switchers?

                    Sunggook Chue

                    can you clarify question? The caller removes frame_id from the cache when it won't be used anymore by any switchers.

                    Olga Sharonova

                    So it's expected that if any switchers were added earlier, they are removed by now, right? If so - please add that to the comment, and make sure we have a corresponding CHECK in the implementation.

                    Sunggook Chue
                    yes, we already have this.
                    DCHECK(render_frame_host_id_to_main_frame_id_.find(frame_id) !=
                    render_frame_host_id_to_main_frame_id_.end());

                    move to CHECK.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 127, Patchset 43: AuthorizationCompleted(frame_id, hashed_sink_id, std::move(callback),
                    Olga Sharonova . unresolved

                    We have indeterministic behavior here: if SetPreferredSinkId() is called with a non-default device, it goes to the authorization handler and jumps through some thread, but if it's called with a default device, it's processed immediately. And then we potentially jump through UI thread to get the main frame.

                    So it's possible that
                    SetPreferredSinkId(non-default); SetPreferredSinkId(default)
                    will result in a sequence
                    OnGetMainFrameId(default), OnGetMainFrameId(non-default).

                    I.e. the order sink switches are applied is not the same they are called in.

                    One way to fix it is something like this:
                    introduce per main frame request id counter which is incremented every time SetPreferredSinkId() is called, and pass it all the way to OnGetMainFrameId(). Then in OnGetMainFrameId() if the request_number is lower than the current counter value, then we just don't do anything. I.e. we always apply only the latest preferred sink if there was a rapid sequence of SetPreferredSinkId() calls for a given main frame tree.

                    Sunggook Chue

                    sounds good for your suggested algorithm.

                    Olga Sharonova

                    The caveat is the counter needs to be per main frame - see my comment above. Otherwise we may be dropping requests from a different frame tree.

                    Hmmm.. So we'll have to reverse the order: first look up the main frame and update its request id, then do the authorization. Will this work?

                    We can make request_id a part of MainFramePreferredSinkIdConfig, add GetNextRequestId() and have SetPreferredSinkId(..., request_id) there which would do nothing if the request has expired. Does it make sense?

                    Sunggook Chue

                    We don't create MainFramePreferredSinkIdConfig when it failed on the Authorization.

                    so, authorization check needs to made as early as possible.
                     
                    How about calling RequestDeviceAuthorization even with default device id, which seems much cleaner? (I will update the code with this scheme as the previous request_id_ doesn't work out).

                    Please let me know if you still prefer your suggestion?

                    (I think the chance of the initial concern might not occurs in real time, we might overengineer here :).

                    Line 186, Patchset 43: // The main frame id is not cached yet.
                    Olga Sharonova . resolved

                    Under what circumstances is it possible?

                    If it's possible, then why would we have two difference mechanisms to obtain mapping? If we keep this code, why would we not just drop Add/RemoveRenderFrameHostId?

                    Sunggook Chue

                    If SetPreferredSinkId called before any AddSwitcher, then it would hit this one.

                    We could drop it. However, if it hits cache, then we could avoid UI thread switching.

                    Please let me know what you think as initially it was your idea (register frameId/mainFrameId) to avoid UI thread switching as much as possible.

                    Olga Sharonova

                    Again, the way caching is done was your proposal, mine was to cache it in the switcher :)
                    Ok, I see what you mean. But it's not if SetPreferredSinkId is called before any AddSwitcher, but rather if SetPreferredSinkId is called before the frame accessed RendererAudioOutputStreamFactory for the first time - that's when we call AddRenderFrameHostId - right?
                    If so - could you document it? Something like "SetSinkId() is called before AddRenderFrameHostId(), i.e. the frame called SetSinkId() before creating any audio outputs"

                    Sunggook Chue

                    Done

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Olga Sharonova
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 45
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Fri, 18 Oct 2024 04:32:20 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 18, 2024, 8:03:36 AM10/18/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 2 comments

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Line 127, Patchset 43: AuthorizationCompleted(frame_id, hashed_sink_id, std::move(callback),
                    Olga Sharonova . unresolved

                    We have indeterministic behavior here: if SetPreferredSinkId() is called with a non-default device, it goes to the authorization handler and jumps through some thread, but if it's called with a default device, it's processed immediately. And then we potentially jump through UI thread to get the main frame.

                    So it's possible that
                    SetPreferredSinkId(non-default); SetPreferredSinkId(default)
                    will result in a sequence
                    OnGetMainFrameId(default), OnGetMainFrameId(non-default).

                    I.e. the order sink switches are applied is not the same they are called in.

                    One way to fix it is something like this:
                    introduce per main frame request id counter which is incremented every time SetPreferredSinkId() is called, and pass it all the way to OnGetMainFrameId(). Then in OnGetMainFrameId() if the request_number is lower than the current counter value, then we just don't do anything. I.e. we always apply only the latest preferred sink if there was a rapid sequence of SetPreferredSinkId() calls for a given main frame tree.

                    Sunggook Chue

                    sounds good for your suggested algorithm.

                    Olga Sharonova

                    The caveat is the counter needs to be per main frame - see my comment above. Otherwise we may be dropping requests from a different frame tree.

                    Hmmm.. So we'll have to reverse the order: first look up the main frame and update its request id, then do the authorization. Will this work?

                    We can make request_id a part of MainFramePreferredSinkIdConfig, add GetNextRequestId() and have SetPreferredSinkId(..., request_id) there which would do nothing if the request has expired. Does it make sense?

                    Sunggook Chue

                    We don't create MainFramePreferredSinkIdConfig when it failed on the Authorization.

                    so, authorization check needs to made as early as possible.
                     
                    How about calling RequestDeviceAuthorization even with default device id, which seems much cleaner? (I will update the code with this scheme as the previous request_id_ doesn't work out).

                    Please let me know if you still prefer your suggestion?

                    (I think the chance of the initial concern might not occurs in real time, we might overengineer here :).

                    Olga Sharonova

                    We don't create MainFramePreferredSinkIdConfig when it failed on the Authorization.

                    So we can delete it if authorization failed and there are no requests in progress, for example?

                    How about calling RequestDeviceAuthorization even with default device id, which seems much cleaner?

                    We should do it, yes, because all authorization decisions need to be done in one place, so please keep the change.

                    But I don't think it helps with our specific problem: AudioOutputAuthorizationHandler does not serialize its replies - take a look at its implementation.


                    I agree this may be a rare case. But I prefer to invest time now in making it robust, rather than a year later spend two weeks debugging some obscure edge case which all of a sudden is very popular.

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager_unittest.cc
                    Line 230, Patchset 43:TEST_F(PreferredAudioOutputDeviceManagerImplTest, SwitchDeviceOnPlaying) {
                    Olga Sharonova . unresolved

                    Do you mean during playing? And during playing what? The tests do not actively start playing anything. OnPlaying is still confusing (everywhere). Could you formulate it in concepts of the CL?

                    Sunggook Chue

                    I'm not sure which name is appropriate for this. Initially ActiveStream seems right wording as it is after CreateStream is called.

                    How about removing this word, it seems clearer.

                    Olga Sharonova

                    What condition did you want to describe with these words? Could you elaborate?

                    Open in Gerrit

                    Related details

                    Attention is currently required from:
                    • Guido Urdaneta
                    • Olga Sharonova
                    • Sunggook Chue
                    Submit Requirements:
                    • requirement satisfiedCode-Coverage
                    • requirement is not satisfiedCode-Review
                    • requirement is not satisfiedNo-Unresolved-Comments
                    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                    Gerrit-MessageType: comment
                    Gerrit-Project: chromium/src
                    Gerrit-Branch: main
                    Gerrit-Change-Id: Ib304fd723a5e1c7dc1cb5d30646ced502cd98026
                    Gerrit-Change-Number: 5664173
                    Gerrit-PatchSet: 45
                    Gerrit-Owner: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Reviewer: Gabriel Brito <gabrie...@microsoft.com>
                    Gerrit-Reviewer: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Reviewer: Olga Sharonova <ol...@chromium.org>
                    Gerrit-Reviewer: Steve Becker <ste...@microsoft.com>
                    Gerrit-CC: Olga Sharonova <ol...@google.com>
                    Gerrit-CC: Rijubrata Bhaumik <rijubrat...@intel.com>
                    Gerrit-Attention: Guido Urdaneta <gui...@chromium.org>
                    Gerrit-Attention: Sunggook Chue <sun...@microsoft.com>
                    Gerrit-Attention: Olga Sharonova <ol...@google.com>
                    Gerrit-Comment-Date: Fri, 18 Oct 2024 12:03:24 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy

                    Olga Sharonova (Gerrit)

                    unread,
                    Oct 18, 2024, 8:22:26 AM10/18/24
                    to Sunggook Chue, Guido Urdaneta, Olga Sharonova, AyeAye, Steve Becker, Gabriel Brito, Tricium, chromium...@chromium.org, Rijubrata Bhaumik, blundell+...@chromium.org, edgecapab...@microsoft.com, alexmo...@chromium.org, blink-re...@chromium.org, blink-...@chromium.org, chfreme...@chromium.org, creis...@chromium.org, feature-me...@chromium.org, ipc-securi...@chromium.org, jophba...@chromium.org, kinuko...@chromium.org, mfoltz...@chromium.org, navigation...@chromium.org, tommyw+w...@chromium.org
                    Attention needed from Guido Urdaneta, Olga Sharonova and Sunggook Chue

                    Olga Sharonova added 1 comment

                    File content/browser/renderer_host/media/preferred_audio_output_device_manager.cc
                    Olga Sharonova

                    BTW: if a follow-up device authorization has not succeeded we don't remove MainFramePreferredSinkIdConfig which has already been created.
                    And we do add MainFramePreferredSinkIdConfig entries for switchers without any authorization.
                    What invariant do you want to maintain around this? Maybe it just does not matter that we cache it before authorization?

                    Gerrit-Comment-Date: Fri, 18 Oct 2024 12:22:15 +0000
                    satisfied_requirement
                    unsatisfied_requirement
                    open
                    diffy
                    It is loading more messages.
                    0 new messages