Skip to content

Conversation

@rohit9625
Copy link
Contributor

Explanation of Change

This PR updates the react-native-pager-view library to version 6.8.0 to resolve crash on rapid back navigation on Android devices. It's was an upstream issue.

Fixed Issues

$ #61581
PROPOSAL: #61581 (comment)

Tests

  1. Launch Expensify app.
  2. Open FAB > Create expense.
  3. Tap Distance.
  4. Tap app back button.
  5. Open FAB > Create expense.
  6. Tap Manual.
  7. Tap device back button twice quickly.
  • Verify that no errors appear in the JS console

Offline tests

Same as test

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android_App.mp4
Android: mWeb Chrome
mWeb_Android.mp4
iOS: Native
iOS_App.mov
iOS: mWeb Safari
iOS_mWeb_Safari.mov
MacOS: Chrome / Safari
Mac_Safari.mov
MacOS: Desktop
Mac_Desktop.mov

@rohit9625 rohit9625 requested a review from a team as a code owner July 18, 2025 18:02
@melvin-bot melvin-bot bot requested review from parasharrajat and removed request for a team July 18, 2025 18:02
@melvin-bot
Copy link

melvin-bot bot commented Jul 18, 2025

@parasharrajat 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]

@github-actions
Copy link
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@parasharrajat
Copy link
Member

@rohit9625 Can you please clarify what was the error or issue that were you facing earlier?

@rohit9625
Copy link
Contributor Author

It wasn't consistent but when I first installed the app and tried to repro the issue, the app crashed even after upgrading to latest version.

@parasharrajat
Copy link
Member

parasharrajat commented Jul 23, 2025

Can you please merge main @rohit9625 ?

1 similar comment
@parasharrajat
Copy link
Member

Can you please merge main @rohit9625 ?

@rohit9625
Copy link
Contributor Author

Sure!

@rohit9625
Copy link
Contributor Author

I think some issue from the main.

@parasharrajat
Copy link
Member

Screenshots

🔲 iOS / native

🔲 iOS / Safari

🔲 MacOS / Desktop

🔲 MacOS / Chrome

23.07.2025_19.09.03_REC.mp4

🔲 Android / Chrome

🔲 Android / native

23.07.2025_19.06.23_REC.mp4

@parasharrajat
Copy link
Member

parasharrajat commented Jul 23, 2025

@rohit9625 This ts error seems to be coming from this PR. Can you please fix that?

Also add a summary of what changed between the versions to the PR description.

@rohit9625
Copy link
Contributor Author

@rohit9625 This ts error seems to be coming from this PR. Can you please fix that?

Also add a summary of what changed between the versions to the PR description.

Okay, I'll try to fix that by tomorrow :)

@parasharrajat
Copy link
Member

Any update @rohit9625

@rohit9625
Copy link
Contributor Author

Hi @parasharrajat, I'm sorry for replying late as I was sick yesterday. I looked at the changelogs and found that the support for useNext has been removed in version 6.6.0. So, what should we do in this case? Make changes in our code or drop the idea of upgrading version?

image

@parasharrajat
Copy link
Member

We need to solve this issue. Now what is best here to solve the main issue and not cause more.

@rohit9625
Copy link
Contributor Author

Well, I think downgrading the version can solve the crash as someone using version 6.3.0 with no crash. I tried but getting some build errors which will require library patch and it's also not quite a good approach. So, at best I think we should just debounce the back navigation until scrolling is finished.

We can utilize onPageScrollStateChanged prop for that:
image

@parasharrajat
Copy link
Member

I think we are juggling between different things to try and run.

Can you instead migrate the code for useNext?

@parasharrajat
Copy link
Member

@rohit9625 Any update? We have already spent a considerable amount waiting on this. Do we have an action plan for this that works without doing hit and trial?

Can you please share the results of the approaches you are suggesting before implementing?

@rohit9625
Copy link
Contributor Author

rohit9625 commented Jul 26, 2025

I'm sorry @parasharrajat but I couldn't find out a more viable solution than upgrading version. However, that too seems pretty unstable initially, maybe something wrong on my device. If upgrading version solves crash for you, then I will work on migrating useNext. However, from your screencasts, it seems the app crashes even after upgrading, right?

@parasharrajat
Copy link
Member

No app didn't crashed on my app, it exited as it is supposed to do on back arrow press on Android when you are at the home screen.

I think we should pursure migrating useNext. Let me retest this on main. May be its no longer an issue.

@parasharrajat
Copy link
Member

parasharrajat commented Aug 3, 2025

So this issue is still happening on main. Can you please provide an update on when you can complete this?

If you are having a problem, please let us know so that we can reassign someone else.

@rohit9625
Copy link
Contributor Author

So this issue is still happening on main. Can you please provide an update on when you can complete this?

So, both of us can reproduce this issue on main, and you confirmed that PR fixes the crash on your end. I think something could be wrong with my PC, as on a fresh install after upgrading, I got a crash for one time only, and not after that.

Anyways, I'm looking for the reason why we added useNext for Android. I also found that some of the users were required to use a prop for an iOS issue. I'm testing the behavior after removing the useNext prop on version 6.5.3, and if I didn't find any, then I would suggest removing the prop completely after upgrading to version 6.8.0.

One more thing, why did you test attachment carousel swiping, as in your screencasts? Did you notice any issues there after upgrading?

@rohit9625
Copy link
Contributor Author

