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

[$250] DEV: Investigate the console errors that show up after signing in #45619

Closed
6 tasks
youssef-lr opened this issue Jul 17, 2024 · 38 comments
Closed
6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review

Comments

@youssef-lr
Copy link
Contributor

youssef-lr commented Jul 17, 2024

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:
Reproducible in staging?:
Reproducible in production?:
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:
Slack conversation:

Action Performed:

  1. Sign in to NewDot locally

Expected Result:

Ideally, no error should be shown in the console.

Actual Result:

Many console errors show up and they are distracting, it's hard to know which one of them is causing a UI issue.

As of now here are the errors I'm seeing:

Screenshot 2024-07-17 at 18 01 22 Screenshot 2024-07-17 at 18 01 29

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

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

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b447136e274124b6
  • Upwork Job ID: 1813619813398356556
  • Last Price Increase: 2024-07-31
  • Automatic offers:
    • hoangzinh | Reviewer | 103403426
Issue OwnerCurrent Issue Owner: @hoangzinh
@youssef-lr youssef-lr added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jul 17, 2024
@melvin-bot melvin-bot bot changed the title DEV: Investigate the console errors that show up after signing in [$250] DEV: Investigate the console errors that show up after signing in Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

Job added to Upwork: https://www.upwork.com/jobs/~01b447136e274124b6

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jul 17, 2024
Copy link

melvin-bot bot commented Jul 17, 2024

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

Copy link

melvin-bot bot commented Jul 17, 2024

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

@mosesbabu
Copy link

Please re-state the problem that we are trying to solve in this issue.
Investigate the console errors that show up after signing in

What is the root cause of that problem?
1.the View components may have plain text is directly inside them will check Wrap all text with Text components.
2.some libraries are using deprecated methods like findDOMNode will check and update them
What changes do you think we should make in order to solve the problem?

  1. will check Wrap all text with Text components.
  2. will check libraries using depreciated methods such as findDOMNode and update them

@hoangzinh
Copy link
Contributor

Hi @mosesbabu can you format your proposal same as PROPOSAL_TEMPLATE here? Besides that, the root cause needs to be more details and clearly point out which is causing the issue. Thank you.

@mosesbabu
Copy link

ok noted doing so right now. was asking if the issue is not yet assigned as well thank you

@hoangzinh
Copy link
Contributor

yep, it is still open for proposals

@mosesbabu
Copy link

mosesbabu commented Jul 18, 2024

Proposal

i recreated the error locally there are more errors as well on the console apart from these can check them as well

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

Investigate the console errors that show up after signing in

What is the root cause of that problem?

The RCA was not how react handled the routes but this is fixed

  • Fixed

Screenshot from 2024-07-18 21-57-29

  • In progress
    Screenshot from 2024-07-18 21-58-10
    caused by findDomNode being depreciated in StrictMode

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

Screenshot from 2024-07-18 21-57-29
Verify that objects from which are reading properties are not undefined.
Add null or undefined checks before accessing properties
Screenshot from 2024-07-18 21-58-10
Ensure findDOMNode is not used directly.
Update any libraries that rely on findDOMNode to their latest versions

What alternative solutions did you explore? (Optional)

there are so many other errors i can clear them all if hired
Screenshot from 2024-07-20 04-19-26
Screenshot from 2024-07-20 04-19-47
Screenshot from 2024-07-20 04-20-08
Screenshot from 2024-07-20 04-20-27

@hoangzinh
Copy link
Contributor

It looks better @mosesbabu, but next time, you don't need to post a new proposal, just update the existing one.

This error occurs when trying to access the routes property of an undefined object.

Can you elaborate more on it in your RCA? Which line of code caused this error? How can it happen? In RCA, we have to describe the root cause in detail as much as possible.

Copy link

melvin-bot bot commented Jul 22, 2024

@puneetlath, @hoangzinh Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Jul 22, 2024
@hoangzinh
Copy link
Contributor

@mosesbabu is your proposal ready for the next review? If yes, please post a new comment according to step 7 of the guidelines https://github.com/Expensify/App/blob/main/contributingGuides/CONTRIBUTING.md#propose-a-solution-for-the-job

@melvin-bot melvin-bot bot removed the Overdue label Jul 24, 2024
@mosesbabu
Copy link

mosesbabu commented Jul 24, 2024

Yes it's ready for review apologies this is my first time with expensify am I supposed to first fix the error or wait to be hired first

Copy link

melvin-bot bot commented Jul 24, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@hoangzinh
Copy link
Contributor

