-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 multiple console errors when login and in onboarding welcome video #46854
Fix multiple console errors when login and in onboarding welcome video #46854
Conversation
@hoangzinh 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] |
I can finally repro On Android mWeb, the error is |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-08-08.at.16.44.52.android.movAndroid: mWeb ChromeScreen.Recording.2024-08-08.at.16.58.04.android.chrome.moviOS: NativeScreen.Recording.2024-08-08.at.17.21.08.ios.moviOS: mWeb SafariScreen.Recording.2024-08-08.at.17.23.19.ios.safari.movMacOS: Chrome / SafariScreen.Recording.2024-08-08.at.16.03.13.web.movMacOS: DesktopScreen.Recording.2024-08-08.at.16.10.34.desktop.mov |
}, [stopVideo, unloadVideo]); | ||
|
||
useEffect(() => { | ||
if (!currentReportID) { | ||
if (!currentReportID || !prevCurrentReportID || currentReportID === '-1' || prevCurrentReportID === '-1') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bernhardoj it appears that you applied 2 solutions in your proposal or error 7th , didn't you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The first one waits until the play promise is completed. But on Android mWeb (if I remember the platform correctly), the play is never triggered anymore after the video is stopped. So,
- play is called
- resetVideoPlayer is called because currentReportID changes from an empty string to something
- There is no play called anymore like in other platforms, so the video is completely stopped and (ref) cleared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @bernhardoj do you mean the checking isPlaying
in 1st option is not useful in Android mWeb? Or does it never return isPlaying
status in Android mWeb?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, at this line only (not this error log), we only need to check !currentReportID || currentReportID === '-1'
is enough, what do you think? And do you think we should make -1
as a constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, what I mean is that, when we open the video, the play video is called multiple times.
App/src/components/VideoPlayerContexts/PlaybackContext.tsx
Lines 28 to 36 in 8193c37
const playVideo = useCallback(() => { | |
currentVideoPlayerRef.current?.getStatusAsync?.().then((status) => { | |
const newStatus: AVPlaybackStatusToSet = {shouldPlay: true}; | |
if ('durationMillis' in status && status.durationMillis === status.positionMillis) { | |
newStatus.positionMillis = 0; | |
} | |
currentVideoPlayerRef.current?.setStatusAsync(newStatus); | |
}); | |
}, [currentVideoPlayerRef]); |
And then resetVideoPlayerData
is also called once. On other platforms, the order of call looks like this:
In mWeb Android, it's
play
play
...
reset
[no more call]
But I just retested it and the call order is similar to other platforms too.
we only need to check !currentReportID || currentReportID === '-1' is enough, what do you think?
Still, we need to prevent the reset to be called, so we need to check for prevCurrentReportID
too.
And do you think we should make -1 as a constant?
I don't have a strong opinion about this one. There is -1 and '-1' and we use this everywhere on the app without const. Maybe we can have a new cleanup issue to create the const and replace it everywhere in the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay cool. Can you leave a comment explaining why we have to check both current and prev, also another comment in line 79? I think it's useful to back-read later.
(playVideoPromiseRef.current ?? Promise.resolve()).then(stopVideo).finally(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bernhardoj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Lint is failing. |
@puneetlath oops, lint fixed |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
FYI I believe this was deployed to prod yesterday, from this checklist - #47219 |
Details
This PR is fixing multiple console errors when login and in onboarding welcome video page.
Fixed Issues
$ #45619
PROPOSAL: #45619 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
TypeError: Cannot read properties of undefined (reading 'routes')
error in the consolestaging.new.expensify.com/onboarding/welcome-video
.Unexpected text node.
validateDOMNesting(...): cannot appear as a descendant of ...
play() failed because the user didn't interact with the document first.
The play() request was interrupted by a call to pause().
Verify that no errors appear in the JS console
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mweb.1.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4