Backed out 3 changesets (bug 1873394) for causing bug 1879250. CLOSED TREE

Backed out changeset b355f33d28c9 (bug 1873394)
Backed out changeset 6711b73d58e1 (bug 1873394)
Backed out changeset 44fdf4e83c7c (bug 1873394)
This commit is contained in:
pstanciu
2024-02-08 11:53:13 +02:00
parent c76c890a9b
commit dbc4a6f9dd
16 changed files with 19 additions and 358 deletions

View File

@@ -6995,11 +6995,6 @@ void HTMLMediaElement::MakeAssociationWithCDMResolved() {
// 5.4 Set the mediaKeys attribute to mediaKeys.
mMediaKeys = mIncomingMediaKeys;
#ifdef MOZ_WMF_CDM
if (mMediaKeys && mMediaKeys->GetCDMProxy()) {
mIsUsingWMFCDM = !!mMediaKeys->GetCDMProxy()->AsWMFCDMProxy();
}
#endif
// 5.5 Let this object's attaching media keys value be false.
ResetSetMediaKeysTempVariables();
// 5.6 Resolve promise.
@@ -7871,10 +7866,6 @@ void HTMLMediaElement::NodeInfoChanged(Document* aOldDoc) {
nsGenericHTMLElement::NodeInfoChanged(aOldDoc);
}
#ifdef MOZ_WMF_CDM
bool HTMLMediaElement::IsUsingWMFCDM() const { return mIsUsingWMFCDM; };
#endif
} // namespace mozilla::dom
#undef LOG

View File

@@ -554,10 +554,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
bool IsEncrypted() const override { return mIsEncrypted; }
#ifdef MOZ_WMF_CDM
bool IsUsingWMFCDM() const override;
#endif
bool Paused() const { return mPaused; }
double DefaultPlaybackRate() const {
@@ -1926,11 +1922,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
// Return true if we should queue a 'timeupdate' event runner to main thread.
bool ShouldQueueTimeupdateAsyncTask(TimeupdateType aType) const;
#ifdef MOZ_WMF_CDM
// It's used to record telemetry probe for WMFCDM playback.
bool mIsUsingWMFCDM = false;
#endif
};
// Check if the context is chrome or has the debugger or tabs permission

View File