I just tested on Android after removing useNext, and the behavior is the same. So, should I remove that prop completely?

Screencast.from.2025-08-03.20-08-23.webm

@parasharrajat
Copy link
Member

Can you explain how the app is still working the same even after removing that?

@rohit9625
Copy link
Contributor Author

I don't know how and I didn't found the issue which added useNext. So, after manually testing we cannot see any difference. Also, that is the only usage of useNext in our codebase.

@parasharrajat
Copy link
Member

This is the issue. #45289 (comment)

Can you please check it?

@parasharrajat
Copy link
Member

Also, can you please share the supporting document from the migration notes on how useNext is migrated or why it was removed? PR, issue etc. Everything that can explain it. Please do share the links that I can follow.

@rohit9625
Copy link
Contributor Author

This is the issue. #45289 (comment)

Can you please check it?

Thanks for the reference @parasharrajat. I saw the related commit, which solved the truncated image issue for iOS. However, that doesn't explain why we have useNext, which forces the scroll view-based pager view implementation.

Before that commit, we had useNext={true} for all platforms, but that was causing a truncated image issue for iOS, as mentioned in the linked comment. So, someone scoped useNext for Android only using shouldUseNewPager.

@rohit9625
Copy link
Contributor Author

rohit9625 commented Aug 4, 2025

Also, can you please share the supporting document from the migration notes on how useNext is migrated or why it was removed? PR, issue etc. Everything that can explain it. Please do share the links that I can follow.

Here's the PR that removed the scroll-view-based pager view implementation:

This is the related issue that someone was able to solve using the useNext prop as mentioned in the above PR.

@rohit9625
Copy link
Contributor Author

Also, I couldn't find any migration-related notes as useNext, allowing users to use an experimental implementation of pager-view that was removed in version 6.6.0. So, it wasn't something that could be migrated. However, if we find the issue because of which we started using scroll-view-based pager view implementation, then we will figure out some other way to solve that or it's possible that the issue doesn't exist anymore.

@parasharrajat
Copy link
Member

Thanks for all this. I will go through it.

@parasharrajat
Copy link
Member

parasharrajat commented Aug 5, 2025

@rohit9625 Please merge main. I am looking into this now.

@rohit9625
Copy link
Contributor Author

rohit9625 commented Aug 5, 2025

Done 👍 @parasharrajat

@parasharrajat
Copy link
Member

Ok. Let's remove the useNext prop and all related code used for it. @rohit9625

@parasharrajat
Copy link
Member

Let me know when this PR is ready.

@parasharrajat
Copy link
Member

But I noticed that this PR does not completely solve the double-tap app-closing issue. It does not cause a crash anymore, but still, the app gets closed on double-tap on the create expense page, while if we do the same thing, it does not.

So I consider this solution partial.

@rohit9625
Copy link
Contributor Author

That's exactly what I was saying that the app crashing and so the app closes when tapping back twice. If it wasn't crashing, then the app shouldn't closed on tapping twice. However, it happens for the first time on my case and works after that.

@parasharrajat
Copy link
Member

So what do you suggest here?

@rohit9625
Copy link
Contributor Author

Currently, tab view is working like this:

  1. We open create expense flow and suppose manual tab is opened on first render
  2. Then we switches to distance tab
  3. And now if we try to navigate back by hardware back button, then it switches to previous tab(manual).

The crash happens when the app unmounts create expense screen on second rapid back press, while the switching tab animation is going on.
It could be better if just remove this functionality of switching to previous tab.

@parasharrajat
Copy link
Member

OK, I think this is something that needs to be discused on slack. Do you have access to Slack?

@rohit9625
Copy link
Contributor Author

Yes, I have access to Slack's external contributor's group.

@parasharrajat
Copy link
Member

parasharrajat commented Aug 5, 2025

Can you please raise a slack thread about this? Explaining the problem, then solution you adopted and the blocker. Please tag me.

@rohit9625
Copy link
Contributor Author

Can you please raise a slack thread about this? Explaining the problem, then solution you adopted and the blocker. Please tag me.

Sure! I will create a descriptive thread today and tag you :)

@rohit9625
Copy link
Contributor Author

I created a thread here: https://expensify.slack.com/archives/C01GTK53T8Q/p1754498061089509

@parasharrajat
Copy link
Member

@rohit9625 We are not ready to change the tab behaviour. It is designed this way. Do you have any other solution?

@rohit9625
Copy link
Contributor Author

rohit9625 commented Aug 17, 2025

Okay, so what if we detect a quick double-back navigation press on Android and directly close the Create Expense screen? This way, older functionality will remain intact as the crash happens when the back press is too quick, and not if we press normally. So, we can implement this solution as a workaround until the upstream issue is fixed.

@parasharrajat
Copy link
Member

Thanks for the suggestion, but I am not happy to move ahead with this workaround. At this point, I think we can reopen the issue for more proposals.

@rohit9625
Copy link
Contributor Author

Yep, I think you're right, we should reopen the issue for proposals, and can also increase the bounty, as this is not a simple issue.

@parasharrajat
Copy link
Member

@rohit9625 let's close this PR. Thanks.

@rohit9625
Copy link
Contributor Author

Okay, done 👍

@rohit9625 rohit9625 closed this Aug 19, 2025
@rohit9625 rohit9625 deleted the fix/crash-on-rapid-back-navigation branch September 12, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants