Delay video offline state to show loader during intermittent network#84197
Delay video offline state to show loader during intermittent network#84197
Conversation
…etwork
During intermittent network conditions, the isOffline flag from useNetwork()
flips rapidly, causing the video loading spinner to disappear and the offline
indicator to flash. This also triggers replaceAsync('') which destructively
clears the video source mid-stream.
Introduce a local isVideoOffline state in BaseVideoPlayer that only becomes
true after isOffline has been continuously true for 10 seconds. This keeps the
loading spinner visible during brief offline blips while still showing the
offline indicator for confirmed sustained offline periods.
Co-authored-by: Jules <Julesssss@users.noreply.github.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MelvinBot Considering that the threshold used for intermittent networks via |
The threshold for intermittent networks via 'Simulate poor internet connection' is 5 seconds, so 7 seconds is a more appropriate threshold to distinguish brief connectivity drops from sustained offline state. Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com>
|
Good point — updated |
|
While testing, I noticed an existing issue with the latest main specifically with respect to web chrome version (Mac OS). I have raised this in expensify bugs here |
|
@MelvinBot LGTM. Please mark the PR as |
|
PR has been marked as Ready for review ✅ |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppUnable to test in simulator. Raised the issue here. But I think it should be fine considering that the changes are not platform specific. Android: mWeb Chrome84197-mweb-chrome-001.mp4iOS: HybridApp84197-ios-hybrid-001.mp4iOS: mWeb Safari84197-mweb-safari-001.mp4MacOS: Chrome / Safari84197-web-chrome-003.mp4 |
rojiphil
left a comment
There was a problem hiding this comment.
@Julesssss Changes LGTM. Over to you. Thanks.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a46ff50460
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@MelvinBot What do you think of the concern here? |
…r reconnection
Adds isOffline as an extra condition to the effect that calls
replaceAsync('') so it never fires when the network has already
reconnected, closing a theoretical race window where isVideoOffline
could still be true for one render cycle after isOffline flips to false.
Co-authored-by: Roji Philip <rojiphil@users.noreply.github.com>
rojiphil
left a comment
There was a problem hiding this comment.
LGTM
84197-web-chrome-005.mp4
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @Julesssss has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
Explanation of Change
During intermittent/slow network conditions,
isOfflinefromuseNetwork()flips rapidly asNetInfodetects brief connectivity drops. InBaseVideoPlayer, this causes:shouldShowLoadingIndicatorrequires!isOffline)replaceAsync('')to fire destructively, clearing the video source mid-streamThis PR introduces a local
isVideoOfflinestate that only becomestrueafterisOfflinehas been continuouslytruefor 7 seconds (CONST.VIDEO_PLAYER.OFFLINE_THRESHOLD). WhenisOfflineflips back tofalse,isVideoOfflineresets immediately. This delayed state is used in place ofisOfflinefor the loading indicator, offline indicator, error indicator, and thereplaceAsync('')effect.Result:
replaceAsync('')does not firereplaceAsync('')fires to stop the stalled loadFixed Issues
$ #82779
PROPOSAL: #82779 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari