When serving an Apache Cordova or Ionic Capacitor app from a custom scheme, if the app contains a video tag, it makes multiple requests to the video file (I guess it's to return the video in chunks).
The problem is, the requests don't include Range headers, so it's impossible to return just the chunks, and also, as it's requested multiple times, the memory increases a lot.
When using a WKURLSchemeHandler, the requests should include Range headers so the video can be returned by the requested chunks.
Alternatively, if the app is being served from a custom scheme, then a single request should be made to the WKURLSchemeHandler (when serving the app from file:// protocol only a request is made)
Sample project reproducing the issue (without using Apache Cordova nor Ionic Capacitor to simplify the code)
Check the WebViewHandler class, it prints urlSchemeTask.request.allHTTPHeaderFields content and it doesn't include Range.
Also if the app is inspected in Safari remote inspector, the requests don't show Range in headers neither.
WKURLSchemeHandler is behaving correctly here, and on Mac the same code has a range request. The problem is on iOS the request we receive from AVAssetResourceLoader does not have a range request, but on Mac the request we receive in the WebCoreNSURLSession has a range request. I'm uploading a test that verifies this is the case.
Created attachment 381757 [details]
Comment on attachment 381757 [details]
Can you file a bug report for AVAssetResourceLoader?
Are you asking me or somebody else?
In case it's me, where should I report the new issue?
I think he was asking me to report another bug and use this just to commit the test that verifies existing behavior. I'm still talking to people and deciding what to do about this.
We have faced the same no Range header problem using WKURLSchemeHandler for custom video scheme on iOS.
Does it still remain an unresolved bug even after 6 months later from the first report?
Nonetheless, is there any one who happens to know how to detour this bug so that we can manage to catch the Range data from AVAssetResourceLoader?
It is so desperate to finalize our project.
Hi, any new on this? Is there anywhere we can follow this issue(AVAssetResourceLoader or something else)?
Hello, is there anything new in this Bug? The problem persists and makes it impossible to view larger files from local storage.
Created attachment 427459 [details]
Comment on attachment 427459 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=427459&action=review
r=me - plz fix test build
> + @"Content-Range" : [NSString stringWithFormat:@"bytes %llu-%llu/%lu", rangeBegin, rangeEnd, [videoData length]],
> + @"Content-Length" : [NSString stringWithFormat:@"%llu", rangeEnd - rangeBegin + 1]
/Volumes/Data/worker/watchOS-7-Build-EWS/build/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:1513:105: error: values of type 'NSUInteger' should not be used as format arguments; add an explicit cast to 'unsigned long' instead [-Werror,-Wformat]
Created attachment 427464 [details]
iOS test failures look related. Will investigate.
It seems like blob URLs are going through this path too. I'm going to exclude the blob protocol.
Created attachment 427587 [details]