Bug 1755820 - Improve memory reporter in TrackBuffersManager. r=media-playback-reviewers,alwu

This expands our memory reporting in TrackBuffersManager to cover additional
memory usage. Specifically it now reports several buffers where input data is
stored by the manager. These buffers will not typically take up that much space,
but it doesn't hurt to have them reported against media. Additionally, we've
just fixed a case where one of the buffers reported in this patch was growing
without bound, so it's nice to have some cover on that (bug 1697476 ). Reporting
these metrics will allow for testing of that bug too.

There is still more that could be reported from the TrackBuffersManager, but
that's a big yak to shave, so this patch intentionally does not attempt to do
so.

I've verified this works via about:memory and dmd.py (this also confirms there
are no double counts in my testing).

Differential Revision: https://phabricator.services.mozilla.com/D139246
This commit is contained in:
Bryce Seager van Dyk 2022-02-24 02:04:46 +00:00
Родитель c46226129e
Коммит b63d9c3455
1 изменённых файлов: 19 добавлений и 0 удалений

Просмотреть файл

@ -3028,6 +3028,25 @@ void TrackBuffersManager::GetDebugInfo(
void TrackBuffersManager::AddSizeOfResources(
MediaSourceDecoder::ResourceSizes* aSizes) const {
MOZ_ASSERT(OnTaskQueue());
if (mInputBuffer.isSome() && mInputBuffer->Buffer()) {
// mInputBuffer should be the sole owner of the underlying buffer, so this
// won't double count.
aSizes->mByteSize += mInputBuffer->Buffer()->ShallowSizeOfIncludingThis(
aSizes->mMallocSizeOf);
}
if (mInitData) {
aSizes->mByteSize +=
mInitData->ShallowSizeOfIncludingThis(aSizes->mMallocSizeOf);
}
if (mPendingInputBuffer.isSome() && mPendingInputBuffer->Buffer()) {
// mPendingInputBuffer should be the sole owner of the underlying buffer, so
// this won't double count.
aSizes->mByteSize +=
mPendingInputBuffer->Buffer()->ShallowSizeOfIncludingThis(
aSizes->mMallocSizeOf);
}
mVideoTracks.AddSizeOfResources(aSizes);
mAudioTracks.AddSizeOfResources(aSizes);
}