#1 July 31, 2014 7:26am

jono_hayward
Member
From: Melbourne, Australia
Registered: June 29, 2014
Posts: 11

.htaccess rewrites interfering with video playback on iOS

So I'm not sure if this should go into the bug report forum or not, but here goes.

I'm building a site at the moment on BigTree that employs self-hosted videos (with HTML5 <video> on the front-end). For a couple of days, I could not, no matter what I tried, make the videos play on iOS devices.

For reference, my videos were stored in /site/files/dictionary/videos/1.mp4. But on the front-end, I was referencing them simply via /files/dictionary/videos/1.mp4 because I know that normally the .htaccess rewrites will transparently send the file through correctly. And on desktop browsers, that's what was happening. But for some reason iOS browsers simply refused to play ball: they'd recognise that I was trying to look at a video file, and bring up the video playback UI, but would completely fail to load it.

Eventually, I discovered the problem: if I went into my unix terminal and tried to access the video file via curl, the output would be the BigTree 404 page template, not the video itself. I just thought that maybe curl somehow doesn't respect mod_rewrite, but it did get me thinking about what the iOS browsers were doing. So on my iPad I tried to access the file with the /site/ part of the URL included and - hey presto - it worked.

So this is a long-winded way of saying that BigTree's default .htaccess rewriting seems to interfere with certain operations on iOS browsers smile

Offline

#2 July 31, 2014 8:50am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: .htaccess rewrites interfering with video playback on iOS

That's super strange. I'll add this to an internal bug list and see if we can reproduce it and fix it. Thanks for the report!

Offline

#3 August 12, 2014 7:31pm

jono_hayward
Member
From: Melbourne, Australia
Registered: June 29, 2014
Posts: 11

Re: .htaccess rewrites interfering with video playback on iOS

Thanks for the response Tim!

I'm actually still encountering this issue. I'm not entirely sure what's triggered it this time as it was working perfectly for a while, but for now on my local development server, iOS refuses to open .mp4 videos located in /site/files/.

I've done some trial-and-error investigation by commenting out different sections of the /site/.htaccess file, and discovered that this section seems to be causing issues. If it's commented out, videos play fine, but if it's left in there iOS just shows a play icon with a line through it indicating the file can't be opened:

  # html, txt, css, js, json, xml, htc:
  <IfModule filter_module>
   FilterDeclare   COMPRESS
   FilterProvider  COMPRESS  DEFLATE resp=Content-Type /text/(html|css|javascript|plain|x(ml|-component))/
   FilterProvider  COMPRESS  DEFLATE resp=Content-Type /application/(javascript|json|xml|x-javascript)/
   FilterChain	 COMPRESS
   FilterProtocol  COMPRESS  change=yes;byteranges=no
 </IfModule>

I don't know anywhere near enough about Apache module configuration to understand what that's doing, but my first guess was that it was interfering with the content-type response from the server. However, viewing the response headers with Curl indicates it's still being passed as video/mp4:

Jonos-Shiny-Macbook-Pro:~ jonathonhayward$ curl -I http://sacd.dev/site/files/dictionary/videos/1.mp4
HTTP/1.1 200 OK
Date: Wed, 13 Aug 2014 00:29:09 GMT
Server: Apache/2.2.26 (Unix) DAV/2 PHP/5.4.24 mod_ssl/2.2.26 OpenSSL/0.9.8y
Last-Modified: Tue, 12 Aug 2014 14:49:48 GMT
ETag: "1aa76e8-ac736-5006fc8747b00"
Accept-Ranges: bytes
Content-Length: 706358
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Permitted-Cross-Domain-Policies: master-only
Content-Type: video/mp4

.

So I'm really not sure what's going on here.

Any thoughts?

Offline

#4 August 12, 2014 7:40pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: .htaccess rewrites interfering with video playback on iOS

I've heard of Apache improperly serving up things with deflate, but this is the first time I've seen it happen.
Deflate is basically gzip -- it compresses text content and makes it nicer. I'm guessing it's re-compressing the video and that's what's causing issues.

Can you remove that portion and replace it with this code and see if it fixes the issue? (this is from HTML5 Boilerplate -- if it works then we'll probably switch to this version going forward).

<IfModule mod_deflate.c>
	<IfModule mod_setenvif.c>
		<IfModule mod_headers.c>
			SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
			RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
		</IfModule>
	</IfModule>
	<IfModule mod_mime.c>
		AddEncoding gzip svgz
	</IfModule>
	<IfModule mod_filter.c>
		AddOutputFilterByType DEFLATE "application/atom+xml" \
			"application/javascript" \
			"application/json" \
			"application/ld+json" \
			"application/manifest+json" \
			"application/rss+xml" \
			"application/vnd.geo+json" \
			"application/vnd.ms-fontobject" \
			"application/x-font-ttf" \
			"application/x-web-app-manifest+json" \
			"application/xhtml+xml" \
			"application/xml" \
			"font/opentype" \
			"image/svg+xml" \
			"image/x-icon" \
			"text/cache-manifest" \
			"text/css" \
			"text/html" \
			"text/plain" \
			"text/vtt" \
			"text/x-component" \
			"text/xml"
	</IfModule>
</IfModule>

Offline

#5 August 13, 2014 1:53am

jono_hayward
Member
From: Melbourne, Australia
Registered: June 29, 2014
Posts: 11

Re: .htaccess rewrites interfering with video playback on iOS

Yep, that's worked and the videos are now playing normally, thanks! big_smile

Offline

#6 August 13, 2014 8:45am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 974

Re: .htaccess rewrites interfering with video playback on iOS

Awesome, thanks for the confirmation! I'll try to roll that out in the 4.0.6/4.1.2 releases.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.