You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[$500] Android - Compose box -App crashes on sending message in offline while page is loading #30685
Version Number: 1.3.94-0 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: Applause-Internal Team Slack conversation: @
Action Performed:
Launch app
Tap profile icon--preferences
Toggle on forced offline
Navigate back to LHN
Tap on a admin page with no activity and loading (or any page which is loading)
Send a message
Expected Result:
App must not crash on sending message in offline while page is loading.
Actual Result:
App crashes on sending message in offline while page is loading.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
changed the title [-]Android - Compose box -App crashes on sending message in offline while page is loading[/-][+][$500] Android - Compose box -App crashes on sending message in offline while page is loading[/+]on Nov 1, 2023
Please re-state the problem that we are trying to solve in this issue.
App crashes on sending message in offline while page is loading.
What is the root cause of that problem?
In here, the flatListRef is not initialized yet, but we're calling scrollToOffset on the flatListRef.current which is undefined, causing the crash. flatListRef is not initialized at the beginning because at that time there's no item in the list yet, there's only the loading skeleton. Only after the first message is sent, there'll be item in the list and the ref will have value.
What changes do you think we should make in order to solve the problem?
We need to check that flatListRef?.current is truth first before calling scrollToOffset. This will not cause any issue because at the time we send the first message, the list is already at the bottom so no need to scroll to bottom.
What alternative solutions did you explore? (Optional)
We need to check all the places that flatListRef is used and apply the same fix if it's also not checking truthy.
Alternatively, we can import the useReportScrollManager and use the scrollToBottom method from there, which already has the truthy check.
flatListRef is the ref of the chat list component (ReportActionsList). The problem is, while the report page is loading, we render the skeleton loader view, so the list ref isn't set yet.
What changes do you think we should make in order to solve the problem?
Actually, we already have an existing logic to scroll to the bottom every time the user adds a new message using reportScrollManager.scrollToBottom() that already handles the null/undefined safety.
The scroll there was added for a reason, removing it will cause regressions, also it's not the root cause of this issue. I'd say let's fix this bad crash now on the correct root cause.
There's a plan to address the timeout as a follow up here so we don't need to worry about that unrelated part in this issue.
I've just tried to reproduce the issue but with no luck - how to do you get the loading state of the app while being offline? I'm opening the admin page but it loads normally even when forced offline...
Activity
[-]Android - Compose box -App crashes on sending message in offline while page is loading[/-][+][$500] Android - Compose box -App crashes on sending message in offline while page is loading[/+]melvin-bot commentedon Nov 1, 2023
Triggered auto assignment to @sonialiap (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Nov 1, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01459aaf4e457cbbe8
melvin-bot commentedon Nov 1, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Nov 1, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @burczu (
External)tienifr commentedon Nov 1, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
App crashes on sending message in offline while page is loading.
What is the root cause of that problem?
In here, the
flatListRefis not initialized yet, but we're callingscrollToOffseton theflatListRef.currentwhich is undefined, causing the crash.flatListRefis not initialized at the beginning because at that time there's no item in the list yet, there's only the loading skeleton. Only after the first message is sent, there'll be item in the list and the ref will have value.What changes do you think we should make in order to solve the problem?
We need to check that
flatListRef?.currentis truth first before callingscrollToOffset. This will not cause any issue because at the time we send the first message, the list is already at the bottom so no need to scroll to bottom.What alternative solutions did you explore? (Optional)
We need to check all the places that
flatListRefis used and apply the same fix if it's also not checking truthy.Alternatively, we can import the
useReportScrollManagerand use thescrollToBottommethod from there, which already has the truthy check.bernhardoj commentedon Nov 1, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
Sending a message while the report page is still loading (a skeleton loader is showing) will crash the app (on the Web, an error log will be thrown).
What is the root cause of that problem?
The error is coming from this code where we are trying to scroll to the bottom after adding a comment, but the
flatListRef.currentisundefined.App/src/pages/home/ReportScreen.js
Lines 266 to 269 in b9e202d
flatListRefis the ref of the chat list component (ReportActionsList). The problem is, while the report page is loading, we render the skeleton loader view, so the list ref isn't set yet.What changes do you think we should make in order to solve the problem?
Actually, we already have an existing logic to scroll to the bottom every time the user adds a new message using
reportScrollManager.scrollToBottom()that already handles the null/undefined safety.App/src/pages/home/report/ReportActionsList.js
Lines 221 to 230 in b9e202d
So, we can just remove the new logic that is introduced by this PR.
tienifr commentedon Nov 2, 2023
The scroll there was added for a reason, removing it will cause regressions, also it's not the root cause of this issue. I'd say let's fix this bad crash now on the correct root cause.
There's a plan to address the timeout as a follow up here so we don't need to worry about that unrelated part in this issue.
sonialiap commentedon Nov 6, 2023
@burczu what do you think of the above proposals?
burczu commentedon Nov 6, 2023
@sonialiap I'm sorry - I was OOO last week. I'll be reviewing proposals soon.
burczu commentedon Nov 7, 2023
I've just tried to reproduce the issue but with no luck - how to do you get the loading state of the app while being offline? I'm opening the admin page but it loads normally even when forced offline...
tienifr commentedon Nov 8, 2023
Loading here means skeleton. You should re-open the app, enable forced offline and go to a random chat that has not been loaded in Onyx yet.
melvin-bot commentedon Nov 8, 2023
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸
burczu commentedon Nov 9, 2023
@tienifr Thanks for help!
I've checked one more time and it seems it's not reproducible on the current
main:Screen.Recording.2023-11-09.at.12.21.54.mp4
Can someone else confirm it?
sonialiap commentedon Nov 13, 2023
I just tested and my android app does not crash when I send a message to a loading #admins room while "force offline" is toggled.
Since multiple people cannot reproduce. Closing