Skip to content

iOS Chat - Downloaded share code is blank #49868

Closed

Description

@lanitochka17

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: 9.0.41-1
Reproducible in staging?: Y
Reproducible in production?: N/A unable to check
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch New Expensify app
  2. Open workspace chat
  3. Tap on the chat header
  4. Tap Share
  5. Tap Download
  6. Download the share code
  7. View the downloaded code on device gallery

Expected Result:

The downloaded share code is not blank

Actual Result:

The downloaded share code is blank

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

Bug6617724_1727463539750.ScreenRecording_09-28-2024_02-15-09_1.mp4

View all open jobs on GitHub

Activity

  1. melvin-bot commented on Sep 27, 2024

    @melvin-bot

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

  2. github-actions commented on Sep 27, 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.
  3. Nodebrute commented on Sep 27, 2024

    @Nodebrute
    Contributor

    I am on latest main. I am unable to reproduce this issue
    Screenshot 2024-09-28 at 2 38 29 AM

  4. bernhardoj commented on Sep 28, 2024

    @bernhardoj
    Contributor

    Proposal

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

    Downloaded QR Code is blank in iOS.

    What is the root cause of that problem?

    This happened after we upgraded the react-native-view-shot in #49595. The upstream issue started in version 4.0.0-alpha.2. Someone reported the issue upstream here too.

    After knowing the issue is from the react-native-view-shot, now we need to understand what is the issue there. The issue happens after this upstream PR which replaces the iOS deprecated function.

    Previously, it used UIGraphicsBeginImageContextWithOptions and UIGraphicsGetImageFromCurrentImageContext and "draw" the image between the active context:

    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
    
    if (renderInContext) {
      [rendered.layer renderInContext: UIGraphicsGetCurrentContext()];
      success = YES;
    }
    else {
      success = [rendered drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES];
    }
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    

    But now, it looks like this:

    UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size];
    
    if (renderInContext) {
      [rendered.layer renderInContext: UIGraphicsGetCurrentContext()];
      success = YES;
    }
    else {
      success = [rendered drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES];
    }
    
    UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {}];
    

    A renderer is created and the context is now available from the imageWithActions. So, the "drawing" between them does nothing.

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

    There is a solution here but it's incomplete since it doesn't respect the renderInContext params and always use renderInContext.

    So, to solve this, we need to move the rendering/"drawing" inside imageWithActions.

    UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {
      if (renderInContext) {
        [rendered.layer renderInContext: rendererContext.CGContext];
        success = YES;
      }
      else {
        success = [rendered drawViewHierarchyInRect:(CGRect){CGPointZero, size} afterScreenUpdates:YES];
      }
    }];
    

    The context now is coming from rendererContext.

    Last, we need to update this success variable with a __block modifier, so it's updatable from the imageWithActions block.

    __block BOOL success;
    
  5. s77rt commented on Sep 28, 2024

    @s77rt
    Member

    If we don't have to stick with react-native-view-shot we can use @s77rt/react-native-viewshot which provides a similar API and it seems to line up with @bernhardoj's proposed solution

  6. roryabraham commented on Sep 29, 2024

    @roryabraham
    Contributor

    @lakchote wdyt? Should we just revert #49595?

  7. lakchote commented on Sep 30, 2024

    @lakchote
    Contributor

    @lakchote wdyt? Should we just revert #49595?

    Yes, we should just revert and wait for the library to offer a new stable version. Once that's done, we'll reconsider adding it.

  8. removed their assignment
    on Sep 30, 2024
  9. thienlnam commented on Sep 30, 2024

    @thienlnam
    Contributor

    This has been CPEd

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