Skip to content

Commit

Permalink
Fix the crash issue on Real ARM64 device
Browse files Browse the repository at this point in the history
  • Loading branch information
dreampiggy committed Nov 18, 2019
1 parent 5542331 commit 47c61c1
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#endif

#define AVDataAssetClass @"AVDataAsset"
#define AVDataAssetMaxLength 1048576
@protocol AVDataAssetProtocol <NSObject>

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

AVAsset *asset;
Class cls = NSClassFromString(AVDataAssetClass);
if (type.length > 0 && [cls instancesRespondToSelector:@selector(initWithData:contentType:)]) {
if ([cls instancesRespondToSelector:@selector(initWithData:contentType:)] && data.length < AVDataAssetMaxLength && type.length > 0) {
// Prefer Data Asset if available
asset = [[cls alloc] initWithData:data contentType:type];
} else {
// Random file name
Expand All @@ -48,7 +50,6 @@ + (instancetype)sd_assetImageGeneratorWithVideoData:(NSData *)data contentType:(
NSURL *fileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fileName]];
[data writeToURL:fileURL atomically:NO];
asset = [[AVURLAsset alloc] initWithURL:fileURL options:nil];
[NSFileManager.defaultManager removeItemAtURL:fileURL error:nil];
}
if (!asset) {
return nil;
Expand Down

0 comments on commit 47c61c1

Please sign in to comment.