Skip to content

Commit 0e4d48a

Browse files
SergeyPetrachkovnguyenhuy
authored andcommitted
[ASVideoNodeDelegate] fix for #291 crash (#292)
* Fixed bug where ASVideoNodeDelegate error reporting callback would crash an app because of not responding to selector; refs #291 * updated changelog.md * fixed typo in const name of ASVideoNodeDelegate method in delegate flags; refs #292
1 parent d30c357 commit 0e4d48a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
- [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)
2626
- [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)
2727
- [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)
28+
- [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)

Source/ASVideoNode.mm

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ @interface ASVideoNode ()
5858
unsigned int delegateVideoNodeDidSetCurrentItem:1;
5959
unsigned int delegateVideoNodeDidStallAtTimeInterval:1;
6060
unsigned int delegateVideoNodeDidRecoverFromStall:1;
61+
unsigned int delegateVideoNodeDidFailToLoadValueForKey:1;
6162
} _delegateFlags;
6263

6364
BOOL _shouldBePlaying;
@@ -153,7 +154,9 @@ - (void)prepareToPlayAsset:(AVAsset *)asset withKeys:(NSArray<NSString *> *)requ
153154
AVKeyValueStatus keyStatus = [asset statusOfValueForKey:key error:&error];
154155
if (keyStatus == AVKeyValueStatusFailed) {
155156
NSLog(@"Asset loading failed with error: %@", error);
156-
[self.delegate videoNode:self didFailToLoadValueForKey:key asset:asset error:error];
157+
if (_delegateFlags.delegateVideoNodeDidFailToLoadValueForKey) {
158+
[self.delegate videoNode:self didFailToLoadValueForKey:key asset:asset error:error];
159+
}
157160
}
158161
}
159162

@@ -604,6 +607,7 @@ - (void)setDelegate:(id<ASVideoNodeDelegate>)delegate
604607
_delegateFlags.delegateVideoNodeDidSetCurrentItem = [delegate respondsToSelector:@selector(videoNode:didSetCurrentItem:)];
605608
_delegateFlags.delegateVideoNodeDidStallAtTimeInterval = [delegate respondsToSelector:@selector(videoNode:didStallAtTimeInterval:)];
606609
_delegateFlags.delegateVideoNodeDidRecoverFromStall = [delegate respondsToSelector:@selector(videoNodeDidRecoverFromStall:)];
610+
_delegateFlags.delegateVideoNodeDidFailToLoadValueForKey = [delegate respondsToSelector:@selector(videoNode:didFailToLoadValueForKey:asset:error:)];
607611
}
608612
}
609613

0 commit comments

Comments
 (0)