Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix memory leak in DASH live streams with inband EventStream #3957

Merged
merged 1 commit into from Feb 16, 2022
Merged

fix: Fix memory leak in DASH live streams with inband EventStream #3957

merged 1 commit into from Feb 16, 2022

Conversation

joeyparrish
Copy link
Member

EventStreams in DASH generate TimelineRegionInfo objects, which are
then stored in the RegionTimeline and RegionObserver classes. But
DashParser would add all regions to RegionTimeline, even if they would
be quickly removed again, and RegionObserver would cache some regions
from the timeline without ever removing them.

This fixes the issue from both of those directions. DashParser will
now ignore regions that are outside the DVR window (and therefore
would soon be removed from RegionTimeline), and RegionObserver listens
to an event on RegionTimeline to clean up its own storage when regions
fall outside the DVR window during playback.

Closes #3949 (memory leak in DASH live streams with inband EventStream)

@joeyparrish joeyparrish added type: bug Something isn't working correctly component: DASH The issue involves the MPEG DASH manifest format labels Feb 16, 2022
@joeyparrish
Copy link
Member Author

Hrm... I've got a test failure, likely caused by the code I moved in DashParser. I'll take a look on Wednesday.

Copy link
Collaborator

@theodab theodab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual code LGTM.

test/dash/dash_parser_live_unit.js Outdated Show resolved Hide resolved
@@ -985,7 +985,8 @@ describe('DashParser Manifest', () => {

it('duplicate Representation ids with live', async () => {
const source = [
'<MPD minBufferTime="PT75S" type="dynamic">',
'<MPD minBufferTime="PT75S" type="dynamic"',
' availabilityStartTime="1970-01-01T00:00:00Z">',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was broken before. You can't have a dynamic manifest without a start time. However, the code in DashParser hid this mistake, because it didn't set the PresentationTimeline to dynamic until after all the periods had been parsed.

I moved up the code that sets properties on PresentationTimeline, so that the correct values for start time and isLive() are available during parsing. That caused this test to fail, however, due to a failed assertion in PresentationTimeline. Making the MPD in this test more realistic fixes that previously-hidden issue.

EventStreams in DASH generate TimelineRegionInfo objects, which are
then stored in the RegionTimeline and RegionObserver classes.  But
DashParser would add all regions to RegionTimeline, even if they would
be quickly removed again, and RegionObserver would cache some regions
from the timeline without ever removing them.

This fixes the issue from both of those directions.  DashParser will
now ignore regions that are outside the DVR window (and therefore
would soon be removed from RegionTimeline), and RegionObserver listens
to an event on RegionTimeline to clean up its own storage when regions
fall outside the DVR window during playback.

Closes #3949 (memory leak in DASH live streams with inband EventStream)
@joeyparrish joeyparrish merged commit b7f04cb into shaka-project:master Feb 16, 2022
@joeyparrish joeyparrish deleted the region-leak-2 branch February 16, 2022 22:03
joeyparrish added a commit that referenced this pull request Feb 16, 2022
)

EventStreams in DASH generate TimelineRegionInfo objects, which are
then stored in the RegionTimeline and RegionObserver classes.  But
DashParser would add all regions to RegionTimeline, even if they would
be quickly removed again, and RegionObserver would cache some regions
from the timeline without ever removing them.

This fixes the issue from both of those directions.  DashParser will
now ignore regions that are outside the DVR window (and therefore
would soon be removed from RegionTimeline), and RegionObserver listens
to an event on RegionTimeline to clean up its own storage when regions
fall outside the DVR window during playback.

Closes #3949 (memory leak in DASH live streams with inband EventStream)
joeyparrish added a commit that referenced this pull request Feb 16, 2022
)

EventStreams in DASH generate TimelineRegionInfo objects, which are
then stored in the RegionTimeline and RegionObserver classes.  But
DashParser would add all regions to RegionTimeline, even if they would
be quickly removed again, and RegionObserver would cache some regions
from the timeline without ever removing them.

This fixes the issue from both of those directions.  DashParser will
now ignore regions that are outside the DVR window (and therefore
would soon be removed from RegionTimeline), and RegionObserver listens
to an event on RegionTimeline to clean up its own storage when regions
fall outside the DVR window during playback.

Closes #3949 (memory leak in DASH live streams with inband EventStream)
joeyparrish added a commit that referenced this pull request Feb 16, 2022
)

EventStreams in DASH generate TimelineRegionInfo objects, which are
then stored in the RegionTimeline and RegionObserver classes.  But
DashParser would add all regions to RegionTimeline, even if they would
be quickly removed again, and RegionObserver would cache some regions
from the timeline without ever removing them.

This fixes the issue from both of those directions.  DashParser will
now ignore regions that are outside the DVR window (and therefore
would soon be removed from RegionTimeline), and RegionObserver listens
to an event on RegionTimeline to clean up its own storage when regions
fall outside the DVR window during playback.

Closes #3949 (memory leak in DASH live streams with inband EventStream)
@avelad avelad added this to the v4.0 milestone May 4, 2022
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Jul 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: DASH The issue involves the MPEG DASH manifest format status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential memory leak w/ DASH live streams and inband EventStreams
3 participants