VPAAMP-764 Guard GetBufferStatus against uninitialized mStartTimeStamp before first fragment injection#1718
Open
pstroffolino wants to merge 2 commits into
Open
VPAAMP-764 Guard GetBufferStatus against uninitialized mStartTimeStamp before first fragment injection#1718pstroffolino wants to merge 2 commits into
pstroffolino wants to merge 2 commits into
Conversation
MediaTrack::GetBufferStatus() can produce anomalous negative bufferedTime and epoch-scale elapsedTime values when called before NotifyFirstFragmentInjected() has set mStartTimeStamp. This occurs because MonitorBufferHealth may start polling before the fragment injector thread has injected the first fragment, at which point mStartTimeStamp is still -1, causing GetElapsedTime() to compute against epoch (Jan 1 1970). Root cause: Race between MonitorBufferHealth thread launch and first fragment injection in the fragment injector thread. mStartTimeStamp is initialized to -1 and only set to a valid value in NotifyFirstFragmentInjected(). Fix: Add an early return of BUFFER_STATUS_GREEN in GetBufferStatus() when pContext->mStartTimeStamp < 0. Buffer monitoring is meaningless before first fragment injection, so reporting GREEN is the correct behavior. Impact: Eliminates spurious buffer underflow warnings and misleading GetBufferStatus log entries during startup. These bogus entries were visible in AutoTriage BufferStatus visualizations as large negative bufferedTime outliers. Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR prevents MediaTrack::GetBufferStatus() from reporting bogus startup buffer metrics when buffer health polling begins before the first fragment has been injected (i.e., before StreamAbstractionAAMP::NotifyFirstFragmentInjected() initializes mStartTimeStamp).
Changes:
- Add an early return of
BUFFER_STATUS_GREENinMediaTrack::GetBufferStatus()whenmStartTimeStampis still uninitialized (< 0), avoiding epoch-scale elapsed time calculations and negative buffered time.
pstroffolino
force-pushed
the
feature/VPAAMP-764
branch
from
July 10, 2026 19:34
31c3d0f to
0be044f
Compare
Before NotifyFirstFragmentInjected(), mStartTimeStamp is -1 which causes GetElapsedTime() to return epoch-scale values, producing bogus negative bufferedTime. Buffer monitoring is meaningless before first fragment injection, so return BUFFER_STATUS_GREEN immediately. - Add public IsFirstFragmentInjected() to StreamAbstractionAAMP that checks mStartTimeStamp >= 0 under mLock (thread-safe) - Use IsFirstFragmentInjected() in GetBufferStatus() guard instead of direct protected field access - Fix 3 existing LLD GetBufferStatus tests to call NotifyFirstFragmentInjected() (they model post-injection buffering) - Add 2 new tests: pre-injection GREEN guard, post-injection evaluation
pstroffolino
force-pushed
the
feature/VPAAMP-764
branch
from
July 10, 2026 19:51
0be044f to
274aa93
Compare
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.
MediaTrack::GetBufferStatus() can produce anomalous negative bufferedTime and epoch-scale elapsedTime values when called before NotifyFirstFragmentInjected() has set mStartTimeStamp. This occurs because MonitorBufferHealth may start polling before the fragment injector thread has injected the first fragment, at which point mStartTimeStamp is still -1, causing GetElapsedTime() to compute against epoch (Jan 1 1970).
Root cause: Race between MonitorBufferHealth thread launch and first fragment injection in the fragment injector thread. mStartTimeStamp is initialized to -1 and only set to a valid value in NotifyFirstFragmentInjected().
Fix: Add an early return of BUFFER_STATUS_GREEN in GetBufferStatus() when pContext->mStartTimeStamp < 0. Buffer monitoring is meaningless before first fragment injection, so reporting GREEN is the correct behavior.
Impact: Eliminates spurious buffer underflow warnings and misleading GetBufferStatus log entries during startup. These bogus entries were visible in AutoTriage BufferStatus visualizations as large negative bufferedTime outliers.