Skip to content

Commit

Permalink
Don't allocate a CADisplayLink for static images
Browse files Browse the repository at this point in the history
Summary:
@public
The mass majority of RCTUIImageViewAnimated uses are actually for static images. As such, we don't need to create a CADisplayLink.

Reviewed By: shergin

Differential Revision: D16945038

fbshipit-source-id: a7cb63000987d1ea7a8a9b4d596e1e474709d2ac
  • Loading branch information
Mehdi Mulani authored and facebook-github-bot committed Aug 22, 2019
1 parent 59f84ca commit 2211eb5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Libraries/Image/RCTUIImageViewAnimated.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ - (NSOperationQueue *)fetchQueue

- (CADisplayLink *)displayLink
{
// 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) {
_displayLink = [CADisplayLink displayLinkWithTarget:[RCTWeakProxy weakProxyWithTarget:self] selector:@selector(displayDidRefresh:)];
NSString *runLoopMode = [NSProcessInfo processInfo].activeProcessorCount > 1 ? NSRunLoopCommonModes : NSDefaultRunLoopMode;
Expand Down

0 comments on commit 2211eb5

Please sign in to comment.