Skip to content

Commit

Permalink
fix(ios): mitigate memory usage of media files (#2115)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Oct 30, 2019
1 parent a2a1165 commit 4b8fc3e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ios/Capacitor/Capacitor/CAPAssetHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class CAPAssetHandler: NSObject, WKURLSchemeHandler {
do {
var data = Data()
if !stringToLoad.contains("cordova.js") {
data = try Data(contentsOf: fileUrl)
if isMediaExtension(pathExtension: url.pathExtension) {
data = try Data(contentsOf: fileUrl, options: Data.ReadingOptions.mappedIfSafe)
} else {
data = try Data(contentsOf: fileUrl)
}
}
let mimeType = mimeTypeForExtension(pathExtension: url.pathExtension)
let expectedContentLength = data.count
Expand Down

0 comments on commit 4b8fc3e

Please sign in to comment.