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

feat(images): Adding iOS Image Cache Limits #3258

Merged
merged 7 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,20 @@ Please note that the following corner specific, border radius style properties m
## Off-thread Decoding

Image decoding can take more than a frame-worth of time. This is one of the major sources of frame drops on the web because decoding is done in the main thread. In React Native, image decoding is done in a different thread. In practice, you already need to handle the case when the image is not downloaded yet, so displaying the placeholder for a few more frames while it is decoding does not require any code change.

## Configuring iOS Image Cache Limits

gedeagas marked this conversation as resolved.
Show resolved Hide resolved
On iOS, we expose an API to override React Native's default image cache limits. This should be called from within your native AppDelegate code (e.g. within `didFinishLaunchingWithOptions`).

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

**Parameters:**

| Name | Type | Required | Description |
| -------------- | ------ | -------- | ----------------------- |
| imageSizeLimit | number | Yes | Image cache size limit. |
| totalCostLimit | number | Yes | Total cache cost limit. |

In the above code example the image size limit is set to 4 MB and the total cost limit is set to 200 MB.
17 changes: 17 additions & 0 deletions website/versioned_docs/version-0.69/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,20 @@ Please note that the following corner specific, border radius style properties m
## Off-thread Decoding

Image decoding can take more than a frame-worth of time. This is one of the major sources of frame drops on the web because decoding is done in the main thread. In React Native, image decoding is done in a different thread. In practice, you already need to handle the case when the image is not downloaded yet, so displaying the placeholder for a few more frames while it is decoding does not require any code change.

## Configuring iOS Image Cache Limits

On iOS, we expose an API to override React Native's default image cache limits. This should be called from within your native AppDelegate code (e.g. within `didFinishLaunchingWithOptions`).

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

**Parameters:**

| Name | Type | Required | Description |
| -------------- | ------ | -------- | ----------------------- |
| imageSizeLimit | number | Yes | Image cache size limit. |
| totalCostLimit | number | Yes | Total cache cost limit. |

In the above code example the image size limit is set to 4 MB and the total cost limit is set to 200 MB.