Flag guard WebAudio OnRenderError handling
Bug: 331369797 Change-Id: I59125d2c87f3b5e4378bb179bd42616cae474c93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5427770 Reviewed-by: Hongchan Choi <hongchan@chromium.org> Commit-Queue: Michael Wilson <mjwilson@chromium.org> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org> Reviewed-by: Sina Firoozabadi <sinafirooz@chromium.org> Cr-Commit-Position: refs/heads/main@{#1284133}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
7d67c28376
commit
e05ae3b16f
content/renderer/media
third_party/blink
common
public
common
renderer
modules
platform
@ -22,6 +22,7 @@
|
||||
#include "base/task/thread_pool.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "media/audio/null_audio_sink.h"
|
||||
#include "media/base/audio_glitch_info.h"
|
||||
#include "media/base/audio_timestamp_helper.h"
|
||||
@ -30,8 +31,10 @@
|
||||
#include "media/base/output_device_info.h"
|
||||
#include "media/base/silent_sink_suspender.h"
|
||||
#include "media/base/speech_recognition_client.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "third_party/blink/public/platform/audio/web_audio_device_source_type.h"
|
||||
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
|
||||
#include "third_party/blink/public/platform/task_type.h"
|
||||
#include "third_party/blink/public/web/modules/media/audio/audio_device_factory.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
#include "third_party/blink/public/web/web_local_frame_client.h"
|
||||
@ -163,9 +166,14 @@ RendererWebAudioDeviceImpl::RendererWebAudioDeviceImpl(
|
||||
original_sink_params_.Reset(media::AudioParameters::AUDIO_FAKE,
|
||||
media::ChannelLayoutConfig::Stereo(), 48000,
|
||||
480);
|
||||
base::SequencedTaskRunner::GetCurrentDefault()->PostTask(
|
||||
FROM_HERE, base::BindOnce(&RendererWebAudioDeviceImpl::OnRenderError,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
if (base::FeatureList::IsEnabled(
|
||||
blink::features::kWebAudioHandleOnRenderError)) {
|
||||
RenderFrame::FromWebFrame(WebLocalFrame::FromFrameToken(frame_token_))
|
||||
->GetTaskRunner(blink::TaskType::kInternalMediaRealTime)
|
||||
->PostTask(FROM_HERE,
|
||||
base::BindOnce(&RendererWebAudioDeviceImpl::OnRenderError,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
}
|
||||
SendLogMessage(base::StringPrintf(
|
||||
"%s => (hardware_params=[%s])", __func__,
|
||||
|
5
third_party/blink/common/features.cc
vendored
5
third_party/blink/common/features.cc
vendored
@ -2467,6 +2467,11 @@ BASE_FEATURE(kWebAppManifestLockScreen,
|
||||
"WebAppManifestLockScreen",
|
||||
base::FEATURE_DISABLED_BY_DEFAULT);
|
||||
|
||||
// Allow OnRenderError callback to propagate in WebAudio
|
||||
BASE_FEATURE(kWebAudioHandleOnRenderError,
|
||||
"WebAudioHandleOnRenderError",
|
||||
base::FEATURE_DISABLED_BY_DEFAULT);
|
||||
|
||||
// A server-side switch for the output device (sink) selection in Web Audio API.
|
||||
// This enables the selection via the AudioContext constructor and also via
|
||||
// AudioContext.setSinkId() method.
|
||||
|
1
third_party/blink/public/common/features.h
vendored
1
third_party/blink/public/common/features.h
vendored
@ -1577,6 +1577,7 @@ BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAppBorderless);
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAppEnableScopeExtensions);
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAppEnableUrlHandlers);
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAppManifestLockScreen);
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAudioHandleOnRenderError);
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAudioSinkSelection);
|
||||
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kWebAudioBypassOutputBuffering);
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "services/metrics/public/cpp/ukm_builders.h"
|
||||
#include "services/metrics/public/cpp/ukm_recorder.h"
|
||||
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_devices.h"
|
||||
#include "third_party/blink/public/platform/modules/webrtc/webrtc_logging.h"
|
||||
#include "third_party/blink/public/platform/web_audio_latency_hint.h"
|
||||
@ -1192,13 +1193,15 @@ bool AudioContext::IsValidSinkDescriptor(
|
||||
}
|
||||
|
||||
void AudioContext::OnRenderError() {
|
||||
DCHECK(IsMainThread());
|
||||
LocalDOMWindow* window = To<LocalDOMWindow>(GetExecutionContext());
|
||||
if (window && window->GetFrame()) {
|
||||
window->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>(
|
||||
mojom::blink::ConsoleMessageSource::kOther,
|
||||
mojom::blink::ConsoleMessageLevel::kError,
|
||||
"The AudioContext encountered a render error."));
|
||||
if (base::FeatureList::IsEnabled(features::kWebAudioHandleOnRenderError)) {
|
||||
DCHECK(IsMainThread());
|
||||
LocalDOMWindow* window = To<LocalDOMWindow>(GetExecutionContext());
|
||||
if (window && window->GetFrame()) {
|
||||
window->AddConsoleMessage(MakeGarbageCollected<ConsoleMessage>(
|
||||
mojom::blink::ConsoleMessageSource::kOther,
|
||||
mojom::blink::ConsoleMessageLevel::kError,
|
||||
"The AudioContext encountered a render error."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,13 +256,16 @@ void RealtimeAudioDestinationHandler::Render(
|
||||
}
|
||||
|
||||
void RealtimeAudioDestinationHandler::OnRenderError() {
|
||||
if (task_runner_->BelongsToCurrentThread()) {
|
||||
RealtimeAudioDestinationHandler::NotifyAudioContext();
|
||||
} else {
|
||||
PostCrossThreadTask(
|
||||
*task_runner_, FROM_HERE,
|
||||
CrossThreadBindOnce(
|
||||
&RealtimeAudioDestinationHandler::NotifyAudioContext, AsWeakPtr()));
|
||||
if (base::FeatureList::IsEnabled(features::kWebAudioHandleOnRenderError)) {
|
||||
if (task_runner_->BelongsToCurrentThread()) {
|
||||
RealtimeAudioDestinationHandler::NotifyAudioContext();
|
||||
} else {
|
||||
PostCrossThreadTask(
|
||||
*task_runner_, FROM_HERE,
|
||||
CrossThreadBindOnce(
|
||||
&RealtimeAudioDestinationHandler::NotifyAudioContext,
|
||||
AsWeakPtr()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,9 @@ int AudioDestination::Render(base::TimeDelta delay,
|
||||
}
|
||||
|
||||
void AudioDestination::OnRenderError() {
|
||||
callback_->OnRenderError();
|
||||
if (base::FeatureList::IsEnabled(features::kWebAudioHandleOnRenderError)) {
|
||||
callback_->OnRenderError();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDestination::Start() {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "media/base/audio_glitch_info.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "third_party/blink/public/platform/web_audio_device.h"
|
||||
#include "third_party/blink/public/platform/web_audio_latency_hint.h"
|
||||
#include "third_party/blink/public/platform/web_audio_sink_descriptor.h"
|
||||
@ -159,7 +160,10 @@ TEST_P(AudioDestinationTest, ResamplingTest) {
|
||||
InSequence s;
|
||||
|
||||
EXPECT_CALL(platform->web_audio_device(), Start).Times(1);
|
||||
EXPECT_CALL(callback_, OnRenderError).Times(1);
|
||||
if (base::FeatureList::IsEnabled(
|
||||
blink::features::kWebAudioHandleOnRenderError)) {
|
||||
EXPECT_CALL(callback_, OnRenderError).Times(1);
|
||||
}
|
||||
EXPECT_CALL(platform->web_audio_device(), Stop).Times(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user