bug: iOS - playing video from filesystem / support range requests
See original GitHub issueBug Report
As already known, video playback from filesystem on iOS makes trouble. iOS 15 makes this problem even worse as it requests more and smaller chunks, so even small videos don’t work. The according apple bug with range headers seems to be fixed, so an implementation should be doable by now. See details below.
Capacitor Version
@capacitor/core: 3.4.0
Platform(s)
iOS > 15.0
Current Behavior
Starting from iOS 15 there are also issues playing medium sized videos (like 10-20MB) from file system. The initial delay is huge and playback is laggy.
Expected Behavior
The range header should be parsed and respected, so smooth and instant video playback from filesystem is working on all iOS versions that include the according bugfix from apple.
Code Reproduction
https://github.com/jcesarmobile/no-ranges-bug
Additional Context
Investigating the issues, I found that there are more/smaller range requests on video playback in iOS 15, probably since video playback was moved to GPU (see related webkit bug). This causes even small and medium sized video to be requested a few hundred times, since capacitor doesn’t support range requests, resulting in initalial playback delay and lagging playback.
I also found the closed issues here, the webkit bug that caused this and the demo project from you @jcesarmobile.
However, the bug seems to be closed by now, and executing the demo code on Simulator/iPhone11/iOS 15.2 gives me the following example output:
Optional(["Range": "bytes=2498560-2551807", "X-Playback-Session-Id": "00ECD4FA-B8B3-4B97-A121-DBD633B2EA7E", "Accept": "*/*", "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"])
urlSchemeTask.request.allHTTPHeaderFields Optional(["Accept": "*/*", "Range": "bytes=2551808-2555903", "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148", "X-Playback-Session-Id": "00ECD4FA-B8B3-4B97-A121-DBD633B2EA7E"])
So it looks like it should be possible now to implement range request on iOS, right?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:8 (1 by maintainers)
Top GitHub Comments
I created a working version based on the code reproduction repo, supporting range requests: https://github.com/sburnicki/no-ranges-bug (forking on github wasn’t possible atm, so did it locally) with this codes, the video plays after only a short delay and smoothly on Simulator/iPhone11/iOS 15.2
I didn’t find a way on how to avoid the initial short delay. I’m not sure if this is a problem of not answering the requests fast enough or a general webkit implementation problem.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.