iOS - clean up weakproxy gating

Summary: The proper weakproxy usage should be enabled by default from now on.

Reviewed By: PeteTheHeat

Differential Revision: D17866448

fbshipit-source-id: da404a41fd1136d7feebfc7591fa2965a65c4c6b
This commit is contained in:
Kevin Gozali 2019-10-10 21:05:12 -07:00 коммит произвёл Facebook Github Bot
Родитель 299eb9f440
Коммит abf612aecd
2 изменённых файлов: 23 добавлений и 36 удалений

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

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

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

@ -11,11 +11,6 @@
#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];
}
@ -151,20 +146,14 @@ static NSUInteger RCTDeviceFreeMemory() {
- (CADisplayLink *)displayLink
{
// TODO (T53783620): This logic should always be enabled.
if (weakProxyEnabled) {
// We only need a displayLink in the case of animated images, so short-circuit this code and don't create one for most of the use cases.
// Since this class is used for all RCTImageView's, this is especially important.
if (!_animatedImage) {
return nil;
}
// We only need a displayLink in the case of animated images, so short-circuit this code and don't create one for most of the use cases.
// Since this class is used for all RCTImageView's, this is especially important.
if (!_animatedImage) {
return nil;
}
if (!_displayLink) {
__weak typeof(self) weakSelf = self;
// TODO (T53783620): This logic should always be enabled.
id target = weakProxyEnabled ? [RCTWeakProxy weakProxyWithTarget:self] : weakSelf;
_displayLink = [CADisplayLink displayLinkWithTarget:target selector:@selector(displayDidRefresh:)];
_displayLink = [CADisplayLink displayLinkWithTarget:[RCTWeakProxy weakProxyWithTarget:self] selector:@selector(displayDidRefresh:)];
NSString *runLoopMode = [NSProcessInfo processInfo].activeProcessorCount > 1 ? NSRunLoopCommonModes : NSDefaultRunLoopMode;
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:runLoopMode];
}