Skip to content

Conversation

@kjyoun
Copy link
Contributor

@kjyoun kjyoun commented Nov 3, 2025

This PR plumbs H5vcc settings from GlobalFeatures in the browser process to StarboardRenderer in the renderer process.

It introduces a new Mojo interface, cobalt::mojom::H5vccSettings, to allow the renderer to synchronously query all settings from the browser during initialization.

CobaltContentRendererClient now queries these settings during RenderThreadStarted and passes them to StarboardRenderer via RendererFactoryTraits and StarboardRendererConfig.

Bug: 455661813

@kjyoun
Copy link
Contributor Author

kjyoun commented Nov 3, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new mojo interface to pass settings from GlobalFeatures in the browser process down to SbPlayer. Specifically, it plumbs the use_external_allocator setting. The changes are quite extensive, touching build files, browser and renderer code, and various parts of the media stack. My review has identified a critical issue in the build configuration, a high-severity race condition in how the setting is fetched asynchronously, and a medium-severity issue regarding the robustness of parsing the setting's value.

@kjyoun
Copy link
Contributor Author

kjyoun commented Nov 3, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Mojo interface, CobaltSettings, to allow the renderer process to synchronously query settings from the browser process. This is used to plumb the use_external_allocator setting from GlobalFeatures all the way down to SbPlayer. The changes are mostly plumbing this new boolean flag through various layers. The overall approach is sound, and the implementation is clean. I have a couple of suggestions to improve robustness and maintainability.

@kjyoun kjyoun changed the title GlobalFeatures -> SbPlayer: through mojo media: Pass use_external_allocator from GlobalFeature to StarboardRenderer Nov 3, 2025
@kjyoun kjyoun changed the title media: Pass use_external_allocator from GlobalFeature to StarboardRenderer media: Pass use_external_allocator flag from GlobalFeature to StarboardRenderer Nov 3, 2025
@kjyoun kjyoun marked this pull request as ready for review November 3, 2025 17:29
@kjyoun kjyoun requested a review from a team as a code owner November 3, 2025 17:29
Copy link
Contributor

@at-ninja at-ninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDL changes & the "Media.DisableExternalAllocator" flag LGTM.

@kjyoun kjyoun requested a review from borongc November 3, 2025 21:48
int64 int_value;
};

interface CobaltSettings {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we consider to make this H5vccSettings? As most of setting-related naming, we use h5vcc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to H5vssSettings

@kjyoun kjyoun force-pushed the global-features-connect-mojo-2 branch from e20ae66 to 32fdbeb Compare November 4, 2025 19:10
@kjyoun kjyoun force-pushed the global-features-connect-mojo-2 branch from 32fdbeb to bcc50e7 Compare November 4, 2025 20:59
@kjyoun kjyoun changed the title media: Pass use_external_allocator flag from GlobalFeature to StarboardRenderer media: Pass H5vcc settings from GlobalFeatures to StarboardRenderer Nov 4, 2025
@kjyoun
Copy link
Contributor Author

kjyoun commented Nov 4, 2025

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively plumbs H5vcc settings from the browser process to the StarboardRenderer in the renderer process. The introduction of the cobalt::mojom::H5vccSettings Mojo interface for synchronously querying settings during initialization is a clean solution. The changes are well-structured and consistently applied throughout the codebase, from the browser to the renderer and down into the media stack. The IPC mechanisms and data structures are correctly implemented. I have one minor suggestion to improve the handling of std::variant for better code safety and readability. Overall, this is a high-quality contribution.

@kjyoun
Copy link
Contributor Author

kjyoun commented Nov 4, 2025

I updated PR to pass H5vcc settings map, instead of one boolean value.

Since we are planning to add several experiments on h5vcc setting, it would be more efficient to pass the map data once though mojo call.

Otherwise, we need to call mojor APIs for each experiment value.

@kjyoun kjyoun requested a review from borongc November 4, 2025 23:56
renderer_factory_traits->audio_write_duration_remote =
base::Microseconds(kSbPlayerWriteDurationRemote);

mojo::Remote<cobalt::mojom::H5vccSettings> cobalt_settings;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For L193 to L195, mojo::Remote can be bind when CobaltContentRendererClient::RenderFrameCreated(), so the mojo connection can stay as long as Renderer thread exists.

Then, when Cobalt creates WebMediaPlayer, Cobalt can get the setting every time (L197--L207).

#include "mojo/public/cpp/bindings/pending_remote.h"

#if BUILDFLAG(USE_STARBOARD_MEDIA)
#include "media/base/starboard/starboard_renderer_config.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why MojoRendererFactory need to include this?

#ifndef MEDIA_MOJO_SERVICES_GPU_MOJO_MEDIA_CLIENT_H_
#define MEDIA_MOJO_SERVICES_GPU_MOJO_MEDIA_CLIENT_H_

#include <map>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including map and string is not gated by USE_STARBOARD_MEDIA. Consider to put them to media/base/starboard/starboard_renderer_config.h so we don't need to add them here.

mojo::PendingRemote<stable::mojom::StableVideoDecoder> oop_video_decoder,
base::OnceCallback<void(
mojo::PendingRemote<stable::mojom::StableVideoDecoder>)> cb) final;
base::OnceCallback<
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this caused by formating?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants