mirror of
https://github.com/TextureGroup/Texture.git
synced 2026-04-07 19:17:39 +00:00
Fix a deadlock with display link
This commit is contained in:
@@ -65,13 +65,12 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
|
||||
};
|
||||
}
|
||||
|
||||
animatedImage.playbackReadyCallback = ^{
|
||||
// In this case the lock is already gone we have to call the unlocked version therefore
|
||||
[weakSelf setShouldAnimate:YES];
|
||||
};
|
||||
if (animatedImage.playbackReady) {
|
||||
[self _locked_setShouldAnimate:YES];
|
||||
} else {
|
||||
animatedImage.playbackReadyCallback = ^{
|
||||
// In this case the lock is already gone we have to call the unlocked version therefore
|
||||
[weakSelf setShouldAnimate:YES];
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,11 +216,13 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
|
||||
NSLog(@"starting animation: %p", self);
|
||||
#endif
|
||||
|
||||
// Get frame interval before holding display link lock to avoid deadlock
|
||||
NSUInteger frameInterval = self.animatedImage.frameInterval;
|
||||
ASDN::MutexLocker l(_displayLinkLock);
|
||||
if (_displayLink == nil) {
|
||||
_playHead = 0;
|
||||
_displayLink = [CADisplayLink displayLinkWithTarget:[ASWeakProxy weakProxyWithTarget:self] selector:@selector(displayLinkFired:)];
|
||||
_displayLink.frameInterval = self.animatedImage.frameInterval;
|
||||
_displayLink.frameInterval = frameInterval;
|
||||
|
||||
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:_animatedImageRunLoopMode];
|
||||
} else {
|
||||
@@ -262,7 +263,9 @@ NSString *const ASAnimatedImageDefaultRunLoopMode = NSRunLoopCommonModes;
|
||||
if (self.animatedImage.coverImageReady) {
|
||||
[self setCoverImage:self.animatedImage.coverImage];
|
||||
}
|
||||
[self startAnimating];
|
||||
if (self.animatedImage.playbackReady) {
|
||||
[self startAnimating];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didExitVisibleState
|
||||
|
||||
Reference in New Issue
Block a user