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

Fix video sharing #38407

Conversation

Skalakid
Copy link
Contributor

@Skalakid Skalakid commented Mar 15, 2024

Details

This PR reenables video sharing feature. With these changes videos from inside the chat will be sharing their state with the player that is inside the attachment carousel.

Fixed Issues

$ #36873
PROPOSAL: #36873 (comment)

Tests

Button linking:

  1. Go to prerequisite chat
  2. Play&Pause the video
  3. Tap on the expand button on the video preview
  4. Verify if video player showed there have the same state as the on from chat
  5. Play&Pause the video
  6. Exit from the attachment view via clicking X button top right
  7. Try to Play&Pause the video in preview mode

Window dimension changing:
Web & desktop:

  1. Open video in attachment carousel
  2. Make your app widow smaller
  3. Enter full screen
  4. Exit fullscreen
  5. Verify if video continue playing

Native devices:

  1. Open video in attachment carousel
  2. Enter full screen
  3. Change device orientation
  4. Exit fullscreen
  5. Verify if video continue playing and if app changed layout
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

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

Copy link
Contributor

@Kicu Kicu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to review this and left some of my comments and questions. As I'm not super familiar with the app code yet, maybe some of the questions don't make much sense.

I don't see any huge red flags here. BasePlayer itself has a lot of complex logic in hooks so Im not sure I understand how everything works there - but like I said Im not yet familiar with this.

Left you some naming suggestions and some questions

src/components/VideoPlayerContexts/types.ts Outdated Show resolved Hide resolved
src/components/VideoPlayerContexts/FullScreenContext.tsx Outdated Show resolved Hide resolved
src/components/VideoPlayer/BaseVideoPlayer.js Outdated Show resolved Hide resolved
src/components/VideoPlayer/BaseVideoPlayer.js Outdated Show resolved Hide resolved
src/hooks/useWindowDimensions/index.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@Kicu Kicu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright looks pretty good with my limited knowledge about video player 👍

@Skalakid Skalakid marked this pull request as ready for review March 20, 2024 13:50
@Skalakid Skalakid requested a review from a team as a code owner March 20, 2024 13:50
@melvin-bot melvin-bot bot requested review from ishpaul777 and removed request for a team March 20, 2024 13:50
Copy link

melvin-bot bot commented Mar 20, 2024

@ishpaul777 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@ishpaul777
Copy link
Contributor

@Skalakid Can you please resolve conflicts

@ishpaul777
Copy link
Contributor

nvm, above is not related ⬆️

@ishpaul777
Copy link
Contributor

ishpaul777 commented Mar 22, 2024

bug: Not able to pause video (by clicking on video itself) in full screen it starts playing as soon as i pause

Screen.Recording.2024-03-22.at.5.32.18.PM.mov

@ishpaul777
Copy link
Contributor

ishpaul777 commented Mar 22, 2024

Bug: there's a loading indicator and video restarts when changing windowsize after a breakpoint in attachment carousel

Screen.Recording.2024-03-22.at.5.45.53.PM.mov

bug: video stops playing in chat after a breakpoing in chat

Screen.Recording.2024-03-22.at.5.54.32.PM.mov

Bug?: it takes few second to play video when video timing is backed (it seems it redownloads the video everytime)

Screen.Recording.2024-03-22.at.6.22.57.PM.mov

@ishpaul777
Copy link
Contributor

thats it for now @Skalakid can you address above comments once you got sometime, thank you!

@Skalakid
Copy link
Contributor Author

Skalakid commented Mar 25, 2024

Bug: there's a loading indicator and video restarts when changing window size after a breakpoint in attachment carousel

I don't think it is a bug. Video reloads when changing window size and hitting breakpoint because on small screens, the in-chat video player isn't available and we can't share video elements that don't exit. So it is like natural behaviour because we have to stop sharing video elements and render separate players directly inside the attachment carousel

bug: video stops playing in chat after a breakpoing in chat

Same as above. In-chat video player isn't available on small screen devices. That why we are changing currently playing video to video thumbnail button that opens attachment carousel with the video inside

@Skalakid
Copy link
Contributor Author

Bug?: it takes few second to play video when video timing is backed (it seems it redownloads the video everytime)

Hmm, I think is not related to this PR. The same thing appears on main and probably that how native android player works. It can be connected how our backend returns video to our app. It accepts video ranges and probably Android native video player doesn't load entire file, only parts of it. After some time cached parts of the video are removed.
I will investigate this issue more, however it should block this PR, since it is not connected to it

@Skalakid
Copy link
Contributor Author

@ishpaul777 I've added review changes and answered to you comments, let me know what do you think :D

@Skalakid
Copy link
Contributor Author

@ishpaul777 I resolved conflicts

@ishpaul777
Copy link
Contributor

Thanks, Did breif testing for web desktop, it seems to work well, i'll priortize a full review for tomorrow its EOD for me, sorry!

@Skalakid
Copy link
Contributor Author

Okay, no problem. Thanks

Copy link
Contributor

@ishpaul777 ishpaul777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@melvin-bot melvin-bot bot requested a review from lakchote March 27, 2024 17:34
@lakchote lakchote merged commit 5888c68 into Expensify:main Mar 28, 2024
15 of 17 checks passed
@melvin-bot melvin-bot bot added the Emergency label Mar 28, 2024
Copy link

melvin-bot bot commented Mar 28, 2024

@lakchote looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/lakchote in version: 1.4.58-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@lakchote
Copy link
Contributor

lakchote commented Apr 1, 2024

Not an emergency, reviewer has completed all the checklist boxes. Removing label.

@lakchote lakchote removed the Emergency label Apr 1, 2024
@OSBotify
Copy link
Contributor

OSBotify commented Apr 2, 2024

🚀 Deployed to production by https://github.com/Beamanator in version: 1.4.58-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

// update shared video elements
useEffect(() => {
if (shouldUseSharedVideoElement || url !== currentlyPlayingURL) {
if (shouldUseSharedVideoElement || url !== currentlyPlayingURL || isFullScreenRef.current) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Skalakid I wonder why do we need to add isFullScreenRef.current?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isFullScreenRef is responsible for locking the video player when screen orientation changes in full-screen mode. It prevents video players from changing their state because of device rotation or window size changes. Changing state causes the full screen to dismiss. We need it here to block updating currently shared video element

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me reproduce the bug if we remove isFullScreenRef.current? Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @Skalakid
I'm also curious about test steps that cause unexpected errors when we remove isFullScreenRef.current.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to remove isFullScreenRef.current only in this useEffect if statement.

Copy link
Contributor

@jacobnguyen0000 jacobnguyen0000 May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Skalakid
Thank you for your confirm. I can't reproduce on my end.
Could you please let me know if this issue is reproducible on native devices?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed again, it's not reproducible on my end.

Copy link
Contributor Author

@Skalakid Skalakid May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to remove isFullScreenRef.current only in this useEffect if statement.

@tienifr oh thanks for information, in the video above I deleted isFullScreenRef in whole BaseVideo Player file 😅 So if it works after deleting isFullScreenRef.current in useEffect, just do the test steps from this issue description and if everything works you can remove it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Skalakid
thank you for your check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants