Replace CachedFragment::Copy with std::move in CacheTsbFragment#1350
Merged
Conversation
Eliminate unnecessary deep copy of fragment data (2-7 MB for UHD) in CacheTsbFragment by using move assignment instead of Copy(). The move assignment operator already exists on CachedFragment. Also add null guard for GetFetchChunkBuffer return value to prevent potential null pointer dereference. (bug discovered while doing above) LL-DASH chunk mode callers that need the fragment for both CacheTsbFragment and EnqueueWrite now create a separate copy before moving into the cache. Add unit test validating move semantics transfer ownership correctly.
DomSyna
reviewed
Apr 24, 2026
DomSyna
reviewed
Apr 24, 2026
| if (aamp->GetLLDashChunkMode()) | ||
| { | ||
| CacheTsbFragment(fragmentToTsbSessionMgr); | ||
| auto fragmentForChunkCache = std::make_shared<CachedFragment>(*fragmentToTsbSessionMgr); |
DomSyna
reviewed
Apr 24, 2026
DomSyna
reviewed
Apr 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes TSB fragment caching by replacing a deep copy of CachedFragment payloads with move assignment, reducing large (multi-MB) memory copies in UHD scenarios, and adds a null guard to prevent a potential null dereference when acquiring a chunk-cache slot.
Changes:
- Update
MediaStreamContext::CacheTsbFragmentto move-assign fragment data into the cache slot, avoiding deep copies. - Add a null check for
GetFetchChunkBuffer(true)returningnullptr, returningfalseearly with an error log. - Update LL-DASH chunk-mode paths to create a separate copy when the fragment must be used for both chunk caching and
EnqueueWrite, and add a unit test intended to validate move semantics.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
MediaStreamContext.cpp |
Replace Copy() with move assignment in CacheTsbFragment, add null guard, and adjust LL-DASH callers to copy before caching. |
test/utests/tests/MediaStreamContextTests/FragmentDownloadTests.cpp |
Add a unit test for CacheTsbFragment move-based transfer into the chunk-cache slot. |
…1test Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Abhi-jith-S
pushed a commit
that referenced
this pull request
May 12, 2026
…1350) Reason for Change: Eliminate unnecessary deep copy of fragment data (2-7 MB for UHD) in CacheTsbFragment by using move assignment instead of Copy(). The move assignment operator already exists on CachedFragment. Also add null guard for GetFetchChunkBuffer return value to prevent potential null pointer dereference. (bug discovered while doing above) LL-DASH chunk mode callers that need the fragment for both CacheTsbFragment and EnqueueWrite now create a separate copy before moving into the cache. Add unit test validating move semantics transfer ownership correctly. Also: Refactoring to enforce std::move use at compile time. Update for old (misleading) comment. Test Guidance: regression + no test breakage --------- Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com> Co-authored-by: pstroffolino <Philip_Stroffolino@cable.comcast.com>
varatharajan568
pushed a commit
that referenced
this pull request
May 20, 2026
…1350) Reason for Change: Eliminate unnecessary deep copy of fragment data (2-7 MB for UHD) in CacheTsbFragment by using move assignment instead of Copy(). The move assignment operator already exists on CachedFragment. Also add null guard for GetFetchChunkBuffer return value to prevent potential null pointer dereference. (bug discovered while doing above) LL-DASH chunk mode callers that need the fragment for both CacheTsbFragment and EnqueueWrite now create a separate copy before moving into the cache. Add unit test validating move semantics transfer ownership correctly. Also: Refactoring to enforce std::move use at compile time. Update for old (misleading) comment. Test Guidance: regression + no test breakage --------- Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com> Co-authored-by: pstroffolino <Philip_Stroffolino@cable.comcast.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eliminate unnecessary deep copy of fragment data (2-7 MB for UHD) in CacheTsbFragment by using move assignment instead of Copy(). The move assignment operator already exists on CachedFragment.
Also add null guard for GetFetchChunkBuffer return value to prevent potential null pointer dereference. (bug discovered while doing above)
LL-DASH chunk mode callers that need the fragment for both CacheTsbFragment and EnqueueWrite now create a separate copy before moving into the cache.
Add unit test validating move semantics transfer ownership correctly.