Skip to content

Commit

Permalink
[ASVideoNodeDelegate] fix for TextureGroup#291 crash (TextureGroup#292)
Browse files Browse the repository at this point in the history
* Fixed bug where ASVideoNodeDelegate error reporting callback would crash an app because of not responding to selector;

refs TextureGroup#291

* updated changelog.md

* fixed typo in const name of ASVideoNodeDelegate method in delegate flags;

refs TextureGroup#292
  • Loading branch information
SergeyPetrachkov authored and bernieperez committed Apr 25, 2018
1 parent d529763 commit 6e5e65e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
- [Fix] Fix a potential crash when cell nodes that need layout are deleted during the same runloop. [Adlai Holler](https://github.com/Adlai-Holler) [#279](https://github.com/TextureGroup/Texture/pull/279)
- [Batch fetching] Add ASBatchFetchingDelegate that takes scroll velocity and remaining time into account [Huy Nguyen](https://github.com/nguyenhuy) [#281](https://github.com/TextureGroup/Texture/pull/281)
- [Fix] Fix a major regression in our image node contents caching. [Adlai Holler](https://github.com/Adlai-Holler) [#287](https://github.com/TextureGroup/Texture/pull/287)
- [Fix] Fixed a bug where ASVideoNodeDelegate error reporting callback would crash an app because of not responding to selector. [Sergey Petrachkov](https://github.com/Petrachkov) [#291](https://github.com/TextureGroup/Texture/issues/291)
6 changes: 5 additions & 1 deletion Source/ASVideoNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ @interface ASVideoNode ()
unsigned int delegateVideoNodeDidSetCurrentItem:1;
unsigned int delegateVideoNodeDidStallAtTimeInterval:1;
unsigned int delegateVideoNodeDidRecoverFromStall:1;
unsigned int delegateVideoNodeDidFailToLoadValueForKey:1;
} _delegateFlags;

BOOL _shouldBePlaying;
Expand Down Expand Up @@ -153,7 +154,9 @@ - (void)prepareToPlayAsset:(AVAsset *)asset withKeys:(NSArray<NSString *> *)requ
AVKeyValueStatus keyStatus = [asset statusOfValueForKey:key error:&error];
if (keyStatus == AVKeyValueStatusFailed) {
NSLog(@"Asset loading failed with error: %@", error);
[self.delegate videoNode:self didFailToLoadValueForKey:key asset:asset error:error];
if (_delegateFlags.delegateVideoNodeDidFailToLoadValueForKey) {
[self.delegate videoNode:self didFailToLoadValueForKey:key asset:asset error:error];
}
}
}

Expand Down Expand Up @@ -604,6 +607,7 @@ - (void)setDelegate:(id<ASVideoNodeDelegate>)delegate
_delegateFlags.delegateVideoNodeDidSetCurrentItem = [delegate respondsToSelector:@selector(videoNode:didSetCurrentItem:)];
_delegateFlags.delegateVideoNodeDidStallAtTimeInterval = [delegate respondsToSelector:@selector(videoNode:didStallAtTimeInterval:)];
_delegateFlags.delegateVideoNodeDidRecoverFromStall = [delegate respondsToSelector:@selector(videoNodeDidRecoverFromStall:)];
_delegateFlags.delegateVideoNodeDidFailToLoadValueForKey = [delegate respondsToSelector:@selector(videoNode:didFailToLoadValueForKey:asset:error:)];
}
}

Expand Down

0 comments on commit 6e5e65e

Please sign in to comment.