@@ -15,9 +15,7 @@
#include "mozilla/ProfilerLabels.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/glean/GleanMetrics.h"
#include "nsThreadUtils.h"
#include "VideoUtils.h"
namespace mozilla {
@@ -250,7 +248,6 @@ void ExternalEngineStateMachine::OnEngineInitFailure() {
state->mEngineInitRequest.Complete();
state->mInitPromise = nullptr;
// TODO : Should fallback to the normal playback with media engine.
ReportTelemetry(NS_ERROR_DOM_MEDIA_FATAL_ERR);
DecodeError(MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__));
}
@@ -279,16 +276,14 @@ void ExternalEngineStateMachine::OnMetadataRead(MetadataHolder&& aMetadata) {
if (!IsFormatSupportedByExternalEngine(*mInfo)) {
// The external engine doesn't support the type, try to notify the decoder
// to use our own state machine again. Not a real "error", because it would
// fallback to another state machine.
// to use our own state machine again.
DecodeError(
MediaResult(NS_ERROR_DOM_MEDIA_EXTERNAL_ENGINE_NOT_SUPPORTED_ERR));
return;
}
#ifdef MOZ_WMF_MEDIA_ENGINE
// Only support encrypted playback. Not a real "error", because it would
// fallback to another state machine.
// Only support encrypted playback.
if (!mInfo->IsEncrypted() &&
StaticPrefs::media_wmf_media_engine_enabled() == 2) {
LOG("External engine only supports encrypted playback by the pref");
@@ -336,7 +331,6 @@ void ExternalEngineStateMachine::OnMetadataNotRead(const MediaResult& aError) {
MOZ_ASSERT(mState.IsReadingMetadata());
LOGE("Decode metadata failed, shutting down decoder");
mState.AsReadingMetadata()->mMetadataRequest.Complete();
ReportTelemetry(aError);
DecodeError(aError);
}
@@ -472,7 +466,6 @@ void ExternalEngineStateMachine::OnSeekRejected(
MOZ_ASSERT(NS_FAILED(aReject.mError),
"Cancels should also disconnect mSeekRequest");
state->RejectIfExists(__func__);
ReportTelemetry(aReject.mError);
DecodeError(aReject.mError);
}
@@ -845,7 +838,6 @@ void ExternalEngineStateMachine::OnRequestAudio() {
// so here just silently ignore this.
break;
default:
ReportTelemetry(aError);
DecodeError(aError);
}
})
@@ -922,7 +914,6 @@ void ExternalEngineStateMachine::OnRequestVideo() {
// so here just silently ignore this.
break;
default:
ReportTelemetry(aError);
DecodeError(aError);
}
})
@@ -1109,14 +1100,11 @@ void ExternalEngineStateMachine::NotifyErrorInternal(
if (aError == NS_ERROR_DOM_MEDIA_NOT_SUPPORTED_ERR) {
// The external engine doesn't support the type, try to notify the decoder
// to use our own state machine again.
ReportTelemetry(NS_ERROR_DOM_MEDIA_EXTERNAL_ENGINE_NOT_SUPPORTED_ERR);
DecodeError(
MediaResult(NS_ERROR_DOM_MEDIA_EXTERNAL_ENGINE_NOT_SUPPORTED_ERR));
} else if (aError == NS_ERROR_DOM_MEDIA_REMOTE_DECODER_CRASHED_MF_CDM_ERR) {
ReportTelemetry(NS_ERROR_DOM_MEDIA_REMOTE_DECODER_CRASHED_MF_CDM_ERR);
RecoverFromCDMProcessCrashIfNeeded();
} else {
ReportTelemetry(aError);
DecodeError(aError);
}
}
@@ -1202,8 +1190,7 @@ RefPtr<SetCDMPromise> ExternalEngineStateMachine::SetCDMProxy(
}
// TODO : set CDM proxy again if we recreate the media engine after crash.
mKeySystem = NS_ConvertUTF16toUTF8(aProxy->KeySystem());
LOG("SetCDMProxy=%p (key-system=%s)", aProxy, mKeySystem.get());
LOG("SetCDMProxy=%p", aProxy);
MOZ_DIAGNOSTIC_ASSERT(mEngine);
if (!mEngine->SetCDMProxy(aProxy)) {
LOG("Failed to set CDM proxy on the engine");
@@ -1229,45 +1216,6 @@ bool ExternalEngineStateMachine::IsCDMProxySupported(CDMProxy* aProxy) {
#endif
}
void ExternalEngineStateMachine::ReportTelemetry(const MediaResult& aError) {
glean::mfcdm::ErrorExtra extraData;
extraData.errorName = Some(aError.ErrorName());
nsAutoCString resolution;
if (mInfo) {
if (mInfo->HasAudio()) {
extraData.audioCodec = Some(mInfo->mAudio.mMimeType);
}
if (mInfo->HasVideo()) {
extraData.videoCodec = Some(mInfo->mVideo.mMimeType);
DetermineResolutionForTelemetry(*mInfo, resolution);
extraData.resolution = Some(resolution);
}
}
if (!mKeySystem.IsEmpty()) {
extraData.keySystem = Some(mKeySystem);
}
glean::mfcdm::error.Record(Some(extraData));
if (MOZ_LOG_TEST(gMediaDecoderLog, LogLevel::Debug)) {
nsPrintfCString logMessage{"MFCDM Error event, error=%s",
aError.ErrorName().get()};
if (mInfo) {
if (mInfo->HasAudio()) {
logMessage.Append(
nsPrintfCString{", audio=%s", mInfo->mAudio.mMimeType.get()});
}
if (mInfo->HasVideo()) {
logMessage.Append(nsPrintfCString{", video=%s, resolution=%s",
mInfo->mVideo.mMimeType.get(),
resolution.get()});
}
}
if (!mKeySystem.IsEmpty()) {
logMessage.Append(nsPrintfCString{", keySystem=%s", mKeySystem.get()});
}
LOG("%s", logMessage.get());
}
}
#undef FMT
#undef LOG
#undef LOGV

View File

@@ -291,8 +291,6 @@ class ExternalEngineStateMachine final
void RecoverFromCDMProcessCrashIfNeeded();
void ReportTelemetry(const MediaResult& aError);
UniquePtr<ExternalPlaybackEngine> mEngine;
bool mHasEnoughAudio = false;
@@ -306,9 +304,6 @@ class ExternalEngineStateMachine final
// It would be zero for audio-only playback.
gfx::IntSize mVideoDisplay;
// It would be set if playback is encrypted.
nsCString mKeySystem;
};
class ExternalPlaybackEngine {

View File

@@ -27,7 +27,6 @@
#include "mozilla/StaticPtr.h"
#include "mozilla/Telemetry.h"
#include "mozilla/Unused.h"
#include "mozilla/glean/GleanMetrics.h"
#include "nsComponentManagerUtils.h"
#include "nsContentUtils.h"
#include "nsError.h"
@@ -456,36 +455,6 @@ void MediaDecoder::OnPlaybackErrorEvent(const MediaResult& aError) {
!needExternalEngine /* disable external engine */);
if (NS_WARN_IF(NS_FAILED(rv))) {
LOG("Failed to create a new state machine!");
glean::mfcdm::ErrorExtra extraData;
extraData.errorName = Some("FAILED_TO_FALLBACK_TO_STATE_MACHINE"_ns);
nsAutoCString resolution;
if (mInfo) {
if (mInfo->HasAudio()) {
extraData.audioCodec = Some(mInfo->mAudio.mMimeType);
}
if (mInfo->HasVideo()) {
extraData.videoCodec = Some(mInfo->mVideo.mMimeType);
DetermineResolutionForTelemetry(*mInfo, resolution);
extraData.resolution = Some(resolution);
}
}
glean::mfcdm::error.Record(Some(extraData));
if (MOZ_LOG_TEST(gMediaDecoderLog, LogLevel::Debug)) {
nsPrintfCString logMessage{"MFCDM Error event, error=%s",
extraData.errorName->get()};
if (mInfo) {
if (mInfo->HasAudio()) {
logMessage.Append(
nsPrintfCString{", audio=%s", mInfo->mAudio.mMimeType.get()});
}
if (mInfo->HasVideo()) {
logMessage.Append(nsPrintfCString{", video=%s, resolution=%s",
mInfo->mVideo.mMimeType.get(),
resolution.get()});
}
}
LOG("%s", logMessage.get());
}
}
// Some attributes might have been set on the destroyed state machine, and

View File

@@ -1225,28 +1225,4 @@ bool IsWaveMimetype(const nsACString& aMimeType) {
aMimeType.EqualsLiteral("audio/wave; codecs=65534");
}
void DetermineResolutionForTelemetry(const MediaInfo& aInfo,
nsCString& aResolutionOut) {
if (aInfo.HasAudio()) {
aResolutionOut.AppendASCII("AV,");
} else {
aResolutionOut.AppendASCII("V,");
}
static const struct {
int32_t mH;
const char* mRes;
} sResolutions[] = {{240, "0<h<=240"}, {480, "240<h<=480"},
{576, "480<h<=576"}, {720, "576<h<=720"},
{1080, "720<h<=1080"}, {2160, "1080<h<=2160"}};
const char* resolution = "h>2160";
int32_t height = aInfo.mVideo.mDisplay.height;
for (const auto& res : sResolutions) {
if (height <= res.mH) {
resolution = res.mRes;
break;
}
}
aResolutionOut.AppendASCII(resolution);
}
} // end namespace mozilla