hoangzinh commented Jul 24, 2024

No worry @mosesbabu.

caused by findDomNode being depreciated in StrictMode

Your RCA is still not clear to me. Can you point out exactly which line of codes in Expensify/App repo or libraries that cause this error? Thank you.

@mosesbabu
Copy link

mosesbabu commented Jul 24, 2024

@hoangzinh The findDOMNode being depreciated error arises from this specific library is react-native-gesture-handler library in react not anywhere in the code as app is running on strictMode shows that its depreciated to fix is by using refs in componetts raising the error example component is :src/components/Pressable/GenericPressable/BaseGenericPressable.tsx however a depreciated warning doesnt keep app from running

@hoangzinh
Copy link
Contributor

hoangzinh commented Jul 25, 2024

to fix is by using refs in componetts raising the error example component is :src/components/Pressable/GenericPressable/BaseGenericPressable.tsx

Cool. Can you share more details on how you would fix it in the BaseGenericPressable component?

@bernhardoj
Copy link
Contributor

bernhardoj commented Jul 29, 2024

Proposal

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

A few console error.

What is the root cause of that problem?

If we look at the video play() error stacktrace image, we can see that it's coming from the onboarding video. If you open /onboarding/welcome-video, then you will all the errors + other errors that doesn't show in the OP, except the routes error (the routes error only show when loggin in). Here is the explanation of each error:

  1. Warning: findDOMNode is deprecated in StrictMode
    This error comes from react-native-gesture-handler and needs to be fixed on the upstream repo.

  2. Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code
    This error comes from react-native-animatable and needs to be fixed on the upstream repo.

  3. TypeError: Cannot read properties of undefined (reading 'routes')
    The getState() in resetHomeRouteParams is undefined.

    function resetHomeRouteParams() {
    Navigation.isNavigationReady().then(() => {
    const routes = navigationRef.current?.getState().routes;

We previously have this kind of issue too in #37194.

  1. Unexpected text node.
    This means there is a text rendered without a <Text> component. This erro comesfrom FeatureTrainingModal where we conditionally render a component based on a string value, but if it's empty, then '' is rendered.

    {helpText && (
    <Button
    large
    style={[styles.mb3]}
    onPress={onHelp}
    text={helpText}
    />
    )}

  2. validateDOMNesting(...): cannot appear as a descendant of .
    This means there is a nested button. This comes from BaseVideoPlayer where Pressable is inside another Pressable.

    {/* We need to wrap the video component in a component that will catch unhandled pointer events. Otherwise, these
    events will bubble up the tree, and it will cause unexpected press behavior. */}
    <PressableWithoutFeedback
    accessibilityRole="button"
    accessible={false}
    style={[styles.cursorDefault, style]}
    >
    <Hoverable shouldFreezeCapture={isPopoverVisible}>
    {(isHovered) => (
    <View style={[styles.w100, styles.h100]}>
    <PressableWithoutFeedback
    accessibilityRole="button"
    accessible={false}
    onPress={() => {
    if (isFullScreenRef.current) {
    return;
    }
    togglePlayCurrentVideo();

The code above is to fix #36906.

  1. play() failed because the user didn't interact with the document first.
    The onboardoing video is auto-played, but the browser doesn't allow that without the user interacting first, except if the video is muted (read more here.

We mute the volume here initially, but not immediately.

const volume = useSharedValue(0);
const updateVolume = useCallback(
(newVolume: number) => {
if (!currentVideoPlayerRef.current) {
return;
}
currentVideoPlayerRef.current.setStatusAsync({volume: newVolume, isMuted: newVolume === 0});
// eslint-disable-next-line react-compiler/react-compiler
volume.value = newVolume;
},
[currentVideoPlayerRef, volume],
);
// We want to update the volume when currently playing video changes.
// When originalParent changed we're sure that currentVideoPlayerRef is updated. So we can apply the new volume.
useEffect(() => {
if (!originalParent) {
return;
}
updateVolume(volume.value);
}, [originalParent, updateVolume, volume.value]);

  1. The play() request was interrupted by a call to pause().
    This is explained in https://developer.chrome.com/blog/play-request-was-interrupted. play() is async and if a pause is called before the play() is resolved, the error is thrown. In our case, the currentReportID is changed from an empty string to the topmost reportID that triggers resetVideoPlayerData() which calls stopVideo().

useEffect(() => {
if (!currentReportID) {
return;
}
resetVideoPlayerData();
}, [currentReportID, resetVideoPlayerData]);

const resetVideoPlayerData = useCallback(() => {
videoResumeTryNumberRef.current = 0;
stopVideo();

  1. The play() request was interrupted because the media was removed from the document
    Can't reproduce it anymore.

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

  1. Add null safety when accessing the state
const routes = navigationRef.current?.getState()?.routes;
  1. Use !! to check the text.
{!!title && !!description && <.../>}
...
{!!helpText && <.../>}
  1. Remove the accessibilityRole so it's rendered as a div

    <PressableWithoutFeedback
    accessibilityRole="button"

  2. Immediately mute the video when mounted in BaseVideoPlayer

useEffect(() => {
    videoPlayerRef.current?.setStatusAsync({volume: 0});
}, []);
  1. Two ways to solve this.
    First, only stop the video if the video is playing.
checkVideoPlaying((isPlaying) => {
    videoResumeTryNumberRef.current = 0;
    if (isPlaying) {
        stopVideo();
    }
    setCurrentlyPlayingURL(null);
    ... // rest
});

Or, store the previous currentReportID

const prevCurrentReportID = usePrevious(currentReportID);

and don't call resetVideoPlayerData if the prevCurrentReportID is empty. This way, if the currentReportID is set for the first time, we won't call resetVideoPlayerData and it will only be called if the currentReportID is really changed (instead of being triggered from empty string to the topmost report ID).

if (!currentReportID || !prevCurrentReportID) {
    return;
}
resetVideoPlayerData();

@melvin-bot melvin-bot bot added the Overdue label Jul 29, 2024
@puneetlath
Copy link
Contributor

Thoughts @hoangzinh?

Copy link

melvin-bot bot commented Jul 30, 2024

@puneetlath, @hoangzinh Huh... This is 4 days overdue. Who can take care of this?

@hoangzinh
Copy link
Contributor

Hi @puneetlath, the first 2 warnings in RCA of @bernhardoj's proposal #45619 (comment) they're only in strict mode and need to be fixed in upstream repos (Warning: findDOMNode and Warning: Using UNSAFE_componentWillReceiveProps). Do you think we should fix it or can leave it there?

@bernhardoj
Copy link
Contributor

bernhardoj commented Aug 1, 2024

I tried to apply your suggestion but it didn't work. Can you share exactly the component/where we should set mute for the player?

You can put the code in BaseVideoPlayer. I have added this info to my proposal.

I couldn't reproduce this error. Are you still able to reproduce it?

After retesting, the app is lagging before the video shows and I can't reproduce it. But after muting the video immediately, the app runs smoother and I can reproduce the issue again.

@hoangzinh
Copy link
Contributor

Oh, you're right. Let's wait for @puneetlath thoughts on #45619 (comment)

@puneetlath
Copy link
Contributor

Let's focus on fixing the ones that can be handled on our side for now in this issue.

@hoangzinh
Copy link
Contributor

Thanks @puneetlath. @bernhardoj proposal looks good to me.

Link to proposal #45619 (comment)

🎀👀🎀 C+ reviewed

Copy link

melvin-bot bot commented Aug 3, 2024

Current assignee @puneetlath is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Aug 5, 2024
Copy link

melvin-bot bot commented Aug 5, 2024

📣 @hoangzinh 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

@bernhardoj
Copy link
Contributor

PR is ready

cc: @hoangzinh

@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Aug 29, 2024
Copy link

melvin-bot bot commented Aug 29, 2024

This issue has not been updated in over 15 days. @puneetlath, @hoangzinh, @bernhardoj eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@puneetlath
Copy link
Contributor

I think we're good to pay this one out. @hoangzinh can you complete the checklist?

@hoangzinh
Copy link
Contributor

Sure, I will complete the checklist today

@hoangzinh
Copy link
Contributor

hoangzinh commented Sep 2, 2024

BugZero Checklist:

Console error 3rd: TypeError: Cannot read properties of undefined (reading 'routes')
Console error 4th: Unexpected text node
Console error 5th: validateDOMNesting(...): cannot appear as a descendant of
Console error 6th: play() failed because the user didn't interact with the document first
Console error 7th: The play() request was interrupted by a call to pause()

@hoangzinh
Copy link
Contributor

hoangzinh commented Sep 2, 2024

I think we're good to pay this one out. @hoangzinh can you complete the checklist?

BZ checklist is complete , @puneetlath

@puneetlath
Copy link
Contributor

Payment summary:

Thanks everyone!

@bernhardoj
Copy link
Contributor

Requested in ND.

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review
Projects
Development

No branches or pull requests

6 participants