Skip to content
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

[HOLD for payment 2024-06-03] [$250] Playback speed is not displayed correctly in video player #40646

Closed
1 of 6 tasks
m-natarajan opened this issue Apr 20, 2024 · 107 comments
Closed
1 of 6 tasks
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@m-natarajan
Copy link

m-natarajan commented Apr 20, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.63-7
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @blimpich / @KMichel1030
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1713565240359109

Action Performed:

  1. Upload two videos(Video1, Video2).
  2. Play Video1.
  3. Then change playback speed to 0.25 (or any other)
  4. Play Video2.
  5. Check playback speed of Video2 (three dot menu -> playback speed).

Expected Result:

Playback speed of Video2 should be displayed as 1

Actual Result:

Video2 is played at speed 1 but playback speed is displayed as 0.25

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Issue.1.mp4
Recording.3004.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01648564b9cecf0115
  • Upwork Job ID: 1781837388056326144
  • Last Price Increase: 2024-04-24
  • Automatic offers:
    • hungvu193 | Contributor | 0
Issue OwnerCurrent Issue Owner: @stephanieelliott
@m-natarajan m-natarajan added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Apr 20, 2024
Copy link

melvin-bot bot commented Apr 20, 2024

Triggered auto assignment to @stephanieelliott (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.

@serhii1030
Copy link
Contributor

serhii1030 commented Apr 20, 2024

Proposal

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

We have two problems in this issue
First

  1. Play Video1 and change playback speed to 0.25
  2. Play Video2 and change playback speed to 0.5
  3. Play Video1 again and check speed

Expected Result:
Video1's speed should be 0.25
Actual result:
Video1 is actually played in speed of 0.25, but if we check speed in menu it is 0.5

Second

  1. Upload 2 videos(Video1, Video2)
  2. Play Video2.
  3. Play Video1 and change playback speed to 0.25.
  4. Change playback speed of Video2 to 2 without play.

Expected Result:
Video2's speed should be updated
Actual result:
Video1's speed is updated.

What is the root cause of that problem?

First
Playback speed is stored in currentPlaybackSpeed in VideoPopoverMenuContext. Once it is set, it shows same value for all video player components.

const [currentPlaybackSpeed, setCurrentPlaybackSpeed] = useState<PlaybackSpeed>(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS[2]);

Second
When changing playback speed, we change speed of currentVideoPlayerRef.
currentVideoPlayerRef indicates currently playing video. So if we change playback speed of video which is not playing, playing video's speed is changed.

const updatePlaybackSpeed = useCallback(
(speed: PlaybackSpeed) => {
setCurrentPlaybackSpeed(speed);
currentVideoPlayerRef.current?.setStatusAsync?.({rate: speed});
},
[currentVideoPlayerRef],

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

First

  1. Add `setCurrentPlaybackSpeed here.
  2. Add below line here
    setCurrentPlaybackSpeed: (speed: PlaybackSpeed) => void;
  3. We have to get playback speed from ref and set currentPlaybackSpeed when opening three dot menu.
    get setCurrentPlaybackSpeed from useVideoPopoverMenuContext.
    const {setCurrentPlaybackSpeed} = useVideoPopoverMenuContext();
    Add below part in this function
 videoPlayerRef.current?.getStatusAsync().then((status) => {
            if (!('rate' in status && status.rate)) {
                return;
            }
            setCurrentPlaybackSpeed(status.rate as PlaybackSpeed);
        });

Second
We have to set speed of videoPlayerRef instead of currentVideoPlayerRef.

  1. Add ref(playerRef) which stores current video ref(ref of video player which we are trying to change speed) in VideoPopoverMenuContext.

Add below part here
const playerRef = useRef<VideoWithOnFullScreenUpdate | null>(null);

And also add playerRef to contextValue

  1. set playerRef with videoPlayerRef when opening popover menu

playerRef.current = videoPlayerRef.current;

const showPopoverMenu = (event?: GestureResponderEvent | KeyboardEvent) => {
setIsPopoverVisible(true);

  1. In updatePlaybackSpeed function, change speed of playerRef, not currentVideoPlayerRef.

What alternative solutions did you explore? (Optional)

If we want change currently playing video when opening popover menu:

  • Add setCurrentPlaybackSpeed here.
  • Add below line here
    setCurrentPlaybackSpeed: (speed: PlaybackSpeed) => void;
  • Get setCurrentPlaybackSpeed from useVideoPopoverMenuContext.
    const {setCurrentPlaybackSpeed} = useVideoPopoverMenuContext();
  • We should add below part here.
updateCurrentlyPlayingURL(url);
videoPlayerRef.current?.getStatusAsync().then((status) => {
          if(!('rate' in status && status.rate)) {
              return;
          }
          setCurrentPlaybackSpeed(status.rate as PlaybackSpeed);
      })
  • Then to prevent auto playing when opening pop over menu.
    We have to check if popover menu is opened or not in this part.
    We have to replace this part with below part.

shareVideoPlayerElements(videoPlayerRef.current, videoPlayerElementParentRef.current, videoPlayerElementRef.current, !isUploading && !isPopoverVisible);

Copy link

melvin-bot bot commented Apr 20, 2024

📣 @KMichel1030! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@blimpich blimpich self-assigned this Apr 20, 2024
@blimpich blimpich added the External Added to denote the issue can be worked on by a contributor label Apr 21, 2024
Copy link

melvin-bot bot commented Apr 21, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01648564b9cecf0115

@melvin-bot melvin-bot bot changed the title Playback speed is not displayed correctly in video player [$250] Playback speed is not displayed correctly in video player Apr 21, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 21, 2024
Copy link

melvin-bot bot commented Apr 21, 2024

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

@blimpich blimpich changed the title [$250] Playback speed is not displayed correctly in video player [$150] Playback speed is not displayed correctly in video player Apr 21, 2024
Copy link

melvin-bot bot commented Apr 21, 2024

Upwork job price has been updated to $150

@blimpich
Copy link
Contributor

Reduced price as I consider this a low-priority bug.

@shahinyan11
Copy link
Contributor

shahinyan11 commented Apr 21, 2024

Proposal

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

Playback speed is not displayed correctly in video player

What is the root cause of that problem?

We use one context to display playback speed for all videos. And the currentPlaybackSpeed updates there only when the select speed for some video

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

We should update currentPlaybackSpeed in context based current video speed when user opens video popover.

  1. Add new popoverVideoPlayerRef in VideoPopoverMenuContextProvider and update currentVideoPlayerRef to popoverVideoPlayerRef.
new popoverVideoPlayerRef = useRef<VideoWithOnFullScreenUpdate | null>(null);

...

const updatePlaybackSpeed = useCallback(
    (speed: PlaybackSpeed) => {
        setCurrentPlaybackSpeed(speed);
        popoverVideoPlayerRef.current?.setStatusAsync?.({rate: speed});
    },
    [popoverVideoPlayerRef],
);
  1. Add popoverVideoPlayerRef and setCurrentPlaybackSpeed in contextValue

  2. Get popoverVideoPlayerRef and setCurrentPlaybackSpeed from useVideoPopoverMenuContext() in BaseVideoPlayer component and add below cod on this line ( before if block ).

popoverVideoPlayerRef.current = videoPlayerRef.current
popoverVideoPlayerRef.current?.getStatusAsync().then((status) => {
    setCurrentPlaybackSpeed(status?.rate)
})

What alternative solutions did you explore? (Optional)

@Pycomet
Copy link

Pycomet commented Apr 22, 2024

Proposal

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

Playback speed is not displayed correctly in video player - When a video's playback speed is changed, it is meant to reset when a different video is played but doesn't.

What is the root cause of that problem?

We are using a context manager to handle the playback speed for the videos. The issue is when the context manager handles changing the video displayed, it does not reset the video player configuration. In this case, the playback speed

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

The simplest solution here would be to reset the playback speed anytime the video changes. This can be archived by adding an useEffect hook within the context manager to do just that.

    useEffect(() => {
        setCurrentPlaybackSpeed(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS[2]);
    }, [currentlyPlayingURL]);

What alternative solutions did you explore? (Optional)

An alternate and more robust solution would be to have a mapped state of playback speeds linked to video URLs opened on the player.

Here's what the mapper variable would look like const [playbackSpeedMap, setPlaybackSpeedMap] = useState<{ [url: string]: PlaybackSpeed }>({});

What this does is, it helps the application remember and attach different playback speeds to different videos. Thereby, creating a smoother user experience with the player. If a video has never been played, it has the default playback speed, but if it was changed before it will be remembered and set regardless of how many other videos you played after.

@sword1202
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~0194d962e1f9098218

Copy link

melvin-bot bot commented Apr 22, 2024

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@sword1202
Copy link

Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~0194d962e1f9098218
I am not getting invitation on slack channel yet.

Copy link

melvin-bot bot commented Apr 22, 2024

⚠️ Missing/invalid email or upwork profile link. Please make sure you add both your Expensify email and Upwork profile link in the format specified.

@sword1202
Copy link

I sent a request message to your slack email, but no reponse yet.

@hungvu193
Copy link
Contributor

Taking over this as C+ per this discussion

https://expensify.enterprise.slack.com/archives/C02NK2DQWUX/p1713787155736399

Cc @ntdiary

@ntdiary ntdiary removed their assignment Apr 22, 2024
@hungvu193
Copy link
Contributor

@blimpich I want to confirm the expected behavior here, if we change playback speed of Video 1 to 0.25, then we change speed of Video 2 to 0.5. Later when we play Video 1, should its playback speed be 0.25 or it will reset to 1?

@blimpich
Copy link
Contributor

I would expect it to be 0.25

@hungvu193
Copy link
Contributor

A friendly reminder for @shahinyan11 and @KMichel1030: please make sure you both follow the contributing guidelines here. Otherwise, your proposal will be hidden and not reviewed.

@KMichel1030, I noticed you updated your proposal a couple of times right after @shahinyan11 posted his proposal. Your proposal also didn't elaborate on how to implement setCurrentPlaybackSpeed. I'll consider your proposal a duplicate of @shahinyan11's proposal.

Screenshot 2024-04-22 at 23 50 04

@hungvu193
Copy link
Contributor

@Pycomet can you elaborate more about your alternative proposal and how to implement it? Also a demo video will be really helpful. Thank you 😄

@serhii1030
Copy link
Contributor

Proposal

[Updated] (#40646 (comment))

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels Apr 26, 2024
@stephanieelliott
Copy link
Contributor

I'm back from OOO, thanks for watching this while I was out @bfitzexpensify!

This PR is under active review!

@stephanieelliott
Copy link
Contributor

All conflicts are resolved, the PR is just waiting on an approving review.

@stephanieelliott
Copy link
Contributor

Seems like we hit a snag with testing on some platforms, see the PR for discussion on that

@stephanieelliott
Copy link
Contributor

PR merged to main, should hit staging next deploy

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels May 27, 2024
@melvin-bot melvin-bot bot changed the title [$250] Playback speed is not displayed correctly in video player [HOLD for payment 2024-06-03] [$250] Playback speed is not displayed correctly in video player May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label May 27, 2024
Copy link

melvin-bot bot commented May 27, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.75-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-06-03. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented May 27, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@hungvu193] The PR that introduced the bug has been identified. Link to the PR:
  • [@hungvu193] 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:
  • [@hungvu193] A discussion in #expensify-bugs 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:
  • [@hungvu193] Determine if we should create a regression test for this bug.
  • [@hungvu193] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@stephanieelliott] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@serhii1030
Copy link
Contributor

Hi, @stephanieelliott
could you please let me know if can I get paid today?

@stephanieelliott
Copy link
Contributor

Hey @hungvu193 can you please complete the BZ checklist?

@KMichel1030 yes, you can be paid today! I extended an offer to you on Upwork, can you please let me know once you've accepted? Once you do I will issue payment ASAP
https://www.upwork.com/nx/wm/offer/102582520

@serhii1030
Copy link
Contributor

@stephanieelliott
Thank you for offer. I've just accepted offer.

@stephanieelliott
Copy link
Contributor

Summarizing payment on this issue:

  • Contributor: @KMichel1030 $250 via Upwork -- PAID
  • Contributor+: @hungvu193 $250 via Upwork -- PAID

Upwork job is here: https://www.upwork.com/jobs/~1737876297360310272

@hungvu193 hungvu193 mentioned this issue Jun 4, 2024
58 tasks
@hungvu193
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: Video player #30829
  • 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: https://github.com/Expensify/App/pull/30829/files#r1625244663
  • A discussion in #expensify-bugs 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: N/A
  • Determine if we should create a regression test for this bug: Yes

Regression test:

  1. Upload two videos(Video1, Video2).
  2. Play Video1.
  3. Then change playback speed to 0.25 (or any other).
  4. Play Video2.
  5. Verify that playback speed of Video2 (three dot menu -> playback speed) displays correctly.

Do we 👍 or 👎 ?

@melvin-bot melvin-bot bot added the Overdue label Jun 6, 2024
@hungvu193
Copy link
Contributor

We're good to close @stephanieelliott

@stephanieelliott
Copy link
Contributor

Thanks @hungvu193! PR for regression test here: https://github.com/Expensify/Expensify/issues/402935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
No open projects
Archived in project
Development

No branches or pull requests

10 participants