View File

@@ -578,9 +578,6 @@ inline gfx::YUVColorSpace DefaultColorSpace(const gfx::IntSize& aSize) {
bool IsWaveMimetype(const nsACString& aMimeType);
void DetermineResolutionForTelemetry(const MediaInfo& aInfo,
nsCString& aResolutionOut);
} // end namespace mozilla
#endif

View File

@@ -58,10 +58,6 @@ bool IsPlayReadyKeySystemAndSupported(const nsAString& aKeySystem) {
StaticPrefs::media_wmf_media_engine_enabled() != 2) {
return false;
}
return IsPlayReadyKeySystem(aKeySystem);
}
bool IsPlayReadyKeySystem(const nsAString& aKeySystem) {
return aKeySystem.EqualsLiteral(kPlayReadyKeySystemName) ||
aKeySystem.EqualsLiteral(kPlayReadyKeySystemHardware) ||
aKeySystem.EqualsLiteral(kPlayReadyHardwareClearLeadKeySystemName);
@@ -76,10 +72,6 @@ bool IsWidevineExperimentKeySystemAndSupported(const nsAString& aKeySystem) {
StaticPrefs::media_wmf_media_engine_enabled() != 2) {
return false;
}
return IsWidevineExperimentKeySystem(aKeySystem);
}
bool IsWidevineExperimentKeySystem(const nsAString& aKeySystem) {
return aKeySystem.EqualsLiteral(kWidevineExperimentKeySystemName) ||
aKeySystem.EqualsLiteral(kWidevineExperiment2KeySystemName);
}

