Skip to content

Commit c920685

Browse files
christophpurrerappden
authored andcommitted
Cache local images into memory (microsoft#1279)
This introduces a cache for local image on macOS. There are no predefined limits set here (at least yet) since presumably we are loading a finite number of resources and we have the benefit of virtual memory swap on desktop so we don't really need to sweat a few extra megabytes of in-memory cache for images we know we'll need to repeatedly load. Local images don't use the shared RN image cache, and on macOS there's no automatic in-memory cache for local resources (other than the OS-level disk cache) so the `RCTImageFromLocalBundleAssetURL` function will synchronously access the disk on the main thread many times over during thread switching in Messenger Desktop. Added logging to confirmed cache works as expected in rn-tester, and instrumentation also confirms it. Co-authored-by: Scott Kyle <skyle@fb.com>
1 parent d8dfc86 commit c920685

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

React/Base/RCTUtils.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#import "RCTAssert.h"
2222
#import "RCTLog.h"
2323

24+
static const NSUInteger RCTMaxCachableImageCount = 100;
25+
2426
NSString *const RCTErrorUnspecified = @"EUNSPECIFIED";
2527

2628
// Returns the Path of Home directory

0 commit comments

Comments
 (0)