question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: iOS - playing video from filesystem / support range requests

See original GitHub issue

Bug 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:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
sburnickicommented, Feb 9, 2022

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.

0reactions
ionitron-bot[bot]commented, Nov 10, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Streaming video in Safari: Why is it so difficult? - LogRocket Blog
The problem doesn't happen because of accept range requests (using the Accept-Ranges header), or for requests to open and play a video file....
Read more >
iOS and byte range video streaming not working
1) doesn't want to request a video with a byte range in the HTML video element - it wants to download the entire...
Read more >
why AVPlayer sends range | Apple Developer Forums
Hi,. I am writing my own HTTP web service server that supports iOS devices to view video files. On iOS I am using...
Read more >
Video playback issue on IOS | accept ranges:none - JBoss.org
We are facing issues while playing videos on IOS devices. We understood that for video to play successfully on Ios requires range headers ......
Read more >
Content-range support for file_transfer() [#91934] | Drupal.org
A patch that adds file transfer resume support by accepting byte ranges and ... the range extends beyond the size of the file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found