RESOLVED FIXED 203302
WKWebView: WKURLSchemeHandler request don't have Range headers
https://bugs.webkit.org/show_bug.cgi?id=203302
Summary WKWebView: WKURLSchemeHandler request don't have Range headers
jcesarmobile
Reported 2019-10-23 10:30:02 PDT
The problem: 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. Expected: 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) https://github.com/jcesarmobile/no-ranges-bug Check the WebViewHandler class, it prints urlSchemeTask.request.allHTTPHeaderFields content and it doesn't include Range. https://github.com/jcesarmobile/no-ranges-bug/blob/master/no-ranges-bug/WebViewHandler.swift#L34 Also if the app is inspected in Safari remote inspector, the requests don't show Range in headers neither.
Attachments
Patch (2.47 KB, patch)
2019-10-23 17:27 PDT, Alex Christensen
no flags
Patch (6.31 KB, patch)
2021-04-30 15:34 PDT, Alex Christensen
ews-feeder: commit-queue-
Patch (6.34 KB, patch)
2021-04-30 15:51 PDT, Alex Christensen
no flags
Patch (6.39 KB, patch)
2021-05-03 12:46 PDT, Alex Christensen
ews-feeder: commit-queue-
Radar WebKit Bug Importer
Comment 1 2019-10-23 15:32:45 PDT
Alex Christensen
Comment 2 2019-10-23 17:25:53 PDT
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.
Alex Christensen
Comment 3 2019-10-23 17:27:19 PDT
Geoffrey Garen
Comment 4 2019-10-23 20:08:45 PDT
Comment on attachment 381757 [details] Patch r=me Can you file a bug report for AVAssetResourceLoader?
jcesarmobile
Comment 5 2019-10-28 11:44:51 PDT
Are you asking me or somebody else? In case it's me, where should I report the new issue?
Alex Christensen
Comment 6 2019-10-28 14:34:14 PDT
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.
Taehyun Kim
Comment 7 2020-04-22 21:13:52 PDT
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.
jbgt
Comment 8 2020-09-03 06:10:43 PDT
Hi, any new on this? Is there anywhere we can follow this issue(AVAssetResourceLoader or something else)?
Felix Wansing
Comment 9 2021-03-15 13:46:14 PDT
Hello, is there anything new in this Bug? The problem persists and makes it impossible to view larger files from local storage.
Alex Christensen
Comment 10 2021-04-30 15:34:36 PDT
Geoffrey Garen
Comment 11 2021-04-30 15:48:51 PDT
Comment on attachment 427459 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=427459&action=review r=me - plz fix test build > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:1514 > + @"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]
Alex Christensen
Comment 12 2021-04-30 15:51:46 PDT
Alex Christensen
Comment 13 2021-05-01 18:29:27 PDT
iOS test failures look related. Will investigate.
Alex Christensen
Comment 14 2021-05-03 12:45:14 PDT
It seems like blob URLs are going through this path too. I'm going to exclude the blob protocol.
Alex Christensen
Comment 15 2021-05-03 12:46:09 PDT
Alex Christensen
Comment 16 2021-05-03 15:53:43 PDT
Note You need to log in before you can comment on or make changes to this bug.