Index: media/blink/webmediaplayer_impl.cc |
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc |
index 172541b83589e380d6e5e3fc661da93561247df7..6eae5029a747cccdfa5a90a2914ef3c92f9e2ba5 100644 |
--- a/media/blink/webmediaplayer_impl.cc |
+++ b/media/blink/webmediaplayer_impl.cc |
@@ -2102,15 +2102,27 @@ void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) { |
const PipelineStatistics stats = GetPipelineStatistics(); |
const int64_t data_source_memory_usage = |
data_source_ ? data_source_->GetMemoryUsage() : 0; |
- const int64_t current_memory_usage = |
- stats.audio_memory_usage + stats.video_memory_usage + |
- data_source_memory_usage + demuxer_memory_usage; |
- // Note, this isn't entirely accurate, there may be VideoFrames held by the |
- // compositor or other resources that we're unaware of. |
+ // If we have video and no video memory usage, assume the VideoFrameCompositor |
+ // is holding onto the last frame after we've suspended the pipeline; which |
+ // thus reports zero memory usage from the video renderer. |
+ // |
+ // Technically this should use the coded size, but that requires us to hop to |
+ // the compositor to get and byte-perfect accuracy isn't important here. |
+ const int64_t video_memory_usage = |
+ stats.video_memory_usage + |
+ (pipeline_metadata_.has_video && !stats.video_memory_usage |
+ ? VideoFrame::AllocationSize(PIXEL_FORMAT_YV12, |
+ pipeline_metadata_.natural_size) |
+ : 0); |
+ |
+ const int64_t current_memory_usage = |
+ stats.audio_memory_usage + video_memory_usage + data_source_memory_usage + |
+ demuxer_memory_usage; |
- DVLOG(2) << "Memory Usage -- Audio: " << stats.audio_memory_usage |
- << ", Video: " << stats.video_memory_usage |
+ DVLOG(2) << "Memory Usage -- Total: " << current_memory_usage |
+ << " Audio: " << stats.audio_memory_usage |
+ << ", Video: " << video_memory_usage |
<< ", DataSource: " << data_source_memory_usage |
<< ", Demuxer: " << demuxer_memory_usage; |
@@ -2124,7 +2136,7 @@ void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) { |
} |
if (HasVideo()) { |
UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Video", |
- stats.video_memory_usage / 1024); |
+ video_memory_usage / 1024); |
} |
if (data_source_) { |
UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.DataSource", |