View File

@@ -63,12 +63,8 @@ bool IsWidevineKeySystem(const nsAString& aKeySystem);
#ifdef MOZ_WMF_CDM
bool IsPlayReadyKeySystemAndSupported(const nsAString& aKeySystem);
bool IsPlayReadyKeySystem(const nsAString& aKeySystem);
bool IsWidevineExperimentKeySystemAndSupported(const nsAString& aKeySystem);
bool IsWidevineExperimentKeySystem(const nsAString& aKeySystem);
bool IsWMFClearKeySystemAndSupported(const nsAString& aKeySystem);
#endif

View File

@@ -1,88 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
- 'Core :: Audio/Video'
mfcdm:
eme_playback:
type: event
description:
Record the information about the EME playback when using the media engine.
The value of this event is the key system name.
metadata:
tags:
- 'Core :: Audio/Video: Playback'
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1873394
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1873394#c7
data_sensitivity:
- technical
notification_emails:
- media-alerts@mozilla.com
extra_keys:
key_system:
description: The key system used for the EME playback
type: string
video_codec:
description: The video codec used for EME playback
type: string
resolution:
description: The video resolution used for EME playback
type: string
played_time:
description: The amount of time (in seconds) the EME content has been played (in seconds)
type: quantity
rendered_frames:
description: The amount of video frames has been rendered
type: quantity
dropped_frames:
description: The amount of video frames don't get rendered but dropped
type: quantity
expires: 130
telemetry_mirror: Mfcdm_EmePlayback_Gecko
error:
type: event
description:
Record the error or crash happened while using the media engine playback.
The value of this event is the name of error. This probe covers both EME
and non-EME playback.
metadata:
tags:
- 'Core :: Audio/Video: Playback'
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1873394
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1873394#c7
data_sensitivity:
- technical
notification_emails:
- media-alerts@mozilla.com
extra_keys:
error_name:
description: The name of the error
type: string
current_state:
description: The state of the external state machine was being used when the error or crash happened
type: string
audio_codec:
description: The audio codec was being used when the error or crash happened
type: string
video_codec:
description: The video codec was being used when the error or crash happened
type: string
resolution:
description: The video resolution was being used when the error or crash happened
type: string
key_system:
description: The key system was being used when the error or crash happened
type: string
expires: 130
telemetry_mirror: Mfcdm_Error_Gecko

View File

