Skip to content

Fix updateProfile() 4K iframe selection bugs#1369

Open
benmesander wants to merge 2 commits intodev_sprint_25_2from
feature/VPAAMP-206
Open

Fix updateProfile() 4K iframe selection bugs#1369
benmesander wants to merge 2 commits intodev_sprint_25_2from
feature/VPAAMP-206

Conversation

@benmesander
Copy link
Copy Markdown
Contributor

Issue: The 4K iframe selection path used !mDesiredIframeProfile to check whether a matching iframe was found. Since profile index 0 is a valid index, !0 evaluates to true, causing the fallback to overwrite a correct match at index 0. Replace with an explicit bool foundMatchingIframe flag.

Issue: The middle video bandwidth was computed as
mProfiles[profileCount / 2], which includes iframe tracks in the count and can land on an iframe profile. Use mSortedBWProfileList (which excludes iframes) to find the middle video bandwidth instead.

Issue: fix an out-of-bounds access in the fallback path: when iframeTrackCount == 1, the formula count/2 + count%2 yields index 1, which is past the end of a 1-element vector. Initialize mDesiredIframeProfile to iframeTrackInfo[0].idx (lowest-BW iframe) and guard the fallback with > 1 instead of >= 1.

Applied to both new ABR (abr/abr.cpp) and legacy ABR (support/aampabr/ABRManager.cpp). L1 tests added to AbrTests.cpp and HybridAbrTests.cpp covering all three bugs.

  • GetBestMatchedProfile_ExactMatch_UnsortedProfiles (legacy)
  • GetBestMatchedProfile_ClosestMatch_UnsortedProfiles (legacy)

Issue: The 4K iframe selection path used `!mDesiredIframeProfile` to
check whether a matching iframe was found. Since profile index 0 is a
valid index, `!0` evaluates to true, causing the fallback to overwrite
a correct match at index 0. Replace with an explicit `bool
foundMatchingIframe` flag.

Issue: The middle video bandwidth was computed as
`mProfiles[profileCount / 2]`, which includes iframe tracks in the
count and can land on an iframe profile. Use mSortedBWProfileList
(which excludes iframes) to find the middle video bandwidth instead.

Issue: fix an out-of-bounds access in the fallback path: when
iframeTrackCount == 1, the formula `count/2 + count%2` yields index 1,
which is past the end of a 1-element vector. Initialize
mDesiredIframeProfile to iframeTrackInfo[0].idx (lowest-BW iframe) and
guard the fallback with `> 1` instead of `>= 1`.

Applied to both new ABR (abr/abr.cpp) and legacy ABR
(support/aampabr/ABRManager.cpp). L1 tests added to AbrTests.cpp and
HybridAbrTests.cpp covering all three bugs.
- GetBestMatchedProfile_ExactMatch_UnsortedProfiles (legacy)
- GetBestMatchedProfile_ClosestMatch_UnsortedProfiles (legacy)
@benmesander benmesander requested a review from a team as a code owner April 27, 2026 18:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes multiple bugs in the 4K iframe selection logic inside ABRManager::updateProfile() for both the new ABR and legacy ABR implementations, ensuring correct matching behavior for iframe profile index 0, correct “middle video bandwidth” computation, and safer fallback selection.

Changes:

  • Replace the !mDesiredIframeProfile “not found” check with an explicit foundMatchingIframe flag to avoid treating index 0 as false.
  • Compute the middle video bandwidth using mSortedBWProfileList (non-iframe only) instead of indexing into mProfiles (which may include iframes).
  • Add unit tests covering the 4K iframe middle-bandwidth selection and index-0 matching behaviors for both ABR paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
abr/abr.cpp Fixes new-ABR 4K iframe selection by using non-iframe BW list and explicit match tracking; adjusts fallback guard.
support/aampabr/ABRManager.cpp Applies the same 4K iframe selection fixes to legacy ABR logic.
test/utests/tests/AampAbrTests/AbrTests.cpp Adds L1 tests validating the new-ABR 4K iframe middle-BW selection and index-0 handling.
test/utests/tests/AampAbrTests/HybridAbrTests.cpp Adds equivalent tests for the legacy/hybrid ABR implementation.

Comment on lines +543 to +548
/**
* @brief Bug #13: updateProfile 4K path must compute middle video bandwidth
* excluding iframe tracks. With interleaved profiles, profileCount/2
* could land on an iframe track.
*/
TEST_F(AbrTests, UpdateProfile_4K_MiddleIndex_ExcludesIframeTracks)
Comment on lines +548 to +552
TEST_F(AbrTests, UpdateProfile_4K_MiddleIndex_ExcludesIframeTracks)
{
ABRManager abrManager;
abrManager.ReadPlayerConfig(&eAAMPAbrConfig);

Comment on lines +276 to +284
/**
* @brief Bug #13: updateProfile 4K path must compute middle video bandwidth
* excluding iframe tracks (legacy ABR).
*/
TEST_F(HybridAbrTests, UpdateProfile_4K_MiddleIndex_ExcludesIframeTracks)
{
HybridABRManager mgr;
mgr.ReadPlayerConfig(&eAAMPAbrConfig);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants