Skip to content

Commit

Permalink
media: Add kHardwareSecureDecryptionFallback feature
Browse files Browse the repository at this point in the history
This CL adds a new feature media::kHardwareSecureDecryptionFallback to
control hardware secure decryption fallback logic. It's also added to
about://flags so it's easier for users and testers to disable the
fallback, e.g. for testing purposes.

Manually tested with this feature disabled and fallback never happens
even after multiple failures.

Bug: 1296219
Test: See above
Change-Id: If0c70812b54d0c88a1850276efb6e8b7de60b9a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3550418
Reviewed-by: John Rummell <jrummell@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#985653}
  • Loading branch information
xhwang-chromium authored and Chromium LUCI CQ committed Mar 26, 2022
1 parent 75f46b2 commit 9040929
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 1 deletion.
7 changes: 7 additions & 0 deletions chrome/browser/about_flags.cc
Expand Up @@ -3508,6 +3508,13 @@ const FeatureEntry kFeatureEntries[] = {
kOsWin,
FEATURE_VALUE_TYPE(media::kHardwareSecureDecryptionExperiment),
},
{
"enable-hardware-secure-decryption-fallback",
flag_descriptions::kHardwareSecureDecryptionFallbackName,
flag_descriptions::kHardwareSecureDecryptionFallbackDescription,
kOsWin,
FEATURE_VALUE_TYPE(media::kHardwareSecureDecryptionFallback),
},
{
"enable-media-foundation-clear",
flag_descriptions::kMediaFoundationClearName,
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/flag-metadata.json
Expand Up @@ -2195,6 +2195,13 @@
],
"expiry_milestone": 105
},
{
"name": "enable-hardware-secure-decryption-fallback",
"owners": [
"xhwang", "media-dev"
],
"expiry_milestone": 105
},
{
"name": "enable-heavy-ad-intervention",
"owners": [ "johnidel", "jkarlin" ],
Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/flag_descriptions.cc
Expand Up @@ -3905,6 +3905,14 @@ const char kHardwareSecureDecryptionExperimentDescription[] =
"Enable/Disable the use of hardware secure Content Decryption Module (CDM) "
"for experimental protected content playback.";

const char kHardwareSecureDecryptionFallbackName[] =
"Hardware Secure Decryption Fallback";
const char kHardwareSecureDecryptionFallbackDescription[] =
"Allows automatically disabling hardware secure Content Decryption Module "
"(CDM) after failures or crashes. Subsequent playback may use software "
"secure CDMs. If this feature is disabled, the fallback will never happen "
"and users could be stuck with playback failures.";

const char kMediaFoundationClearName[] = "MediaFoundation for Clear";
const char kMediaFoundationClearDescription[] =
"Enable/Disable the use of MediaFoundation for non-protected content "
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/flag_descriptions.h
Expand Up @@ -2237,6 +2237,9 @@ extern const char kHardwareSecureDecryptionDescription[];
extern const char kHardwareSecureDecryptionExperimentName[];
extern const char kHardwareSecureDecryptionExperimentDescription[];

extern const char kHardwareSecureDecryptionFallbackName[];
extern const char kHardwareSecureDecryptionFallbackDescription[];

extern const char kMediaFoundationClearName[];
extern const char kMediaFoundationClearDescription[];

Expand Down
5 changes: 4 additions & 1 deletion chrome/browser/media/media_foundation_service_monitor.cc
Expand Up @@ -4,10 +4,12 @@

#include "chrome/browser/media/media_foundation_service_monitor.h"

#include "base/feature_list.h"
#include "base/logging.h"
#include "base/power_monitor/power_monitor.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cdm_registry.h"
#include "media/base/media_switches.h"
#include "media/mojo/mojom/media_foundation_service.mojom.h"
#include "ui/display/screen.h"

Expand Down Expand Up @@ -111,7 +113,8 @@ void MediaFoundationServiceMonitor::OnPowerOrDisplayChange() {
void MediaFoundationServiceMonitor::AddSample(int failure_score) {
samples_.AddSample(failure_score);

if (samples_.GetUnroundedAverage() >= kMaxAverageFailureScore) {
if (samples_.GetUnroundedAverage() >= kMaxAverageFailureScore &&
base::FeatureList::IsEnabled(media::kHardwareSecureDecryptionFallback)) {
content::CdmRegistry::GetInstance()->DisableHardwareSecureCdms();
}
}
7 changes: 7 additions & 0 deletions media/base/media_switches.cc
Expand Up @@ -613,6 +613,13 @@ const base::Feature kHardwareSecureDecryption{
const base::Feature kHardwareSecureDecryptionExperiment{
"HardwareSecureDecryptionExperiment", base::FEATURE_DISABLED_BY_DEFAULT};

// Allows automatically disabling hardware secure Content Decryption Module
// (CDM) after failures or crashes to fallback to software secure CDMs. If this
// feature is disabled, the fallback will never happen and users could be stuck
// in playback failures.
const base::Feature kHardwareSecureDecryptionFallback{
"HardwareSecureDecryptionFallback", base::FEATURE_ENABLED_BY_DEFAULT};

const base::Feature kWakeLockOptimisationHiddenMuted{
"kWakeLockOptimisationHiddenMuted", base::FEATURE_ENABLED_BY_DEFAULT};

Expand Down
1 change: 1 addition & 0 deletions media/base/media_switches.h
Expand Up @@ -143,6 +143,7 @@ MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsModernUI;
MEDIA_EXPORT extern const base::Feature kHardwareMediaKeyHandling;
MEDIA_EXPORT extern const base::Feature kHardwareSecureDecryption;
MEDIA_EXPORT extern const base::Feature kHardwareSecureDecryptionExperiment;
MEDIA_EXPORT extern const base::Feature kHardwareSecureDecryptionFallback;
MEDIA_EXPORT extern const base::Feature kInternalMediaSession;
MEDIA_EXPORT extern const base::Feature kKeepRvfcFrameAlive;
MEDIA_EXPORT extern const base::Feature kKeyPressMonitoring;
Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/enums.xml
Expand Up @@ -53200,6 +53200,7 @@ from previous Chrome versions.
<int value="-1150881704"
label="ArcNativeBridge64BitSupportExperiment:enabled"/>
<int value="-1146814438" label="TabbedAppOverflowMenuIcons:enabled"/>
<int value="-1146310028" label="HardwareSecureDecryptionFallback:enabled"/>
<int value="-1145905507" label="SendTabToSelfWhenSignedIn:disabled"/>
<int value="-1145702446" label="ChromeHomeInactivitySheetExpansion:enabled"/>
<int value="-1145246849" label="ThirdPartyDoodles:enabled"/>
Expand Down Expand Up @@ -54642,6 +54643,7 @@ from previous Chrome versions.
<int value="-131673218" label="FileHandlingAPI:disabled"/>
<int value="-131257916" label="OmniboxCompactSuggestions:disabled"/>
<int value="-130318058" label="ExoGamepadVibration:enabled"/>
<int value="-129823932" label="HardwareSecureDecryptionFallback:disabled"/>
<int value="-128687277"
label="OmniboxUIExperimentHideSteadyStateUrlPathQueryAndRef:disabled"/>
<int value="-127666141" label="TabGroups:disabled"/>
Expand Down

0 comments on commit 9040929

Please sign in to comment.