Skip to content

Commit cbd526d

Browse files
authored
fix(ios): mitigate media memory usage (#459)
1 parent 173a313 commit cbd526d

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
@@ -36,8 +36,14 @@ - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)ur
3636
}
3737
}
3838
}
39-
40-
NSData * data = [[NSData alloc] initWithContentsOfFile:startPath];
39+
NSError * fileError = nil;
40+
NSData * data = nil;
41+
if ([self isMediaExtension:url.pathExtension]) {
42+
data = [NSData dataWithContentsOfFile:startPath options:NSDataReadingMappedIfSafe error:&fileError];
43+
}
44+
if (!data || fileError) {
45+
data = [[NSData alloc] initWithContentsOfFile:startPath];
46+
}
4147
NSInteger statusCode = 200;
4248
if (!data) {
4349
statusCode = 404;

0 commit comments

Comments
 (0)