@@ -12,7 +12,6 @@
#include "mozilla/Logging.h"
#include "mozilla/Telemetry.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/glean/GleanMetrics.h"
#include "nsThreadUtils.h"
namespace mozilla {
@@ -436,8 +435,22 @@ void TelemetryProbesReporter::ReportResultForVideo() {
// Keyed by audio+video or video alone, and by a resolution range.
const MediaInfo& info = mOwner->GetMediaInfo();
nsCString key;
DetermineResolutionForTelemetry(info, key);
nsCString key(info.HasAudio() ? "AV," : "V,");
static const struct {
int32_t mH;
const char* mRes;
} sResolutions[] = {{240, "0<h<=240"}, {480, "240<h<=480"},
{576, "480<h<=576"}, {720, "576<h<=720"},
{1080, "720<h<=1080"}, {2160, "1080<h<=2160"}};
const char* resolution = "h>2160";
int32_t height = info.mVideo.mDisplay.height;
for (const auto& res : sResolutions) {
if (height <= res.mH) {
resolution = res.mRes;
break;
}
}
key.AppendASCII(resolution);
auto visiblePlayTimeS = totalVideoPlayTimeS - invisiblePlayTimeS;
LOG("VIDEO_VISIBLE_PLAY_TIME = %f, keys: '%s' and 'All'", visiblePlayTimeS,
@@ -468,56 +481,8 @@ void TelemetryProbesReporter::ReportResultForVideo() {
videoDecodeSuspendPercentage, key.get());
ReportResultForVideoFrameStatistics(totalVideoPlayTimeS, key);
#ifdef MOZ_WMF_CDM
if (mOwner->IsUsingWMFCDM()) {
ReportResultForMFCDMPlaybackIfNeeded(totalVideoPlayTimeS, key);
}
#endif
}
#ifdef MOZ_WMF_CDM
void TelemetryProbesReporter::ReportResultForMFCDMPlaybackIfNeeded(
double aTotalPlayTimeS, const nsCString& aResolution) {
const auto keySystem = mOwner->GetKeySystem();
if (!keySystem) {
NS_WARNING("Can not find key system to report telemetry for MFCDM!!");
return;
}
glean::mfcdm::EmePlaybackExtra extraData;
extraData.keySystem = Some(NS_ConvertUTF16toUTF8(*keySystem));
extraData.videoCodec = Some(mOwner->GetMediaInfo().mVideo.mMimeType);
extraData.resolution = Some(aResolution);
extraData.playedTime = Some(aTotalPlayTimeS);
Maybe<uint64_t> renderedFrames;
Maybe<uint64_t> droppedFrames;
if (auto* stats = mOwner->GetFrameStatistics()) {
renderedFrames = Some(stats->GetPresentedFrames());
droppedFrames = Some(stats->GetDroppedFrames());
extraData.renderedFrames = Some(*renderedFrames);
extraData.droppedFrames = Some(*droppedFrames);
}
if (MOZ_LOG_TEST(gTelemetryProbesReporterLog, LogLevel::Debug)) {
nsPrintfCString logMessage{
"MFCDM EME_Playback event, keySystem=%s, videoCodec=%s, resolution=%s, "
"playedTime=%s",
NS_ConvertUTF16toUTF8(*keySystem).get(),
mOwner->GetMediaInfo().mVideo.mMimeType.get(), aResolution.get(),
std::to_string(aTotalPlayTimeS).c_str()};
if (renderedFrames) {
logMessage.Append(
nsPrintfCString{", renderedFrames=%" PRIu64, *renderedFrames});
}
if (droppedFrames) {
logMessage.Append(
nsPrintfCString{", droppedFrames=%" PRIu64, *droppedFrames});
}
LOG("%s", logMessage.get());
}
glean::mfcdm::eme_playback.Record(Some(extraData));
}
#endif
void TelemetryProbesReporter::ReportResultForAudio() {
// Don't record telemetry for a media that didn't have a valid audio or video
// to play, or hasn't played.

View File

@@ -21,9 +21,6 @@ class TelemetryProbesReporterOwner {
virtual FrameStatistics* GetFrameStatistics() const = 0;
virtual bool IsEncrypted() const = 0;
virtual void DispatchAsyncTestingEvent(const nsAString& aName) = 0;
#ifdef MOZ_WMF_CDM
virtual bool IsUsingWMFCDM() const = 0;
#endif
};
enum class MediaContent : uint8_t {
@@ -94,10 +91,6 @@ class TelemetryProbesReporter final {
void ReportResultForAudio();
void ReportResultForVideoFrameStatistics(double aTotalPlayTimeS,
const nsCString& key);
#ifdef MOZ_WMF_CDM
void ReportResultForMFCDMPlaybackIfNeeded(double aTotalPlayTimeS,
const nsCString& aResolution);
#endif
// Helper class to measure times for playback telemetry stats
class TimeDurationAccumulator {

View File

@@ -115,10 +115,6 @@ bool UtilityProcessHost::Launch(StringVector aExtraOpts) {
EnsureWidevineL1PathForSandbox(aExtraOpts);
#endif
#ifdef MOZ_WMF_CDM
EnanbleMFCDMTelemetryEventIfNeeded();
#endif
mLaunchPhase = LaunchPhase::Waiting;
if (!GeckoChildProcessHost::AsyncLaunch(aExtraOpts)) {
@@ -415,17 +411,4 @@ void UtilityProcessHost::EnsureWidevineL1PathForSandbox(
#endif
#ifdef MOZ_WMF_CDM
void UtilityProcessHost::EnanbleMFCDMTelemetryEventIfNeeded() const {
if (mSandbox != SandboxingKind::MF_MEDIA_ENGINE_CDM) {
return;
}
static bool sTelemetryEventEnabled = false;
if (!sTelemetryEventEnabled) {
sTelemetryEventEnabled = true;
Telemetry::SetEventRecordingEnabled("mfcdm"_ns, true);
}
}
#endif
} // namespace mozilla::ipc

View File

@@ -137,10 +137,6 @@ class UtilityProcessHost final : public mozilla::ipc::GeckoChildProcessHost {
void EnsureWidevineL1PathForSandbox(StringVector& aExtraOpts);
#endif
#ifdef MOZ_WMF_CDM
void EnanbleMFCDMTelemetryEventIfNeeded() const;
#endif
// Set to true on construction and to false just prior deletion.
// The UtilityProcessHost isn't refcounted; so we can capture this by value in
// lambdas along with a strong reference to mLiveToken and check if that value

View File

@@ -54,7 +54,6 @@ firefox_desktop_metrics = [
"browser/components/shopping/metrics.yaml",
"browser/components/urlbar/metrics.yaml",
"browser/modules/metrics.yaml",
"dom/media/platforms/wmf/metrics.yaml",
"toolkit/components/crashes/metrics.yaml",
"toolkit/components/nimbus/metrics.yaml",
"toolkit/components/search/metrics.yaml",

View File

@@ -3485,48 +3485,6 @@ avif:
notification_emails:
- media-alerts@mozilla.com
mfcdm:
eme_playback:
objects: ["gecko"]
bug_numbers: [1873394]
description:
Record the information about the EME playback when using the media engine.
The value of this event is the key system name.
products:
- firefox
record_in_processes: ["all"]
release_channel_collection: opt-out
expiry_version: "130"
notification_emails:
- media-alerts@mozilla.com
extra_keys:
key_system: The key system used for the EME playback
video_codec: The video codec used for playback
resolution: The video resolution used for playback
played_time: The amount of time the EME content has been played (in seconds)
rendered_frames: The amount of video frames has been rendered
dropped_frames: The amount of video frames don't get rendered but dropped
error:
objects: ["gecko"]
bug_numbers: [1873394]
description:
Record the error or crash happened while using the media engine playback.
The value of this event is the name of error.
products:
- firefox
record_in_processes: ["all"]
release_channel_collection: opt-out
expiry_version: "130"
notification_emails:
- media-alerts@mozilla.com
extra_keys:
error_name: The name of the error
current_state: The state of the external state machine was being used when the error or crash happened
video_codec: The video codec was being used when the error or crash happened
audio_codec: The audio codec was being used when the error or crash happened
resolution: The video resolution was being used when the error or crash happened
key_system: The key system was being used when the error or crash happened
installation:
first_seen:
description: >