0
votes

I'm using the standard YouTube iFrame player as defined here within a Webview on IOS. Everything works as it should, except the videos consistently take over 6 seconds to load on a broadband network. When I use Safari to load the exact same video on the Youtbue.com, on the same network, using the same iPad, the video consistently loads in under 3 seconds.

Does anyone know why the IOS Webview videos are taking twice as long to load ?

Or is YouTube (owned by Google) deliberately loading videos on their website faster than apps using their player apis ?

A couple other data points as to my methodology: 1) I'm only measuring the time for a video to load in my app, not the loading of the webview or even the html page within the webview that contains the Youtube iframe. I start measuring after the webview has loaded the Youtube iFrame. 2) The Youtube App performs similarly to the YouTube website using Safari. I assume Youtube App uses a Webview. 3) The results seem to vary on different days. YouTube Website and App videos are always faster on average, but the amount varies by days.

1

1 Answers

0
votes

I feel the "(owned by Google)" comment suggests some alterer motive which I don't believe exists..

There are several different issues which may be at work here:

1) You seem to be testing Youtube.com using Mobile Safari, and testing the embedded player using a webview:

This is not a fair comparison, as the webview has been shown to be very significantly slower than safari. (e.g. http://www.guypo.com/mobile/ios-browsers-speed-bakeoff/ )

2) You do not make it clear exactly what load time you are measuring

Are you creating the webview in this time and setting up the browser environment?

Are you loading the document which includes the script tag for the embedded player code in this time?

Did Safari have a hot cache for youtube.com at the time you loaded the video?

Many browsers start loading requests in the background as you type, before you tap to load a page - these kind of performance tweaks can significantly reduce apparent time to load a site, but make comparisons difficult.

3) The common user story they are optimising for is different

In almost all situations where the YouTube player API is inserted into a page or a website, the video does not automatically start playing.

By comparison, almost every YouTube watch page load begins playing the video automatically.

One of the optimisations which YouTube have discussed in presentations before is in-lining the first part of the video stream into the page even before the video player loads.

This is a trade-off of extra user bandwidth for faster video playback which makes sense when you know the user is going to definitely play the video: however if they were to do this for embedded videos then it would significantly slow down the loading time for players with videos which did not always start playing - which is a fairly significant percentage of all of the websites in the world!

4) YouTube get involved at different points in the two cases, and can only start optimising the experience later for embedded players.

YouTube is able to do optimisations on youtube.com which it is unable to do on third party sites/apps using their html5 player API.

In the case of watching a video on youtube.com: YouTube are involved right from the first http request - they know which video you are playing, and they know which browser you say you are on (so can optimise the experience as much as possible to pre-load the correct video and/or video player).

In the case of embedding an iframe:

  • The browser first loads your page, which it then has to parse and extract urls from.
  • Then it makes a request for javascript from YouTube (note that if you are using the javascript player API rather than the embedded iframe direct then that needs to be cached on the browser, so YouTube still can't optimise performance of this video at this point)
  • Once your entire page has finished loading, it can create an iframe pointing to YouTube (all of this takes time on the CPU and memory management time)
  • At this point, YouTube can start optimising things to try to make the experience faster.