Open Bug 1405841 Opened 3 years ago Updated 1 year ago

Large amount of memory used to load video

Categories

(Core :: Audio/Video: Playback, enhancement, P3)

enhancement

Tracking

()

Tracking Status
firefox-esr52 --- wontfix
firefox-esr60 --- affected
firefox56 --- wontfix
firefox57 --- wontfix
firefox58 --- wontfix
firefox66 --- wontfix
firefox67 --- affected
firefox68 --- affected

People

(Reporter: tsmith, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

(Keywords: testcase)

Attachments

(1 file)

The attached test case seems to use ~500MB of memory or more to load. Every time the video is reloaded another large chunk of memory is consumed (press enter on the url bar, F5 does not seem to work).
Flags: in-testsuite?
Attached video test_case.mp4
It looks like MoofParser uses lots of memory in dmd memory dump.


Unreported {
  47 blocks in heap block record 1 of 6,498
  1,342,225,280 bytes (1,342,210,456 requested / 14,824 slop)
  Individual block sizes: 1,342,181,376; 2,048 x 7; 1,024 x 23; 496 x 4; 416 x 5; 336 x 4; 256 x 2; 96
  91.87% of the heap (91.87% cumulative)
  97.46% of unreported (97.46% cumulative)
  Allocated at {
    #01: replace_malloc (DMD.cpp:1303, in libdmd.dylib)
    #02: nsTArrayFallibleAllocator::ResultTypeProxy nsTArray_base<nsTArrayFallibleAllocator, nsTArray_CopyWithMemutils>::EnsureCapacity<nsTArrayFallibleAllocator>(unsigned long, unsigned long) (nsTArray-inl.h:137, in XUL)
    #03: mp4_demuxer::Moof::Moof(mp4_demuxer::Moof const&) (nsTArray.h:142, in XUL)
    #04: mp4_demuxer::MoofParser::RebuildFragmentedIndex(mp4_demuxer::BoxContext&) (nsTArray.h:2204, in XUL)
    #05: mp4_demuxer::MoofParser::RebuildFragmentedIndex(mozilla::media::IntervalSet<long long> const&, bool*) (MoofParser.cpp:36, in XUL)
    #06: mp4_demuxer::Index::UpdateMoofIndex(mozilla::media::IntervalSet<long long> const&) (Index.cpp:434, in XUL)
    #07: mozilla::MP4TrackDemuxer::EnsureUpToDateIndex() (MP4Demuxer.cpp:407, in XUL)
    #08: mozilla::MP4TrackDemuxer::MP4TrackDemuxer(mozilla::MP4Demuxer*, mozilla::UniquePtr<mozilla::TrackInfo, mozilla::DefaultDelete<mozilla::TrackInfo> >&&, mp4_demuxer::IndiceWrapper const&) (UniquePtr.h:326, in XUL)
  }
}
Flags: needinfo?(ayang)
One of its TrackRunBox has invalid sample count, it should return error at https://dxr.mozilla.org/mozilla-central/rev/c97190c389c4cfef20fe55b4bacade95a36ae6ef/media/libstagefright/binding/MoofParser.cpp#668.

So this bug is the same problem as bug 1387798.


<TrackRunBox SampleCount="16777227" DataOffset="5632">
<BoxInfo Size="20" Type="trun"/>
<FullBoxInfo Version="0" Flags="0x1"/>
</TrackRunBox>
Depends on: 1387798
Flags: needinfo?(ayang)
Has Regression Range: --- → no
Unreported {
  41 blocks in heap block record 1 of 6,544
  1,342,222,736 bytes (1,342,208,008 requested / 14,728 slop)
  Individual block sizes: 1,342,181,376; 2,048 x 7; 1,024 x 22; 496 x 3; 416 x 5; 336 x 2; 256
  90.90% of the heap (90.90% cumulative)
  97.51% of unreported (97.51% cumulative)
  Allocated at {
    #01: replace_malloc (DMD.cpp:1303, in libdmd.dylib)
    #02: nsTArrayFallibleAllocator::ResultTypeProxy nsTArray_base<nsTArrayFallibleAllocator, nsTArray_CopyWithMemutils>::EnsureCapacity<nsTArrayFallibleAllocator>(unsigned long, unsigned long) (nsTArray-inl.h:137, in XUL)
    #03: mp4_demuxer::Moof::Moof(mp4_demuxer::Moof const&) (nsTArray.h:144, in XUL)
    #04: mp4_demuxer::MoofParser::RebuildFragmentedIndex(mp4_demuxer::BoxContext&) (nsTArray.h:2209, in XUL)
    #05: mp4_demuxer::Index::UpdateMoofIndex(mozilla::media::IntervalSet<long long> const&, bool) (RefPtr.h:78, in XUL)
    #06: mozilla::MP4TrackDemuxer::EnsureUpToDateIndex() (MP4Demuxer.cpp:401, in XUL)
    #07: mozilla::MP4TrackDemuxer::MP4TrackDemuxer(mozilla::MP4Demuxer*, mozilla::UniquePtr<mozilla::TrackInfo, mozilla::DefaultDelete<mozilla::TrackInfo> >&&, mp4_demuxer::IndiceWrapper const&) (UniquePtr.h:326, in XUL)
    #08: mozilla::MP4Demuxer::Init() (nsTArray.h:400, in XUL)
  }
}
All the table entries in 'trun' are 'default' value, so it doesn't need to list the whole table even the table size is very large. MoofParser can't know if the sample count is correct or not.

Another way is to check MediaDataBox size if the total sample size exceeds MediaDataBox size, it means that's an invalid 'moof'.

<TrackRunBox SampleCount="16777227" DataOffset="5632">
  <BoxInfo Size="20" Type="trun"/>
  <FullBoxInfo Version="0" Flags="0x1"/>
  <!-- all default values used -->
</TrackRunBox>

<MediaDataBox dataSize="5466">
  <BoxInfo Size="5474" Type="mdat"/>
</MediaDataBox>
Another way is to calculate the table on the fly instead of creating one large table. However, it could change current architecture in MoofParser.
Flags: needinfo?(ayang)
You need to log in before you can comment on or make changes to this bug.