Black youtube screen - analysis
Black youtube screen - analysis
2/12/17 11:44 PM
|

Got hit by a youtube ad bug tonight - resulting in black screen and no video playback if I am logged in, but everything seems to be working when I log out. Tried with Edge and Chrome, both reproduce the issue. I've googled for "youtube black screen" and there seem to be a lot of annoyed users who regulary get hit by something similar. 

Exception is coming from base.js:382 from a window.decodeURI. My experience is that Edge has slightly better debugging tools than Chrome so I've added a debug statement to the javascript code to see what string is causing the exception and hit reload. I got the following right before the exception:
 
a = www.euronics.hu/0%THM
 
That indeed is a malformed URI, the percentage sign should be urlencoded. Remember kids you should always check your input and do not let shitty URIs be entered into systems expecting well formed URIs. Obviously the only way that URL gets rendered in a youtube page is through an ad, so I think the reason this only happens when I'm logged in is because I when I log in I get targeted by this shitty misconfigured ad, and if I log out, I do not.
 
base.js actually tries to do something, because there is the following expression on the same line, that is run before the result is used as a parameter to call window.decodeURI:
 
a.replace(/%25/g,"%2525")
 
I don't really understand what use case this is trying to solve though - if the % sign is already urlencoded, then is it reencoded again? Instead of this replacement there should be a check to see whether a is a well formed URI and if not that should be handled in a more elegant manner.
 
Having written code that used to run in ad click redirectors in millions of browsers every day I've seen my share of misconfigured URLs and can understand the frustration writing such a mission critical piece of code can cause. I've reported the issue through youtube player's builtin in playback issue reporter UI which can be accessed  by right clicking on the video player - hope it reaches somebody who can go in and do something about it.