-
Notifications
You must be signed in to change notification settings - Fork 7
VPLAY-12359 suboptimal UTCTiming behavior #853
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
Conversation
a1b2712 to
4781ef1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR optimizes UTC time synchronization behavior for DASH manifests by implementing interval-based sync throttling. The changes prevent excessive network calls to UTC time servers by skipping synchronization attempts until a minimum interval has elapsed, while maintaining the ability to use cached offset values.
Changes:
- Added
TimeSyncClientstruct to track UTC sync state (last sync time, offset, and sync status) - Introduced two new configuration options:
UTCSyncOnStartup(boolean) andUTCSyncMinIntervalSec/UTCSyncOnErrorRetrySec(integers) - Modified
FindServerUTCTimeto check elapsed time since last sync before making network calls
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| fragmentcollector_mpd.h | Added TimeSyncClient struct definition and member variable to track sync state |
| fragmentcollector_mpd.cpp | Updated FindServerUTCTime logic to conditionally sync based on elapsed interval |
| AampDefine.h | Added default constant definitions for UTC sync intervals |
| AampConfig.h | Added new config enum entries for UTC sync control |
| AampConfig.cpp | Registered new config options in lookup tables with defaults |
4781ef1 to
d8c11d9
Compare
d8c11d9 to
aaff6b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Reason for change: Updates UTCTiming logic to skip sync if interval hasn’t elapsed. Add Configs to control the interval Test Procedure: updated in ticket Risks: Low Signed-off-by: Anurag Krishnan <[email protected]>
aaff6b2 to
a8e0d9f
Compare
deprecated eAAMPConfig_UTCSyncOnErrorRetrySec fixed bug with config order causing runtime crash added some doxygen comments Signed-off-by: Philip Stroffolino <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Signed-off-by: Philip Stroffolino <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Signed-off-by: Philip Stroffolino <[email protected]>
Merge branch 'feature/VPLAY-12359_UTCTiming' of https://github.com/rdkcentral/aamp into feature/VPLAY-12359_UTCTiming Signed-off-by: Philip Stroffolino <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
| * - lastOffset: Cached time delta (in seconds) between local and server time. | ||
| * - hasSynced: Flag indicating whether at least one successful sync has occurred. | ||
| */ | ||
| struct TimeSyncClient |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing include directive for the fixed-width integer types. If the recommendation to use 'int64_t' instead of 'long long' is followed (as suggested in another comment), this header file should include '' to make those types available.
Add: #include
| mLocalUtcTime = GetNetworkTime(ServerUrl, &http_error, aamp->GetNetworkProxy()); | ||
| if(mLocalUtcTime > 0 ) | ||
| bool shouldSyncOnStartup = !mTimeSyncClient.hasSynced && ISCONFIGSET(eAAMPConfig_UTCSyncOnStartup); | ||
| bool intervalElapsed = false; |
Copilot
AI
Jan 14, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic flow has a subtle issue: when shouldSyncOnStartup is true, intervalElapsed is never calculated, which is fine. However, the condition on line 4517 uses OR logic (shouldSyncOnStartup || intervalElapsed), which means intervalElapsed could be used uninitialized if shouldSyncOnStartup is false and the calculation on line 4515 doesn't execute due to the if statement on line 4512.
Wait - looking more carefully, if shouldSyncOnStartup is false (line 4512 condition), then we enter the block and calculate intervalElapsed. So intervalElapsed is always initialized before use on line 4517. However, this is not immediately clear from the code structure.
Consider declaring intervalElapsed with an initial value for clarity: 'bool intervalElapsed = false;' to make the initialization explicit and improve readability.
Signed-off-by: Philip Stroffolino <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
| double currentTime = (double)aamp_GetCurrentTimeMS() / 1000; | ||
| mDeltaTime = mLocalUtcTime - currentTime; | ||
| hasServerUtcTime = true; | ||
| const double elapsed = (double)(aamp_GetCurrentTimeMS() - mTimeSyncClient.lastSync) / 1000; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 1000 is used for millisecond-to-second conversion. Consider defining a named constant like MS_IN_SEC or MILLISECONDS_PER_SECOND to improve code readability and maintainability, as this pattern appears multiple times in the codebase.
Signed-off-by: Philip Stroffolino <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
fragmentcollector_mpd.h:1
- The struct members should use fixed-width integer types for
lastSyncto ensure consistent size across platforms. According to the custom C++ guidelines for ctypes interoperability, useint64_tinstead oflong long.
/*
| {DEFAULT_MIN_BUFFER_LOW_LATENCY,"lowLatencyMinBuffer",eAAMPConfig_LowLatencyMinBuffer,true, eCONFIG_RANGE_LLDBUFFER}, | ||
| {DEFAULT_TARGET_BUFFER_LOW_LATENCY,"lowLatencyTargetBuffer",eAAMPConfig_LowLatencyTargetBuffer,true, eCONFIG_RANGE_LLDBUFFER}, | ||
| {GST_BW_TO_BUFFER_FACTOR,"bandwidthToBufferFactor", eAAMPConfig_BWToGstBufferFactor,true}, | ||
| {GST_BW_TO_BUFFER_FACTOR,"bandwidthToBufferFactor", eAAMPConfig_BWToGstBufferFactor,true} |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of the trailing comma from the last entry in mConfigLookupTableFloat is inconsistent with C++11 best practices, which allow and encourage trailing commas in initializer lists for easier maintenance. Consider keeping the trailing comma to simplify future additions.
| #include "fragmentcollector_mpd.h" | ||
| #include "MockStreamAbstractionAAMP_MPD.h" | ||
|
|
||
| TimeSyncClient::TimeSyncClient(){} |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The empty constructor implementation should have the braces on separate lines or use = default to be consistent with modern C++ style. Consider either formatting as TimeSyncClient::TimeSyncClient() {} with a space, or using the default constructor syntax.
| double currentTime = (double)aamp_GetCurrentTimeMS() / 1000; | ||
| mDeltaTime = mLocalUtcTime - currentTime; | ||
| hasServerUtcTime = true; | ||
| const double elapsed = (double)(aamp_GetCurrentTimeMS() - mTimeSyncClient.lastSync) / 1000; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The calculation converts to double and then divides by 1000. This can be optimized by performing the division on the integer value first to minimize precision loss, or using a more explicit conversion: const double elapsed = static_cast<double>(aamp_GetCurrentTimeMS() - mTimeSyncClient.lastSync) / 1000.0;. Also prefer static_cast over C-style casts per C++ Core Guidelines.
| if(mLocalUtcTime > 0) | ||
| { | ||
| mTimeSyncClient.lastSync = aamp_GetCurrentTimeMS(); | ||
| mDeltaTime = mLocalUtcTime - (double)mTimeSyncClient.lastSync / 1000; |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use static_cast<double> instead of C-style cast (double) to follow C++ Core Guidelines and modern C++ best practices.
| {eAAMPConfig_MaxFragmentChunkCached, DEFAULT_CACHED_FRAGMENT_CHUNKS_PER_TRACK}, | ||
| {eAAMPConfig_UTCSyncMinIntervalSec, DEFAULT_UTC_SYNC_MIN_INTERVAL_SEC} |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new UTC sync functionality introduced in FindServerUTCTime lacks dedicated test coverage. The existing FindServerUTCTimeTest should be extended to verify the interval-based throttling behavior, including scenarios where sync is skipped due to the minimum interval not being elapsed, and where cached offset values are used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
|
@pstroffolino I've opened a new pull request, #858, to work on those changes. Once the pull request is ready, I'll request review from you. |
Signed-off-by: Philip Stroffolino <[email protected]>
…kcentral/aamp into feature/VPLAY-12359_UTCTiming
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
| */ | ||
| TEST_F(StreamAbstractionAAMP_MPDTest, FindServerUTCTime_SyncOnStartup) | ||
| { | ||
| GTEST_SKIP(); |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All five new UTC sync test cases are skipped (lines 3034, 3086, 3145, 3207, 3266). These tests cover critical behavior including startup sync, interval-based skip logic, and cached offset usage. They should be enabled and properly integrated into the test suite to validate the new UTC synchronization logic.
| bool hasSynced; /**< Flag indicating whether at least one successful sync has occurred. */ | ||
|
|
||
| /** | ||
| * @brief Constructor initializes lastSync with current time and resets other members. |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states the constructor "initializes lastSync with current time" but doesn't mention that this initialization happens via aamp_GetCurrentTimeMS() which creates a side effect during construction by making a system call. This should be documented, or consider using a factory method/explicit initialization instead of doing this work in the constructor to follow RAII best practices.
| * @brief Constructor initializes lastSync with current time and resets other members. | |
| * @brief Constructor initializes lastSync with current time and resets other members. | |
| * | |
| * This initialization obtains the current time via a call to | |
| * aamp_GetCurrentTimeMS(), which may perform a system call to | |
| * query the system clock. Callers should be aware that constructing | |
| * TimeSyncClient can therefore incur this side effect. |
| #include "fragmentcollector_mpd.h" | ||
| #include "MockStreamAbstractionAAMP_MPD.h" | ||
|
|
||
| TimeSyncClient::TimeSyncClient(){} |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fake TimeSyncClient constructor is empty, which means member variables (lastSync, lastOffset, hasSynced) are left uninitialized. This creates undefined behavior when tests access these members. The fake should either match the real implementation or explicitly initialize members to known values for deterministic test behavior.
| TimeSyncClient::TimeSyncClient(){} | |
| TimeSyncClient::TimeSyncClient() | |
| : lastSync(0) | |
| , lastOffset(0) | |
| , hasSynced(false) | |
| { | |
| } |
Reason for change: Updates UTCTiming logic to skip sync if interval hasn’t elapsed. Add Configs to control the interval
Test Procedure: updated in ticket
Risks: Low