From e5bb59cbdf9fb6fb2d812b868cd76c13cc681b10 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Mon, 22 May 2017 15:03:00 +1200 Subject: [PATCH] Bug 1366639 - Add telemetry to track max number of PChromiumCDM video frame shmems. r=francois,gerald This will enable us to pre-allocate the correct number of shared memory buffers that we pre-allocate for sending video frames between the CDM and Gecko. That means we won't need to take the slow path to recover from underestimating how many shmems we need. MozReview-Commit-ID: Q4mX2rYMz3 --HG-- extra : rebase_source : f9573cfbf4e65013803b46c0909be2c68566e512 --- dom/media/gmp/ChromiumCDMParent.cpp | 12 ++++++++++++ dom/media/gmp/ChromiumCDMParent.h | 2 ++ toolkit/components/telemetry/Histograms.json | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/dom/media/gmp/ChromiumCDMParent.cpp b/dom/media/gmp/ChromiumCDMParent.cpp index 13559ab980fe..4e5598f9bedc 100644 --- a/dom/media/gmp/ChromiumCDMParent.cpp +++ b/dom/media/gmp/ChromiumCDMParent.cpp @@ -10,6 +10,7 @@ #include "mozilla/Unused.h" #include "ChromiumCDMProxy.h" #include "mozilla/dom/MediaKeyMessageEventBinding.h" +#include "mozilla/Telemetry.h" #include "content_decryption_module.h" #include "GMPLog.h" #include "MediaPrefs.h" @@ -696,6 +697,10 @@ ChromiumCDMParent::EnsureSufficientShmems(size_t aVideoFrameSize) } mVideoShmemsActive++; } + + mMaxVideoShmemsActive = + std::max(mMaxVideoShmemsActive, mVideoShmemsActive); + return true; } @@ -1051,6 +1056,13 @@ ChromiumCDMParent::ShutdownVideoDecoder() } mVideoDecoderInitialized = false; + GMP_LOG("ChromiumCDMParent::~ShutdownVideoDecoder(this=%p) " + "VIDEO_CHROMIUM_CDM_MAX_SHMEMS=%u", + this, + mMaxVideoShmemsActive); + Telemetry::Accumulate(Telemetry::HistogramID::VIDEO_CHROMIUM_CDM_MAX_SHMEMS, + mMaxVideoShmemsActive); + // The ChromiumCDMChild will purge its shmems, so if the decoder is // reinitialized the shmems need to be re-allocated, and they may need // to be a different size. diff --git a/dom/media/gmp/ChromiumCDMParent.h b/dom/media/gmp/ChromiumCDMParent.h index b6091d95cace..4c4e86168d47 100644 --- a/dom/media/gmp/ChromiumCDMParent.h +++ b/dom/media/gmp/ChromiumCDMParent.h @@ -166,6 +166,8 @@ protected: uint32_t mVideoShmemsActive = 0; // Maximum number of shmems to use to return decoded video frames. uint32_t mVideoShmemLimit; + // High water mark for mVideoShmemsActive, reported via telemetry. + uint32_t mMaxVideoShmemsActive = 0; bool mIsShutdown = false; bool mVideoDecoderInitialized = false; diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 8b542ee1a2f7..20837799a7c1 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -8331,6 +8331,15 @@ "description": "Reports whether a navigator.requestMediaKeySystemAccess() was called in a secure context (i.e. on an origin served over HTTPS) or not.", "bug_numbers": [1360438] }, + "VIDEO_CHROMIUM_CDM_MAX_SHMEMS": { + "record_in_processes": ["main", "content"], + "alert_emails": ["cpearce@mozilla.com"], + "bug_numbers": [1366639], + "expires_in_version": "60", + "kind": "enumerated", + "n_values": 50, + "description": "Counts of the maximum number of shared memory buffers used for transferring video frames between the CDM and Gecko processes during playback of DRM'd video. Reported once per CDMVideoDecoder instance, i.e., once per JavaScript SourceBuffer during playback of video using EME." + }, "VIDEO_MFT_OUTPUT_NULL_SAMPLES": { "record_in_processes": ["main", "content"], "alert_emails": ["cpearce@mozilla.com"],