Skip to content

iOS - Profile - The App crashes when saving the user's avatar #37963

Closed

Description

@kbecciv

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.49-0
Reproducible in staging?: y
Reproducible in production?: n
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4410248
Issue reported by: Applause - Internal Team

Action Performed:

  1. Open iOS App
  2. Login with any account
  3. Go to Account Settings
  4. Tap to User Avatar
  5. Select "Upload photo"
  6. Select "Take photo" or "Choose from gallery"
  7. Take/select photo and tap "Save"

Expected Result:

Photo was successfully saved as the user's avatar.

Actual Result:

App crashes after user taps on "Save" button

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

Bug6406847_1709896582377.iOS-crash-Avatar.mp4

View all open jobs on GitHub

Activity

  1. github-actions commented on Mar 8, 2024

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  2. kbecciv commented on Mar 8, 2024

    @kbecciv
    Author

    We think that this bug might be related to #vip-vsb
    @quinthar

  3. melvin-bot commented on Mar 8, 2024

    @melvin-bot

    Triggered auto assignment to @madmax330 (Engineering), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. shubham1206agra commented on Mar 8, 2024

    @shubham1206agra
    Contributor

    @kbecciv Can you share the crash logs here?

  5. kbecciv commented on Mar 8, 2024

    @kbecciv
    Author
  6. roryabraham commented on Mar 8, 2024

    @roryabraham
    Contributor

    not able to reproduce on dev

  7. roryabraham commented on Mar 8, 2024

    @roryabraham
    Contributor

    this appears to be related to this crash, which was first caught on 1.4.47-10. So I'm not sure if it's a blocker (but it was my mistake not noticing this earlier this week, I had been looking only at Android crashes by mistake)

  8. roryabraham commented on Mar 8, 2024

    @roryabraham
    Contributor

    was able to reproduce on staging. I wonder if it has to be an HEIC?

  9. roryabraham commented on Mar 8, 2024

    @roryabraham
    Contributor

    need to test on a physical device...

  10. 22 remaining items

  11. roryabraham commented on Mar 10, 2024

    @roryabraham
    Contributor

    reopening to verify the fix in 1.4.49-4

  12. situchan commented on Mar 10, 2024

    @situchan
    Contributor

    ok so as I said here, app still crashes on launch for the users who already triggered crash on avatar upload in previous build.
    They should uninstall and reinstall to continue using the app.

  13. roryabraham commented on Mar 10, 2024

    @roryabraham
    Contributor

    yeah, that's unfortunate but I don't think there's anything we can do about it really ☹️

  14. roryabraham commented on Mar 10, 2024

    @roryabraham
    Contributor

    well, maybe if we found a "restorative" fix to the crash rather than a "preventative" fix, but idk if we'll be able to do that since it seems to be a low-level crash in the native network request code, presumably caused by some bad url or something?

  15. roryabraham commented on Mar 10, 2024

    @roryabraham
    Contributor

    verified this is fixed after you uninstall and reinstall

  16. kosmydel commented on Mar 11, 2024

    @kosmydel
    Contributor

    Hey, I've investigated this issue today.


    The reason behind it was that we were passing the base64=null param inside the file parameter when calling the API:

    const parameters: UpdateUserAvatarParams = {file};

    The RCTNetworking networking library didn't like the base64 nullish value, and early returned causing the crash:

    https://github.com/facebook/react-native/blob/a7fde7c885a3827c03b058a21023b18501e2a57a/packages/react-native/Libraries/Network/RCTNetworking.mm#L425-L428

    Why did we pass the base64 value?
    The expo-image-manipulator library by default sets the base64 option to false, meaning that we don't need to generate it. But the library instead of skipping this param, adds base64=null in this line:

    https://github.com/expo/expo/blob/a05bfbc3a907177bca2dd8a2dd22073763daa895/packages/expo-image-manipulator/ios/ImageManipulatorModule.swift#L33

    Commenting out this line fixes the problem.

    So I come up with two solutions (without touching the library):

    • We can pass here base64: true option to generate the base64 (instead of passing null)
    • We can remove the base64 prop from the parameters when calling the API command:
    const {base64, ...fileWithoutBase64} = file;
    const parameters: UpdateUserAvatarParams = {file: fileWithoutBase64};

    I will also contact with the internal expo maintainers at SWM, as they might want to fix it in the library.


    I will prepare a PR with the fix tomorrow.

    Thanks @roryabraham for the initial investigation, as it helped a lot!

  17. roryabraham commented on Mar 11, 2024

    @roryabraham
    Contributor

    sounds good @kosmydel and thanks for figuring that out. Glad my initial investigation was helpful! If we're not using the base64 encoding I imagine it's likely better not to generate it unnecessarily. So let's go with the 2nd solution to remove the base64 from the parameters when calling the API command.

    Alternatively, maybe we can update expo-image-manipulator to remove base64: null from the response if no base64 encoding is created. That seems like the best solution if they're down for that

  18. kosmydel commented on Mar 12, 2024

    @kosmydel
    Contributor

    Alternatively, maybe we can update expo-image-manipulator to remove base64: null from the response if no base64 encoding is created. That seems like the best solution if they're down for that

    I've contacted an Expo maintainer, so I will keep you updated.

    For now, I think to unblock the issue, I can prepare a PR with the 2nd solution.

  19. kosmydel commented on Mar 13, 2024

    @kosmydel
    Contributor

    sounds good @kosmydel and thanks for figuring that out. Glad my initial investigation was helpful! If we're not using the base64 encoding I imagine it's likely better not to generate it unnecessarily. So let's go with the 2nd solution to remove the base64 from the parameters when calling the API command.

    Alternatively, maybe we can update expo-image-manipulator to remove base64: null from the response if no base64 encoding is created. That seems like the best solution if they're down for that

    Quick update: After contacting Expo maintainers they told me, that this is expected, and consistent across other parameters. They will improve the types, so the base64 will also include the null type (currently it is string | undefined). So in that way, we would know, that base64 could be null, and we would be able to handle it appropriately.

    For now, I've created a PR with 2nd solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions