Skip to content

Commit 47c61c1

Browse files
committed
Fix the crash issue on Real ARM64 device
1 parent 5542331 commit 47c61c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SDWebImageVideoCoder/Classes/AVAssetImageGenerator+SDAdditions.m

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#endif
1414

1515
#define AVDataAssetClass @"AVDataAsset"
16+
#define AVDataAssetMaxLength 1048576
1617
@protocol AVDataAssetProtocol <NSObject>
1718

1819
- (instancetype)initWithData:(NSData *)data contentType:(AVFileType)type;
@@ -34,7 +35,8 @@ + (instancetype)sd_assetImageGeneratorWithVideoData:(NSData *)data contentType:(
3435

3536
AVAsset *asset;
3637
Class cls = NSClassFromString(AVDataAssetClass);
37-
if (type.length > 0 && [cls instancesRespondToSelector:@selector(initWithData:contentType:)]) {
38+
if ([cls instancesRespondToSelector:@selector(initWithData:contentType:)] && data.length < AVDataAssetMaxLength && type.length > 0) {
39+
// Prefer Data Asset if available
3840
asset = [[cls alloc] initWithData:data contentType:type];
3941
} else {
4042
// Random file name
@@ -48,7 +50,6 @@ + (instancetype)sd_assetImageGeneratorWithVideoData:(NSData *)data contentType:(
4850
NSURL *fileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fileName]];
4951
[data writeToURL:fileURL atomically:NO];
5052
asset = [[AVURLAsset alloc] initWithURL:fileURL options:nil];
51-
[NSFileManager.defaultManager removeItemAtURL:fileURL error:nil];
5253
}
5354
if (!asset) {
5455
return nil;

0 commit comments

Comments
 (0)