Closed lanitochka17 closed 1 month ago
Triggered auto assignment to @thienlnam (DeployBlockerCash
), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.
:wave: 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:
I am on latest main. I am unable to reproduce this issue
Downloaded QR Code is blank in iOS.
This happened after we upgraded the react-native-view-shot
in https://github.com/Expensify/App/pull/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.
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;
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
@lakchote wdyt? Should we just revert https://github.com/Expensify/App/pull/49595?
@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.
This has been CPEd
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:
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?
Screenshots/Videos
Add any screenshot/video evidence
https://github.com/user-attachments/assets/20ef42f6-94b7-461b-ba6c-4b98204c622a
View all open jobs on GitHub