react-native
react-native copied to clipboard
feat(image): enabling basic cache control for android
Summary:
Fixes #12606
Previously, Image cache control options were not functional on Android, even though they were being passed to the native component via the source prop. This PR addresses that by implementing logic to manage cache behaviour on Android.
When the reload option is explicitly set, the image is now evicted from both memory and disk caches before a new request is made. This ensures the image is always fetched from the source, aligning the caching behaviour between Android and iOS for the default and reload options.
Changelog:
[ANDROID][ADDED] - Enabling basic Image cache control for Android
Test Plan:
Added a new example to the rn-tester, where we can notice that the image on the right is reloaded if rendered or re-rendered as the cache policy is set to reload. The image on the left has the cache policy set to default and won't be re-rendered as the image is already in the cache. See the video below:
https://github.com/user-attachments/assets/88bc1d2d-0239-4deb-bcde-fe0ce521ff4d
Also tested on both old and new architecture.
| Fails | |
|---|---|
| :no_entry_sign: |
Danger failed to run |
Error ReferenceError
validateChangelog is not defined
ReferenceError: validateChangelog is not defined
at Object.<anonymous> (dangerfile.js:48:18)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at requireFromString (/home/runner/work/react-native/react-native/node_modules/require-from-string/index.js:28:4)
at /home/runner/work/react-native/react-native/node_modules/danger/distribution/runner/runners/inline.js:161:68
at step (/home/runner/work/react-native/react-native/node_modules/danger/distribution/runner/runners/inline.js:52:23)
at Object.next (/home/runner/work/react-native/react-native/node_modules/danger/distribution/runner/runners/inline.js:33:53)
at /home/runner/work/react-native/react-native/node_modules/danger/distribution/runner/runners/inline.js:27:71
at new Promise (<anonymous>)
at __awaiter (/home/runner/work/react-native/react-native/node_modules/danger/distribution/runner/runners/inline.js:23:12)
at runDangerfileEnvironment (/home/runner/work/react-native/react-native/node_modules/danger/distribution/runner/runners/inline.js:118:132)
at /home/runner/work/react-native/react-native/node_modules/danger/distribution/platforms/GitHub.js:181:38
at step (/home/runner/work/react-native/react-native/node_modules/danger/distribution/platforms/GitHub.js:44:23)
at Object.next (/home/runner/work/react-native/react-native/node_modules/danger/distribution/platforms/GitHub.js:25:53)
at /home/runner/work/react-native/react-native/node_modules/danger/distribution/platforms/GitHub.js:19:71
at new Promise (<anonymous>)
at __awaiter (/home/runner/work/react-native/react-native/node_modules/danger/distribution/platforms/GitHub.js:15:12)
at Object.executeRuntimeEnvironment (/home/runner/work/react-native/react-native/node_modules/danger/distribution/platforms/GitHub.js:144:88)
at /home/runner/work/react-native/react-native/node_modules/danger/distribution/commands/danger-runner.js:101:47
at step (/home/runner/work/react-native/react-native/node_modules/danger/distribution/commands/danger-runner.js:34:23)
at Object.next (/home/runner/work/react-native/react-native/node_modules/danger/distribution/commands/danger-runner.js:15:53)
at fulfilled (/home/runner/work/react-native/react-native/node_modules/danger/distribution/commands/danger-runner.js:6:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Dangerfile
43| 'This will require a manual import by a Facebook employee.';
44| warn(`${title} - <i>${idea}</i>`);
45| }
46|
47| // Provides advice if a test plan is missing.
--------------------^
48| const includesTestPlan =
49| danger.github.pr.body &&
50| danger.github.pr.body.toLowerCase().includes('## test plan');
51| if (!includesTestPlan && !isFromPhabricator) {
Generated by :no_entry_sign: dangerJS against c2b0e6c8e310f7e8123b22f5961278e58433569e
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
This pull request was successfully merged by @mateoguzmana in e5dd7d68bf264669fc5c4ce5e69b24249d28558b
When will my fix make it into a release? | How to file a pick request?
@Abbondanzo merged this pull request in facebook/react-native@e5dd7d68bf264669fc5c4ce5e69b24249d28558b.