Skip to content

OS 17+ Breaking Change: Apple deprecated UIGraphicsBeginImageContext() and made it throw exceptions when called with zero-size dimensions. Previous iOS versions just silently failed.Β #1074

@AshrazRashid

Description

@AshrazRashid

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m b/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m
index f710081..06d646c 100644
--- a/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m
+++ b/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m
@@ -73,6 +73,11 @@ - (void) setImageColor: (UIColor*)imageColor {
 
 - (UIImage*) makeImage: (UIImage*)image withTint: (UIColor*)color {
     UIImage* newImage = [image imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate];
+    
+    if (image.size.width <= 0 || image.size.height <= 0) {
+        return image;
+    }
+    
     UIGraphicsBeginImageContextWithOptions(image.size, NO, newImage.scale);
     [color set];
     [newImage drawInRect: CGRectMake(0, 0, image.size.width, newImage.size.height)];

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions