Back out "[RN] Remove RCTUIImageViewAnimated WeakProxy gating"

Summary:
Original commit changeset: 91eb08181f82
Original diff: D16940181

The original commit removed the gating logic to enable the "fix" to T48583301. However, v236 was burned, and v237+ no longer had this gating, making it impossible to measure the impact of the fix.

This diff reverted the original gating removal until we confirm the fix in prod. Note: this is to be picked to RC v238 (but will have merge conflict for sure, will send a separate diff for the branch).

Reviewed By: mmmulani

Differential Revision: D17251340

fbshipit-source-id: 359ac54aeb9c9e728c2735c688346a1f79ed2189
This commit is contained in:
Kevin Gozali 2019-09-07 19:02:57 -07:00 коммит произвёл Facebook Github Bot
Родитель 16256f83f8
Коммит 24ababc915
2 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -8,6 +8,8 @@
#import <React/RCTAnimatedImage.h>
#import <React/RCTDefines.h>
RCT_EXTERN void RCTUIImageViewEnableWeakProxy(BOOL enabled);
@interface RCTUIImageViewAnimated : UIImageView
@end

Просмотреть файл

@ -11,6 +11,11 @@
#import <mach/mach.h>
#import <objc/runtime.h>
static BOOL weakProxyEnabled = YES;
void RCTUIImageViewEnableWeakProxy(BOOL enabled) {
weakProxyEnabled = enabled;
}
static NSUInteger RCTDeviceTotalMemory() {
return (NSUInteger)[[NSProcessInfo processInfo] physicalMemory];
}
@ -153,7 +158,9 @@ static NSUInteger RCTDeviceFreeMemory() {
}
if (!_displayLink) {
_displayLink = [CADisplayLink displayLinkWithTarget:[RCTWeakProxy weakProxyWithTarget:self] selector:@selector(displayDidRefresh:)];
__weak typeof(self) weakSelf = self;
id target = weakProxyEnabled ? [RCTWeakProxy weakProxyWithTarget:self] : weakSelf;
_displayLink = [CADisplayLink displayLinkWithTarget:target selector:@selector(displayDidRefresh:)];
NSString *runLoopMode = [NSProcessInfo processInfo].activeProcessorCount > 1 ? NSRunLoopCommonModes : NSDefaultRunLoopMode;
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:runLoopMode];
}