Comments (4)
Maybe it's the same issue as this one?
It seems to be fixed since iOS 15.6 at least.
The only fix I've found so far is to use version 2 of this plugin, which handles the files differently, and to wait 1 or 2 years for our users to update their iOS before switching to the last version...
from cordova-plugin-ionic-webview.
Thanks for your reply - I'm actually using iOS 16 on my device so I don't think this is it. I do notice there's some code in IONAssetHandler that's responsible for 'serving' the video - it appears to load the entire contents of the media file (into virtual memory which is good) and then somehow serve it through the response. This gets called repeatedly as the video is buffering/before play starts. I think this must have something to do with the issue. I suspect there must be some way to stream the data here, but I'm not sure how:
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
{
NSString * startPath = @"";
NSURL * url = urlSchemeTask.request.URL;
NSString * stringToLoad = url.path;
NSString * scheme = url.scheme;
if ([scheme isEqualToString:self.scheme]) {
if ([stringToLoad hasPrefix:@"/_app_file_"]) {
startPath = [stringToLoad stringByReplacingOccurrencesOfString:@"/_app_file_" withString:@""];
} else {
startPath = self.basePath ? self.basePath : @"";
if ([stringToLoad isEqualToString:@""] || [url.pathExtension isEqualToString:@""]) {
startPath = [startPath stringByAppendingString:@"/index.html"];
} else {
startPath = [startPath stringByAppendingString:stringToLoad];
}
}
}
NSError * fileError = nil;
NSData * data = nil;
if ([self isMediaExtension:url.pathExtension]) {
// ENTIRE CONTENTS OF MEDIA FILE IS LOADED:
data = [NSData dataWithContentsOfFile:startPath options:NSDataReadingMappedIfSafe error:&fileError];
}
if (!data || fileError) {
data = [[NSData alloc] initWithContentsOfFile:startPath];
}
NSInteger statusCode = 200;
if (!data) {
statusCode = 404;
}
NSURL * localUrl = [NSURL URLWithString:url.absoluteString];
NSString * mimeType = [self getMimeType:url.pathExtension];
id response = nil;
if (data && [self isMediaExtension:url.pathExtension]) {
response = [[NSURLResponse alloc] initWithURL:localUrl MIMEType:mimeType expectedContentLength:data.length textEncodingName:nil];
} else {
NSDictionary * headers = @{ @"Content-Type" : mimeType, @"Cache-Control": @"no-cache"};
response = [[NSHTTPURLResponse alloc] initWithURL:localUrl statusCode:statusCode HTTPVersion:nil headerFields:headers];
}
[urlSchemeTask didReceiveResponse:response];
[urlSchemeTask didReceiveData:data]; // DATA IS "SERVED" , BUT THIS GETS CALLED REPEATEDLY
[urlSchemeTask didFinish];
}
A potential hint at a solution:
https://stackoverflow.com/questions/58217566/how-to-serve-big-files-using-wkurlschemehandler
from cordova-plugin-ionic-webview.
could be missing range headers when fetching from local file system, without range headers the entire file will be loaded.
from cordova-plugin-ionic-webview.
Thanks for the reply, that sounds promising. Do you have an idea for how to have the ionic webview accept range headers? Or supply them in the request somehow? It might actually need to happen somewhere in the code I posted.
from cordova-plugin-ionic-webview.
Related Issues (20)
- The input control cannot hide the keyboard
- navigation to non-allowed URL
- [iOS 15.5] Incorrect events on canvas long press HOT 1
- New Window Not open if using Stripe Hosted Payment Page (see video)
- ERROR:aw_browser_terminator.cc(123) HOT 1
- uploading to the app store / Asset validation failed HOT 1
- Autofocus not centering field in view
- Problem when set fullscreen mode for some video inside WebView content
- Html canβt load local video on iOS
- Impossible to publish to appstore. iOS 16.1 SDK target
- ios 16.1 SDK support
- Cannot debug the webview with safari inspect tool HOT 1
- On iPhone devices screen is zoomed in and fails to resize back after user enters input
- Trying to use import modules using the plugin does not work - any way to get around this?
- Plugins won't load on iOS with ionic urls
- How to used in pdf-generator plugin
- apps using IonicWebViewEngine fails to load on pixel phones running android 14
- Plaid OAuth Integration Feature
- [iOS]add option textInteractionEnabled support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-ionic-webview.