Skip to content

Commit 33c5b61

Browse files
committed
fix(ios): mitigate media memory usage (#459)
1 parent fcbef0d commit 33c5b61

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ios/IONAssetHandler.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)ur
2525
}
2626
}
2727
}
28-
29-
NSData * data = [[NSData alloc] initWithContentsOfFile:startPath];
28+
NSError * fileError = nil;
29+
NSData * data = nil;
30+
if ([self isMediaExtension:url.pathExtension]) {
31+
data = [NSData dataWithContentsOfFile:startPath options:NSDataReadingMappedIfSafe error:&fileError];
32+
}
33+
if (!data || fileError) {
34+
data = [[NSData alloc] initWithContentsOfFile:startPath];
35+
}
3036
NSInteger statusCode = 200;
3137
if (!data) {
3238
statusCode = 404;

0 commit comments

Comments
 (0)