Skip to content

Conversation

@danilobuerger
Copy link
Contributor

@danilobuerger danilobuerger commented Apr 2, 2022

Summary

Allow modifying iOS image cache limits. Currently the image cache imposes some strict limits:

NSCache.totalCostLimit of 20MB.
Single Image Size Limit of 2MB (bitmap size).

This may not be enough for applications that make heavy use of images. With this commit it is possible to fine tune them to the applications need.

This can be set for example in the App Delegate with:

RCTSetImageCacheLimits(4*1024*1024, 200*1024*1024);

This would increase the single image size limit to 4 MB and the total cost limit to 200 MB.

Changelog

[iOS] [Added] - Allow modifying iOS image cache limits

Test Plan

There is no easy way to test this except adding the above snippet and checking via break points that the new limits are used.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 2, 2022
@react-native-bot react-native-bot added Platform: iOS iOS applications. Type: Enhancement A new feature or enhancement of an existing feature. labels Apr 2, 2022
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Apr 2, 2022
@analysis-bot
Copy link

analysis-bot commented Apr 2, 2022

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 3693928
Branch: main

@analysis-bot
Copy link

analysis-bot commented Apr 2, 2022

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,768,085 +0
android hermes armeabi-v7a 7,172,017 +0
android hermes x86 8,074,323 +0
android hermes x86_64 8,054,640 +0
android jsc arm64-v8a 9,645,279 +0
android jsc armeabi-v7a 8,419,644 +0
android jsc x86 9,594,494 +0
android jsc x86_64 10,191,921 +0

Base commit: 3693928
Branch: main

@cortinico
Copy link
Contributor

Could you rebase this @danilobuerger The CI should be green

@facebook-github-bot
Copy link
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@cortinico has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @danilobuerger in 61b013e.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Apr 8, 2022
Saadnajmi pushed a commit to Saadnajmi/react-native-macos that referenced this pull request Jan 15, 2023
Summary:
Allow modifying iOS image cache limits. Currently the image cache imposes some strict limits:

[NSCache.totalCostLimit](https://developer.apple.com/documentation/foundation/nscache/1407672-totalcostlimit?language=objc) of 20MB.
Single Image Size Limit of 2MB (bitmap size).

This may not be enough for applications that make heavy use of images. With this commit it is possible to fine tune them to the applications need.

This can be set for example in the App Delegate with:

```objc
RCTSetImageCacheLimits(4*1024*1024, 200*1024*1024);
```
This would increase the single image size limit to 4 MB and the total cost limit to 200 MB.

## Changelog

[iOS] [Added] - Allow modifying iOS image cache limits

Pull Request resolved: facebook#33554

Test Plan: There is no easy way to test this except adding the above snippet and checking via break points that the new limits are used.

Reviewed By: cipolleschi

Differential Revision: D35485914

Pulled By: cortinico

fbshipit-source-id: 646cf7cab5ea5258d0d0d0bce6383317e27e4445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: iOS iOS applications. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. Type: Enhancement A new feature or enhancement of an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants