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

LOW: [$500] Unread notification in fevicon does not update when the user is in another tab #32225

Closed
1 of 6 tasks
m-natarajan opened this issue Nov 29, 2023 · 52 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Engineering Internal Requires API changes or must be handled by Expensify staff retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause Weekly KSv2

Comments

@m-natarajan
Copy link

m-natarajan commented Nov 29, 2023

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: 1.4.5.3
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: @iwiznia
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1701197419116139

Action Performed:

  1. Open staging.new.expensify.com and login
  2. Open 2nd tab
  3. Send a message from another device
  4. Observe the fevicon in tab 1 where account A logged in

Expected Result:

Should update the fevicon notification count

Actual Result:

Notification count updates only when clicking the tab 1

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

Recording.274.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~013669a17c30bfb662
  • Upwork Job ID: 1729978850198351872
  • Last Price Increase: 2023-12-06
  • Automatic offers:
    • situchan | Contributor | 28044342
@m-natarajan m-natarajan 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 Nov 29, 2023
Copy link

melvin-bot bot commented Nov 29, 2023

Triggered auto assignment to @adelekennedy (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@melvin-bot melvin-bot bot changed the title Unread notification in fevicon does not update when the user is in another tab [$500] Unread notification in fevicon does not update when the user is in another tab Nov 29, 2023
Copy link

melvin-bot bot commented Nov 29, 2023

Job added to Upwork: https://www.upwork.com/jobs/~013669a17c30bfb662

Copy link

melvin-bot bot commented Nov 29, 2023

Bug0 Triage Checklist (Main S/O)

  • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
  • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
    • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
  • This bug is reproducible using the reproduction steps in the OP. S/O
    • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
    • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
  • This issue is filled out as thoroughly and clearly as possible
    • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
  • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Nov 29, 2023
Copy link

melvin-bot bot commented Nov 29, 2023

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

@iwiznia
Copy link
Contributor

iwiznia commented Nov 29, 2023

@vjurcutiu
Copy link

vjurcutiu commented Nov 29, 2023

Proposal

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

The favicon does not update when a message is received in another tab.

What is the root cause of that problem?

In updateUnread/index.website.js we use a setTimeout function, which is no longer necessary after the change specified by @iwiznia.

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

Remove the setTimeout function.
POC:

POC.-.favicon.mp4

What alternative solutions did you explore? (Optional)

@iwiznia
Copy link
Contributor

iwiznia commented Nov 29, 2023

I am confused, I see the setTimeout, is the setTimeout call never firing? And if so, why?

@vjurcutiu
Copy link

I don't know exactly. I assumed that since InteractionManager returns a promise, setTimeout was no longer needed, and that fixed it.

@ZhenjaHorbach
Copy link
Contributor

I don't think they just added it)

// This setTimeout is required because due to how react rendering messes with the DOM, the document title can't be modified synchronously, and we must wait until all JS is done
// running before setting the title.

@vjurcutiu
Copy link

Yeah, but it was added before the InteractionManager change, right? It seems like a hack to simulate an asynchronous load. Since InteractionManager returns a promise, setTimeout was no longer needed. I know that setTimeout is in a different part of the event loop than a promise, so maybe somewhere along the way it gets tangled up.

@tienifr
Copy link
Contributor

tienifr commented Nov 30, 2023

Proposal

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

Unread notification in fevicon does not update when the user is in another tab

What is the root cause of that problem?

When the new message come to App, we will create the new action component. This component uses BaseTooltip, and onHoverOut callback is triggered immediately because we don't hover on that component.

-> Animated.timing().start() is triggered here

In the detail implementation of RNW, we use requestAnimationFrame, and this function intentionally pauses in the background. Ref: https://stackoverflow.com/questions/46765937/run-requestanimationframe-in-background

https://github.com/necolas/react-native-web/blob/a3ea2a0a4fd346a1b32e6cef527878c8e433eef8/packages/react-native-web/src/vendor/react-native/Animated/animations/TimingAnimation.js#L129-L131

In here

InteractionManager.runAfterInteractions(() => {

we just update unread count after all animations complete

-> We can see the updated unread count when back to the main device

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

It doesn't make sense when running hideTooltip even when it never shows up. So we can avoid that by adding didHover value in Hoverable

    const didHover = useRef(false);

update didHover in here

            if(hovered && !didHover.current){
                didHover.current=true
            }

then update this condition to

        if (onHoverOut && !isHovered && didHover.current) {

Result

Screen.Recording.2023-11-30.at.17.20.08.mp4

@melvin-bot melvin-bot bot added the Overdue label Dec 2, 2023
@adelekennedy
Copy link

@hurali97 bump on the request above!

@melvin-bot melvin-bot bot removed the Overdue label Dec 4, 2023
Copy link

melvin-bot bot commented Dec 6, 2023

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

@mananjadhav
Copy link
Collaborator

Apologies for the delay here. I was out sick few days. I don't think we should be removing the setTimeout and neither did the solution worked for me.

@tienifr's solution did work for me, but I am trying to understand was this something that stopped working recently and do we have a linked commit that caused this?

I also noticed that the latest change was made by this PR last week by @allroundexperts, but even after reverting that, the issue is still reproducible.

@iwiznia Are you aware if this was working previously and recently stopped working?

@tienifr
Copy link
Contributor

tienifr commented Dec 7, 2023

@mananjadhav After removing runAfterInteractions in this PR, I can't reproduce, but I don't know why the author remove this . I'm asking in here

@hurali97
Copy link
Contributor

hurali97 commented Dec 7, 2023

@tienifr If I understand correctly, the issue is resolved after this PR but we don't know why the author removed runAfterInteractions, correct?

@tienifr
Copy link
Contributor

tienifr commented Dec 7, 2023

@hurali97 Yes

@iwiznia
Copy link
Contributor

iwiznia commented Dec 7, 2023

@iwiznia Are you aware if this was working previously and recently stopped working?

I don't know if this was working because I've been stuck between this bug and #31276

@quinthar quinthar moved this to MEDIUM in [#whatsnext] #vip-vsb Dec 7, 2023
@quinthar quinthar changed the title [$500] Unread notification in fevicon does not update when the user is in another tab MEDIUM: [$500] Unread notification in fevicon does not update when the user is in another tab Dec 8, 2023
@kaushiktd
Copy link
Contributor

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

Unread notification in fevicon does not update when the user is in another tab

What is the root cause of that problem?

The issue occurs because of stemming from the condition if (onHoverOut && !isHovered) triggering onHoverOut erroneously when isHovered becomes false. This condition needs a refinement to ensure that onHoverOut is only called when a hover event had previously occurred (isHovered was true), rather than simply when isHovered becomes false.

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

https://github.com/Expensify/App/blob/main/src/components/Hoverable/index.tsx#L54

const [hasHovered, setHasHovered] = useState(false);

replace this code 
https://github.com/Expensify/App/blob/d565caa4c62ae23004ed2e4b13b7233259d75d2e/src/components/Hoverable/index.tsx#L133

   useEffect(() => {
       

        if (disabled) {
            return;
        }

        if (onHoverIn && isHovered) {
            return onHoverIn();
        }

        if (onHoverOut && !isHovered && hasHovered) {
            return onHoverOut();
        }
    }, [disabled, isHovered, onHoverIn, onHoverOut, hasHovered]);

In essence, hasHovered acts as a flag to determine whether a hover event has occurred at least once. If hasHovered is true and the current isHovered state becomes false, it will trigger the onHoverOut() callback, indicating that a hover-out event happened after a previous hover-in event.

Video:-

https://drive.google.com/file/d/1g-GuLQ2uRzgD0PVTgOm8FgJ1WuD8QwDx/view?usp=sharing

Copy link

melvin-bot bot commented Dec 29, 2023

@adelekennedy, @situchan 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

Copy link

melvin-bot bot commented Jan 2, 2024

@adelekennedy, @situchan 12 days overdue now... This issue's end is nigh!

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jan 5, 2024
Copy link

melvin-bot bot commented Jan 5, 2024

This issue has not been updated in over 14 days. @adelekennedy, @situchan eroding to Weekly issue.

@melvin-bot melvin-bot bot removed the Overdue label Jan 5, 2024
@adelekennedy
Copy link

@situchan one new proposal to review above

@melvin-bot melvin-bot bot removed the Overdue label Jan 15, 2024
@situchan
Copy link
Contributor

@kaushiktd Hoverable is base component. Please do thorough testing to make sure there's no regression.

@kaushiktd
Copy link
Contributor

@situchan Yes I tested it and then only sent proposal. 🙂

@quinthar
Copy link
Contributor

Hi there, what's the status of this? What's next, who's doing it, and when will it be done?

@quinthar quinthar moved this from MEDIUM to LOW in [#whatsnext] #vip-vsb Jan 22, 2024
@quinthar quinthar changed the title MEDIUM: [$500] Unread notification in fevicon does not update when the user is in another tab LOW: [$500] Unread notification in fevicon does not update when the user is in another tab Jan 22, 2024
@adelekennedy
Copy link

conversation started here on bringing on an agency or reassigning

@situchan
Copy link
Contributor

@kaushiktd your proposal is deprecated after #33257. Can you please update proposal accordingly?

@kaushiktd
Copy link
Contributor

@situchan The new code seems to be fixing this issue. It is not reproducible on my end.

@melvin-bot melvin-bot bot added the Overdue label Jan 24, 2024
@adelekennedy
Copy link

this seems like a great time to try the retest weekly label

@melvin-bot melvin-bot bot removed the Overdue label Jan 25, 2024
@adelekennedy adelekennedy added the retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause label Jan 25, 2024
@melvin-bot melvin-bot bot added the Overdue label Feb 2, 2024
@quinthar
Copy link
Contributor

quinthar commented Feb 5, 2024

@adelekennedy can you re-test to see if this is still the case?

@adelekennedy
Copy link

can't reproduce - closing this

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. Engineering Internal Requires API changes or must be handled by Expensify staff retest-weekly Apply this label if you want this issue tested on a Weekly basis by Applause Weekly KSv2
Projects
No open projects
Status: CRITICAL
Development

No branches or pull requests