Apple’s painfully unstable live stream was caused by bad JavaScript

By

appletvtruckschedule
The new landscape view of the iPhone 6 Plus. Photo: Chris Roman

Apple Watch might have stolen the spotlight at the Flint Center yesterday, but for many fans, tuning into the first 30 minutes was as impossible as scratching sapphire crystal glass.

Fans trying to watch the event via Apple TV and Safari were greeted by colorful bars and an Apple TV truck schedule. Even if you could get connected to the live stream, understanding Tim Cook and Phil Schiller was nearly impossible thanks to a Chinese translation track play loudly over the main feed.

It was an absolute disaster for the first 30 minutes from a company that executes marketing events with zen-like precision, but according to Dan Rayburn at Streaming Media, a few simple errors is all it took to bring down the show. After digging into the meta data and code from Apple’s site, Rayburn found the root of the problem: A couple lines of JavaScript.

Apple decided to add some JSON (JavaScript Object Notation) code to the apple.com page which added an interactive element on the bottom showing tweets about the event. As a result, this was causing the page to make refresh calls every few milliseconds. By Apple making the decision to add the JSON code, it made the apple.com website un-cachable…which causes a huge impact on the performance when it comes to loading the page and the stream”

Because of all the refresh calls from the JSON code, it looks like it artificially forced the player to degrade the quality of the video, dropping it down to a lower bitrate, because it thought there were more requests for the stream than there was.”

Apple only relied on Akamai’s content delivery network for the video stream, but their servers couldn’t cache the page because of the JSON code. Any performance problems on the page also impacted the video because Apple embeded it directly onto the web page.

Ok, but what about the annoying Chinese translator yapping over Tim and Phil for the first 27 minutes? That’s all on Apple. An employee must not have set up the encoder right, and the primary and backup streams were out of sync (that could also explain the dual songs before the event).

Rayburn says he believes the encoders were rebooted after the event started, which is why Apple TV and iOS users received “could not load movie” and “you don’t have permission to access” error messages when trying to access the feed.

Source: Streaming Media