Skip to content

[Due for payment 2026-03-17] Web - BaseVideoPlayer - Loader does not appear consistently during slow network #82779

Closed

Description

@jponikarchuk

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.21-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #82480
Email or phone of affected tester (no customers): applausetester+th12@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 11
App Component: Other

Action Performed:

  1. Open the New Expensify App on Web.
  2. Go to the workspace chat.
  3. Click on “+” → “Add attachment”.
  4. Select a short video (<24MB).
  5. Before sending or playing the video, activate “Simulate poor internet connection” (network throttling / slow network).
  6. Send or open the video.
  7. Observe the loader behavior (ActivityIndicator).

Expected Result:

The loader (ActivityIndicator) should remain visible consistently while the video is loading or buffering under slow network conditions.

Once the video loads and starts playing, the loader disappears.

Actual Result:

The loader appears briefly at the start of the video load.

When the connection fluctuates, the app shows “No Connection” and does not keep the loader visible.

The video eventually loads and plays normally only after exiting and re-entering, without the loader being displayed during intermittent loading.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7081218_1771412107232.Grabando__332.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Feb 18, 2026
  2. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Feb 18, 2026
  3. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Feb 18, 2026
  4. melvin-bot commented on Feb 18, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @rojiphil (External)

  5. melvin-bot commented on Feb 18, 2026

    @melvin-bot

    Triggered auto assignment to @joekaufmanexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  6. melvin-bot commented on Feb 18, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. MelvinBot commented on Feb 18, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    On web, when a video is loading or buffering under slow/intermittent network conditions, the loading spinner (ActivityIndicator) in BaseVideoPlayer disappears prematurely. Instead of showing a consistent loader while the video buffers, the app either shows "No Connection" briefly or shows nothing at all, and the video only plays correctly after exiting and re-entering the view.

    What is the root cause of that problem?

    There are two compounding issues in BaseVideoPlayer.tsx that cause the loader to disappear under slow/intermittent networks:

    1. shouldShowLoadingIndicator excludes the offline case and mid-playback buffering

    At BaseVideoPlayer.tsx:128-132:

    const shouldShowLoadingIndicator = useMemo(() => {
        return isLoading && (!isPlaying || currentTime <= 0) && !isOffline && !hasError;
    }, [currentTime, hasError, isLoading, isOffline, isPlaying]);
    • The !isOffline condition means the spinner disappears the instant isOffline becomes true. On slow networks, NetInfo detects offline status when the reachability ping to api/Ping times out (10s threshold), even though the video CDN may still be serving data. This causes the spinner to vanish while the video is still buffering.
    • The !isPlaying condition means once a video starts playing (isPlaying=true) and stalls due to a buffer underrun, the spinner will NOT reappear. This is because in the HTML5 video spec, the browser does NOT fire onpause during a buffering stall — playing stays true while the expo-video web player sets status back to 'loading' via onwaiting (VideoPlayer.web.js:367-371). So isLoading=true but isPlaying=true and currentTime > 0, making the condition evaluate to false.

    2. The replaceAsync('') effect aggressively kills the video source

    At BaseVideoPlayer.tsx:108-113:

    useEffect(() => {
        if (!(isOffline && isLoading)) {
            return;
        }
        videoPlayerRef.current.replaceAsync('');
    }, [isLoading, isOffline]);

    When isOffline flips to true while the video is loading, the source is replaced with an empty string, aborting any in-progress load. The recovery path at lines 99-106 only fires replaceAsync(sourceURL) if currentTime <= 0 && hasError, which may not be satisfied if the empty source replacement doesn't produce an error status from expo-video.

    Additionally, shouldShowOfflineIndicator at line 133-135 requires currentTime + bufferedPosition <= 0, so if any data was buffered before the offline flag triggered, neither the offline indicator nor the loading spinner shows — creating a visual dead zone where the user has no feedback at all.

    What changes do you think we should make in order to solve the problem?

    The fix should be applied in src/components/VideoPlayer/BaseVideoPlayer.tsx:

    1. Remove the !isOffline condition from shouldShowLoadingIndicator (or add a secondary condition that shows the spinner when isLoading && isOffline). The loading spinner should remain visible when the video is in a loading status regardless of the offline flag, since the video may still be loading from CDN even when the Expensify API ping fails.

    2. Remove or relax the !isPlaying condition for mid-playback buffering stalls. When status === 'loading' (which expo-video sets via onwaiting during buffer stalls), the spinner should show even if the video was previously playing. Consider changing the condition to just isLoading && !hasError — or alternatively, use the playingChange event from expo-video to track isPlaying reactively (currently it's read as a non-reactive snapshot at line 85).

    3. Remove or guard the replaceAsync('') effect so it does not destroy the video source during intermittent network conditions. This effect should only fire if the device is confirmed fully offline for a sustained period, not on momentary NetInfo flickers. One approach is to add a debounce or only abort the load when the video has been offline+loading for longer than a threshold (e.g., matching the 10s NetInfo timeout).

    What alternative solutions did you explore? (Optional)

    An alternative would be to introduce a separate "video-specific" offline detection mechanism that checks CDN reachability rather than relying on the global isOffline flag from useNetwork() (which pings the Expensify API). This would more accurately reflect whether the video can actually load. However, this would be a larger architectural change and the simpler approach above (adjusting the indicator conditions and removing the aggressive source replacement) addresses the core symptoms directly.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  8. PiyushChandra17 commented on Feb 18, 2026

    @PiyushChandra17
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2026-02-20 08:05:01 UTC.

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Web - BaseVideoPlayer - Loader does not appear consistently during slow network

    What is the root cause of that problem?

    1. We only show LoadingIndicator if shouldShowLoadingIndicator is truthy,

    const shouldShowLoadingIndicator = useMemo(() => {
    // We want to show LoadingIndicator when video's loading and paused, except when it's loading
    // for the first time, then playing/loading may vary. Video should be online and without errors.
    return isLoading && (!isPlaying || currentTime <= 0) && !isOffline && !hasError;
    }, [currentTime, hasError, isLoading, isOffline, isPlaying]);

    1. Now We want to show the loading indicator when video is loading && paused or (currentTime <= 0) && it should be online and without error (all these conditions are met)

    2. We show the you appears to offline via AttachmentOfflineIndicator here

    {!isPreview && (
    <View>
    <Text style={[styles.notFoundTextHeader, styles.ph10]}>{translate('common.youAppearToBeOffline')}</Text>
    <Text style={[styles.textAlignCenter, styles.ph11, styles.textSupporting]}>{translate('common.attachmentWillBeAvailableOnceBackOnline')}</Text>
    </View>
    )}

    const shouldShowOfflineIndicator = useMemo(() => {
    return isOffline && currentTime + bufferedPosition <= 0;
    }, [bufferedPosition, currentTime, isOffline]);

    {shouldShowOfflineIndicator && <AttachmentOfflineIndicator isPreview={isPreview} />}

    What changes do you think we should make in order to solve the problem?

    • We need to add one more condition in shouldShowOfflineIndicator - > !isLoading

    • We want to show shouldShowOfflineIndicator only when isOffline is true && currentTime + bufferedPosition <= 0 && !isLoading

    • Remove the !isOffline check from shouldShowLoadingIndicator

    • Updated code:

    const shouldShowLoadingIndicator = useMemo(() => {
        // We want to show LoadingIndicator when video's loading and paused, except when it's loading
        // for the first time, then playing/loading may vary. And without errors.
        return isLoading && (!isPlaying || currentTime <= 0) && !hasError;
    }, [currentTime, hasError, isLoading, isPlaying]);
    
    const shouldShowOfflineIndicator = useMemo(() => {
        return isOffline && currentTime + bufferedPosition <= 0 && !isLoading;
    }, [bufferedPosition, currentTime, isOffline, isLoading]);

    This will ensure the loader appears consistently

    What alternative solutions did you explore? (Optional)

    Result:

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  9. HiepPP commented on Feb 18, 2026

    @HiepPP
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The loading spinner in the video player disappears inconsistently during slow or unstable network conditions. When the connection fluctuates, the "No Connection" indicator appears instead of the loading spinner, even though the video is still buffering.

    What is the root cause of that problem?

    The shouldShowLoadingIndicator logic in BaseVideoPlayer.tsx includes !isOffline as a condition. This causes the loading indicator to vanish whenever the network status reports offline, regardless of whether the video is actively loading. During poor connections, the video can still be buffering while the app reports offline, making this assumption incorrect.

    const shouldShowLoadingIndicator = useMemo(() => {
    // We want to show LoadingIndicator when video's loading and paused, except when it's loading
    // for the first time, then playing/loading may vary. Video should be online and without errors.
    return isLoading && (!isPlaying || currentTime <= 0) && !isOffline && !hasError;
    }, [currentTime, hasError, isLoading, isOffline, isPlaying]);

    const shouldShowLoadingIndicator = useMemo(() => {
      return (
        isLoading && (!isPlaying || currentTime <= 0) && !isOffline && !hasError
      );
    }, [currentTime, hasError, isLoading, isOffline, isPlaying]);

    What changes do you think we should make in order to solve the problem?

    Modify the indicator display logic in src/components/VideoPlayer/BaseVideoPlayer.tsx:

    1. Remove !isOffline from shouldShowLoadingIndicator so the loading indicator shows whenever the video is actively loading, regardless of network status.

    2. Add !isLoading to shouldShowOfflineIndicator to prevent both indicators from displaying simultaneously.

    const shouldShowLoadingIndicator = useMemo(() => {
    // We want to show LoadingIndicator when video's loading and paused, except when it's loading
    // for the first time, then playing/loading may vary. Video should be online and without errors.
    return isLoading && (!isPlaying || currentTime <= 0) && !isOffline && !hasError;
    }, [currentTime, hasError, isLoading, isOffline, isPlaying]);
    const shouldShowOfflineIndicator = useMemo(() => {
    return isOffline && currentTime + bufferedPosition <= 0;
    }, [bufferedPosition, currentTime, isOffline]);

    const shouldShowLoadingIndicator = useMemo(() => {
      // Show loading indicator when video is loading, even on poor connection.
      return isLoading && (!isPlaying || currentTime <= 0) && !hasError;
    }, [currentTime, hasError, isLoading, isPlaying]);
    
    const shouldShowOfflineIndicator = useMemo(() => {
      // Show offline indicator only when not actively loading.
      return isOffline && currentTime + bufferedPosition <= 0 && !isLoading;
    }, [bufferedPosition, currentTime, isOffline, isLoading]);

    This ensures the loading indicator takes priority when the video is buffering, while the offline indicator only appears when no content is buffered and the video is not loading.

    What alternative solutions did you explore? (Optional)

    Considered debouncing the network state to handle rapid fluctuations, but rejected because:

    • Adds complexity
    • The proposed fix already prevents simultaneous indicator display
    • No flickering was reported in the issue

    Files Modified:

    • src/components/VideoPlayer/BaseVideoPlayer.tsx - Updated loading and offline indicator conditions

    Testing Performed:

    • TypeScript compilation passes
    • Prettier formatting verified
    • Lint checks pass (no new warnings introduced)
  10. mobile84developer-ctrl commented on Feb 18, 2026

    @mobile84developer-ctrl

    🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.

  11. github-actions commented on Feb 18, 2026

    @github-actions
    Contributor

    ⚠️ @mobile84developer-ctrl Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.

  12. 34 remaining items

  13. rojiphil commented on Mar 16, 2026

    @rojiphil
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: Not Required. The existing checklist is good enough to capture such issues.

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    Regression Test Proposal Template
    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    Precondition:

    Test:

    1. Open the app on web (Chrome)
    2. Navigate to a workspace chat
    3. Send a short video (<24MB)
    4. Open Chrome DevTools → Network tab → set throttling to "Slow 3G"
    5. Open/play the video
    6. Verify the loading spinner remains visible consistently while the video is buffering
    7. Verify no "No Connection" indicator flashes during the slow loading
    8. Set DevTools to "Offline" mode
    9. Wait at least 7 seconds
    10. Verify the offline indicator appears after the threshold
    11. Re-enable the network
    12. Verify the loading spinner reappears (or video resumes playing)

    Do we agree 👍 or 👎

  14. joekaufmanexpensify commented on Mar 16, 2026

    @joekaufmanexpensify
    Contributor

    Thanks! Will handle next steps so we can pay tomorrow.

  15. melvin-bot commented on Mar 17, 2026

    @melvin-bot

    Issue is ready for payment but no BZ is assigned. @mallenexpensify you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

  16. melvin-bot commented on Mar 17, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  17. joekaufmanexpensify commented on Mar 17, 2026

    @joekaufmanexpensify
    Contributor
  18. joekaufmanexpensify commented on Mar 17, 2026

    @joekaufmanexpensify
    Contributor

    Payment Summary

    • Contributor+: @rojiphil due $250 via NewDot
  19. joekaufmanexpensify commented on Mar 17, 2026

    @joekaufmanexpensify
    Contributor

    @rojiphil please request payment in NewDot at your earliest convenience. Closing as this is otherwise all set 👍

  20. quinthar commented on Apr 13, 2026

    @quinthar
    Contributor

    Approved $250 to @rojiphil

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions