Skip to content
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

iOS Chat - Downloaded share code is blank #49868

Closed
1 of 6 tasks
lanitochka17 opened this issue Sep 27, 2024 · 8 comments
Closed
1 of 6 tasks

iOS Chat - Downloaded share code is blank #49868

lanitochka17 opened this issue Sep 27, 2024 · 8 comments
Assignees
Labels
DeployBlockerCash This issue or pull request should block deployment Engineering Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 27, 2024

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

@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Sep 27, 2024
Copy link

melvin-bot bot commented Sep 27, 2024

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

Copy link
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.

@Nodebrute
Copy link
Contributor

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

@bernhardoj
Copy link
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;

@s77rt
Copy link
Contributor

s77rt commented Sep 28, 2024

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

@roryabraham
Copy link
Contributor

@lakchote wdyt? Should we just revert #49595?

@lakchote
Copy link
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.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Hourly KSv2 labels Sep 30, 2024
@thienlnam thienlnam removed their assignment Sep 30, 2024
@thienlnam
Copy link
Contributor

This has been CPEd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DeployBlockerCash This issue or pull request should block deployment Engineering Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

7 participants