Skip to content

[Due for payment 2026-08-05] [$250] [Exploratory] Video - Play button doesn't work after changing speed for a played video #91224

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.78-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: #89424
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: iPhone 15 iOS 26.4.2
App Component: Chat Report View

Action Performed:

  1. Create a chat with another user, send a video attachment
  2. Tap the attachment preview
  3. Let the video play till the end
  4. Tap 3 dots menu at the right side of the playback controls
  5. Tap Playback speed, tap 2 (the fastest).
  6. Tap Play button

Expected Result:

The video is playing again

Actual Result:

The video is not playing, if it's finished and the speed was changed

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Video.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Jul 17, 2026
  2. MelvinBot commented on Jul 17, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    The Play button chooses between "resume" and "replay from start" based on an isEnded React state flag — but changing the playback speed clears that flag before you tap Play, so the button resumes a video that's already parked at its end (a no-op on iOS) instead of replaying it.

    The play handler only calls replayVideo() (which seeks to 0 first) when isEnded is still true, otherwise it falls through to a bare playVideo():

    Evidence (App e4ae3a2)

    1. Play button handler — replay is gated on isEnded: BaseVideoPlayer.tsx:199-211

    if (player.playing) { pauseVideo(); return; }
    
    if (isEnded && currentTime >= duration) {   // gated on the isEnded flag
        allowSharedAutoPlayRef.current = true;
        replayVideo();                            // replay() seeks to 0 then plays
        return;
    }
    allowSharedAutoPlayRef.current = true;
    playVideo();                                  // bare play(): no-op at end on iOS

    2. Changing speed clears isEnded: the speed handler writes player.playbackRate = speed, which — per its own inline comment — resumes playback on iOS (VideoPopoverMenuContext.tsx:32-40). That momentary resume fires the playingChange listener, which sets isEnded back to false (BaseVideoPlayer.tsx:289-296):

    if (isVideoPlaying && isEnded) {
        setIsEnded(false);
    }

    3. isEnded is only ever re-set to true by the playToEnd event (BaseVideoPlayer.tsx:317-321), which won't fire again, so the "ended" state is lost even though currentTime is still >= duration.

    4. playVideo() is a bare play() with no seek; only replayVideo() restarts (usePlaybackContextVideoRefs.ts:9-19).

    Sequence: video ends → isEnded = true → user picks 2x → playbackRate write resumes playback → playingChange clears isEnded → user taps Play → isEnded is now false, so the replay branch is skipped → playVideo() on a player at its end position → nothing happens.

    This also explains why the bug only reproduces after changing speed: without the speed change, isEnded stays true and Play correctly replays.

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

    Base the replay decision on the player's position, not the fragile isEnded flag. A video parked at its end should always replay, regardless of whether isEnded was cleared. In the Play handler at BaseVideoPlayer.tsx:204, change the guard so the replay branch triggers when duration > 0 && currentTime >= duration (dropping the reliance on isEnded).

    What alternative solutions did you explore? (Optional)

    Alternatively, avoid clearing isEnded in the playingChange listener when the play was triggered by a playbackRate write rather than a genuine user Play (e.g. guard with a ref set only during real play). The position-based guard is the smaller, more robust fix.

    🔎 Possibly related

    • Expensify/App#91625 — Changing playback speed on video reflects on other videos' speed (also in the playback-speed handler).

    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/91224) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jul 17, 2026
  4. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jul 17, 2026
  5. wildan-m commented on Jul 17, 2026

    @wildan-m
    Contributor

    Proposal

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

    In the video player, after a video has played all the way to the end, changing the playback speed and then tapping the Play button does not restart the video. The Play button appears to do nothing. This only happens when the video is already finished AND the playback speed was changed afterward; replaying a finished video works fine if the speed was not touched.

    What is the root cause of that problem?

    When a video reaches the end, the player records that it has finished by setting the isEnded state to true:

    useEventListener(videoPlayerRef.current, 'playToEnd', () => {
    setIsEnded(true);
    setControlStatusState(CONST.VIDEO_PLAYER.CONTROLS_STATUS.SHOW);
    controlsOpacity.set(1);
    });

    The Play button relies on that isEnded flag to decide whether tapping Play should replay the finished video (seek back to the start and play) instead of just calling play(). Calling play() while the playhead is already sitting at the end is a no-op, so the replay branch is what actually makes a finished video play again:

    if (player.playing) {
    pauseVideo();
    return;
    }
    if (isEnded && currentTime >= duration) {
    allowSharedAutoPlayRef.current = true;
    replayVideo();
    return;
    }
    allowSharedAutoPlayRef.current = true;
    playVideo();

    The problem is that changing the playback speed clears the isEnded flag prematurely. On iOS, assigning a new playbackRate resumes playback if the player was paused — a quirk the code already acknowledges in a comment:

    const updatePlaybackSpeed = (speed: PlaybackSpeed) => {
    setCurrentPlaybackSpeed(speed);
    // Setting the playback rate on iOS can resume playback if it was paused, so skip when already set.
    if (!videoPopoverMenuPlayerRef.current || videoPopoverMenuPlayerRef.current.playbackRate === speed) {
    return;
    }
    videoPopoverMenuPlayerRef.current.playbackRate = speed;
    };

    Because the finished video sits paused at the end, setting the new rate makes iOS briefly resume it. That brief resume emits a playingChange event with isPlaying = true, and the playingChange listener responds by clearing isEnded back to false:

    useEventListener(videoPlayerRef.current, 'playingChange', (payload: PlayingChangeEventPayload) => {
    const isVideoPlaying = payload.isPlaying;
    // Toggled in the listener (not a `useEffect`) — the web setter synchronously emits `timeUpdate`, which would re-enter `useEvent` from render.
    videoPlayerRef.current.timeUpdateEventInterval = isVideoPlaying ? 0.1 : 0;
    if (isVideoPlaying && isEnded) {
    setIsEnded(false);
    }
    });

    The video is still at the end (the playhead never actually moved), but the component now thinks it is not finished. So when the user taps Play, the condition isEnded && currentTime >= duration is false, the replay branch is skipped, and playVideo() is called instead — which does nothing because the playhead is already at the end. The result is that the Play button appears dead.

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

    Make the Play button detect "the video is at its end" by the playhead position rather than depending solely on the isEnded flag, since that flag can be cleared spuriously by the iOS playback-rate side effect described above.

    In togglePlayCurrentVideo in src/components/VideoPlayer/BaseVideoPlayer.tsx, change the replay condition so that it replays whenever the playhead has reached the end of a loaded video, in addition to the existing isEnded check. Concretely, replay when currentTime >= duration (guarded by duration > 0 so it never triggers on an unloaded/zero-length video), OR when isEnded is set:

    if (player.playing) {
    pauseVideo();
    return;
    }
    if (isEnded && currentTime >= duration) {
    allowSharedAutoPlayRef.current = true;
    replayVideo();
    return;
    }
    allowSharedAutoPlayRef.current = true;
    playVideo();

    This branch is only reached when the player is paused (the preceding check returns early when the player is currently playing), so a paused playhead that has reached the duration unambiguously means the video is finished and should be replayed. With this change, tapping Play after a speed change correctly seeks back to the start and plays, regardless of whether isEnded was cleared. The fix is shared logic, so it covers all platforms, and it does not change behavior for the normal cases (resuming a paused mid-video still calls playVideo(); replaying a finished video without a speed change still replays).

    Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/91224-replay-finished-video-after-speed-change?expand=1

    What alternative solutions did you explore? (Optional)

    An alternative is to stop the playingChange listener from clearing isEnded when the playhead is still at the end (only clear it when playback has genuinely moved away from the end). This addresses the same root cause at the source, but it is riskier: a real replay momentarily reports isPlaying = true before the seek-to-zero settles, so a naive position guard could fail to clear isEnded on a legitimate replay and leave the controls stuck in the "ended" state. Fixing the decision at the Play button is more robust because replay always seeks to the start, after which the existing listener clears isEnded normally.

    Another alternative is to re-pause the player inside updatePlaybackSpeed after setting the rate when the video was not playing, to counter the iOS auto-resume. This does not fix the symptom on its own, because the brief resume still emits the playingChange(true) event that clears isEnded before the re-pause takes effect.

  6. melvin-bot commented on Jul 17, 2026

    @melvin-bot

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

  7. changed the title [-][Exploratory] Video - Play button doesn't work after changing speed for a played video[/-] [+][$250] [Exploratory] Video - Play button doesn't work after changing speed for a played video[/+] on Jul 17, 2026
  8. 38 remaining items

  9. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Aug 3, 2026
  10. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  11. melvin-bot commented on Aug 4, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    • ROLE: @dmkt9 paid $(AMOUNT) via Upwork (LINK)

    BugZero Checklist (@mallenexpensify)

    • 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/2078168097405253334/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
  12. mallenexpensify commented on Aug 7, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @dmkt9 paid $250 via NewDot

    @dmkt9 can you please accept the job below? Please reply here and tag me once you have.
    If you're not sent an offer in Upwork when you're assigned to an issue, please tag me. If an Upwork job exists, please submit a proposal.
    https://www.upwork.com/jobs/~022078168097405253334

    ^ Test case created. Thx

  13. dmkt9 commented on Aug 7, 2026

    @dmkt9
    Contributor

    @dmkt9 can you please accept the job below? Please reply here and tag me once you have.

    @mallenexpensify Thanks. I've accepted the offer

  14. mallenexpensify commented on Aug 8, 2026

    @mallenexpensify
    Contributor

    @dmkt9 paid, summary updated above. Thx.

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 contributorNot a priority

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions