Skip to content

Commit

Permalink
Use node lock instead of separate one to avoid deadlocks. (#582)
Browse files Browse the repository at this point in the history
* Use node lock instead of separate one to avoid deadlocks.

* Add CHANGELOG entry
  • Loading branch information
garrettmoon authored and nguyenhuy committed Sep 27, 2017
1 parent 9e178dc commit 6c00897
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## master

* Add your own contributions to the next release on the line below this with your name.
- [ASNetworkImageNode] Fix deadlock in GIF handling. [#582](https://github.com/TextureGroup/Texture/pull/582) [Garrett Moon](https://github.com/garrettmoon)
- [ASDisplayNode] Add attributed versions of a11y label, hint and value. [#554](https://github.com/TextureGroup/Texture/pull/554) [Alexander Hüllmandel](https://github.com/fruitcoder)
- [ASCornerRounding] Introduce .cornerRoundingType: CALayer, Precomposited, or Clip Corners. [Scott Goodson](https://github.com/appleguy) [#465](https://github.com/TextureGroup/Texture/pull/465)
- [Yoga] Add insertYogaNode:atIndex: method. Improve handling of relayouts. [Scott Goodson](https://github.com/appleguy)
Expand Down
19 changes: 10 additions & 9 deletions Source/ASImageNode+AnimatedImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import <AsyncDisplayKit/ASAssert.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
#import <AsyncDisplayKit/ASDisplayNode+Subclasses.h>
#import <AsyncDisplayKit/ASDisplayNode+FrameworkSubclasses.h>
#import <AsyncDisplayKit/ASDisplayNodeExtras.h>
#import <AsyncDisplayKit/ASEqualityHelpers.h>
#import <AsyncDisplayKit/ASImageNode+Private.h>
Expand All @@ -43,7 +44,7 @@ @implementation ASImageNode (AnimatedImage)

- (void)setAnimatedImage:(id <ASAnimatedImageProtocol>)animatedImage
{
ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
[self _locked_setAnimatedImage:animatedImage];
}

Expand Down Expand Up @@ -85,13 +86,13 @@ - (void)animatedImageSet:(id <ASAnimatedImageProtocol>)newAnimatedImage previous

- (id <ASAnimatedImageProtocol>)animatedImage
{
ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
return _animatedImage;
}

- (void)setAnimatedImagePaused:(BOOL)animatedImagePaused
{
ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);

_animatedImagePaused = animatedImagePaused;

Expand All @@ -100,13 +101,13 @@ - (void)setAnimatedImagePaused:(BOOL)animatedImagePaused

- (BOOL)animatedImagePaused
{
ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
return _animatedImagePaused;
}

- (void)setCoverImageCompleted:(UIImage *)coverImage
{
ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
[self _locked_setCoverImageCompleted:coverImage];
}

Expand All @@ -123,7 +124,7 @@ - (void)_locked_setCoverImageCompleted:(UIImage *)coverImage

- (void)setCoverImage:(UIImage *)coverImage
{
ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
[self _locked_setCoverImage:coverImage];
}

Expand Down Expand Up @@ -161,7 +162,7 @@ - (void)setAnimatedImageRunLoopMode:(NSString *)runLoopMode

- (void)setShouldAnimate:(BOOL)shouldAnimate
{
ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
[self _locked_setShouldAnimate:shouldAnimate];
}

Expand Down Expand Up @@ -194,7 +195,7 @@ - (void)startAnimating
{
ASDisplayNodeAssertMainThread();

ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
[self _locked_startAnimating];
}

Expand Down Expand Up @@ -233,7 +234,7 @@ - (void)stopAnimating
{
ASDisplayNodeAssertMainThread();

ASDN::MutexLocker l(_animatedImageLock);
ASDN::MutexLocker l(__instanceLock__);
[self _locked_stopAnimating];
}

Expand Down
1 change: 0 additions & 1 deletion Source/Private/ASImageNode+AnimatedImagePrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ extern NSString *const ASAnimatedImageDefaultRunLoopMode;

@interface ASImageNode ()
{
ASDN::RecursiveMutex _animatedImageLock;
ASDN::Mutex _displayLinkLock;
id <ASAnimatedImageProtocol> _animatedImage;
BOOL _animatedImagePaused;
Expand Down

0 comments on commit 6c00897

Please sign in to comment.