-
Notifications
You must be signed in to change notification settings - Fork 3k
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-20] [$250] Start chat - Uh-oh something went wrong displayed when tapping room and going back #42824
Comments
Triggered auto assignment to @johncschuster ( |
We think this issue might be related to the #vip-vsb |
ProposalPlease re-state the problem that we are trying to solve in this issue.App crashes when going back from new room page while keyboard is showing. What is the root cause of that problem?I can't find the real root cause of the issue, but the crash is because we are calling the set state "infinitely" reaching the max update. App/src/hooks/useAutoFocusInput.ts Lines 50 to 53 in f26c9f5
This only happens if the keyboard is showing while we close the page. Also, if we remove the useIsFocused hook, then the issue is gone.
What changes do you think we should make in order to solve the problem?If the ref is already set, return early. App/src/hooks/useAutoFocusInput.ts Lines 50 to 53 in f26c9f5
|
Job added to Upwork: https://www.upwork.com/jobs/~012c83bbe79ba0af18 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jayeshmangwani ( |
@bernhardoj Your proposal will solve the crash tested, but I am trying to understand why it is happening for the only WorkspaceNewRoomPage, I am testing different variations on the other pages where we are using the inputCallbackRef, but not able to reproduce this crash for other pages, curious whats the cause for the WorkspaceNewRoomPage only and not others. |
Bringing my proposal from #42916 since this has similar root causes ProposalPlease re-state the problem that we are trying to solve in this issue.Show error when access starts to chat 2nd time in off-mode What is the root cause of that problem?In App/src/hooks/useAutoFocusInput.ts Line 52 in 1d5f83d
isInputInitialized is false first before setting it to true . So there're too many unnecessary rerendering of the hook that causes the crash.
What changes do you think we should make in order to solve the problem?Check App/src/hooks/useAutoFocusInput.ts Line 52 in 1d5f83d
This can be further polished by using After the crash is fix, we'll face another issue: when trying to create the room the second time, the modal will be automatically dismissed, the root cause is in
loading state is initially true , it already causes the modal to be dismissed in here, before the "clear isLoading" useEffect finishes running.
This can be fixed by clearing the
Or clearing whenever we call What alternative solutions did you explore? (Optional)For the crash issue, we could also early return here App/src/hooks/useAutoFocusInput.ts Line 50 in 1d5f83d
inputRef was already set
For the modal dismissing issue, we can remove this block and the related error clearing logic entirely. They were meant to support the use case that there's a duplicate room name error thrown from the back-end, but we have the front-end validation logic for that in
And we already have the App/src/libs/actions/Report.ts Line 2102 in 1d5f83d
|
If you add |
@dominictb main thing that I am not able to understand is why |
yes that's confuses me, why it is not happening for only inputCallbackRef but happens if we have used the useIsFocused, so it brings me question do we really fixing the root cause here or we are just adding band aid to the real fix |
Seems it's related to react bailing out of a state update, and stack overflow here.
But I'm still confused why |
ProposalPlease re-state the problem that we are trying to solve in this issue.When offline, open new room page may cause app crashing What is the root cause of that problem?The apparent cause is this line is called indefinitely App/src/hooks/useAutoFocusInput.ts Line 52 in f26c9f5
But the root cause is that a loop is running. const [foo, setFoo] = useState(true);
...
setFoo(true); inside a react function component, the function component will loop forever. Refer this stack overflow answer for details. Similar code line happens in @react-navigation/core here in our project. The loop of this issue is:
What changes do you think we should make in order to solve the problem?We should patch package @react-navigation/core here to: React.useEffect(() => {
if (isFocused !== valueToReturn) {
// If the value has changed since the last render, we need to update it.
// This could happen if we missed an update from the event listeners during re-render.
// React will process this update immediately, so the old subscription value won't be committed.
// It is still nice to avoid returning a mismatched value though, so let's override the return value.
// This is the same logic as in https://github.com/facebook/react/tree/master/packages/use-subscription
setIsFocused(valueToReturn);
}
}, [isFocused, valueToReturn]); Besides, we should report a bug to @react-navigation, and we should change App/src/hooks/useAutoFocusInput.ts Line 52 in f26c9f5
to if (isInputInitialized) {
return;
}
setIsInputInitialized(true); like other proposals said for code robust reason. What alternative solutions did you explore? (Optional)N/A |
I don't agree with the root cause here as Issue can be reproduced online too, And if you found that issue is from the navigation package then raise an issue to the navigation repo with minimal reproduction steps/Or any outstanding issues that confirms issue is from the package ? |
@jayeshmangwani Hi, the expression "When offline, a page re-render is triggered" is actually proper for #42916, which has same root cause with this issue. Sorry for my oversight, I will amend my proposal later. Except part "When offline, a page re-render is triggered", the other part should be proper. Sorry again. I will try to raise an issue to the navigation package repo with minimal reproduction steps tomorrow (if I have the bandwidth) |
To confirm my root cause explanation, after install package with
if (isFocused !== valueToReturn) {
// If the value has changed since the last render, we need to update it.
// This could happen if we missed an update from the event listeners during re-render.
// React will process this update immediately, so the old subscription value won't be committed.
// It is still nice to avoid returning a mismatched value though, so let's override the return value.
// This is the same logic as in https://github.com/facebook/react/tree/master/packages/use-subscription
setIsFocused(valueToReturn);
} to React.useEffect(() => {
if (isFocused !== valueToReturn) {
// If the value has changed since the last render, we need to update it.
// This could happen if we missed an update from the event listeners during re-render.
// React will process this update immediately, so the old subscription value won't be committed.
// It is still nice to avoid returning a mismatched value though, so let's override the return value.
// This is the same logic as in https://github.com/facebook/react/tree/master/packages/use-subscription
setIsFocused(valueToReturn);
}
}, [isFocused, valueToReturn]);
import useIsFocused from '@react-navigation/core/src/useIsFocused';
|
Thanks for the investigation @badeggg , And yes I applied these changes to useIsFocused.tsx file and Issue disappeared, So I would agree that root cause for this issue can be from the @react-navigation/core, @badeggg Can you please raise the Issue Upstream to double check and also to see what will the side effect of the adding the useEffect for setIsFocused ? @badeggg 's RCA makes sense here, we can go with the any of their suggestion, Either to fix upstream OR adding the check Note: Proposal of @bernhardoj: Return early if inputRef.current value is set also fix this crash issue but root cause was unclear that's why going with other proposal 🎀 👀 🎀 C+ reviewed |
Triggered auto assignment to @blimpich, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
📣 @badeggg 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Thanks for the issue raising upstream |
Discussing the upstream bug here, seems I have to provide a minimal exact reproducible example to be convincible enough. I am working on that. |
I have made pull request. It's an edge case and kind difficult to trigger I didn't patch the @react-navigation/core package, since I met this error |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.82-4 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-20. 🎊 For reference, here are some details about the assignees on this issue:
|
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:
|
Will be paying this out on the 20th if there are no regressions. @jayeshmangwani, can you complete the BZ Checklist above before then? Thank you! |
Regression Test Proposal
Do we agree 👍 or 👎 |
Payment Summary:Contributor: @badeggg - $250 - paid via Upwork |
Requested on NewDot |
$250 approved for @jayeshmangwani |
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.77-0
Reproducible in staging?: Y
Reproducible in production?: Y
Found when executing PR : #42257
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team
Action Performed:
Expected Result:
User is returned to the LHN
Actual Result:
The "Uh-oh something went wrong" screen is displayed
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Bug6495508_1717013855356.IMG_7234.mp4
ios logs.txt
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @johncschusterThe text was updated successfully, but these errors were encountered: