Google Chromecast Sender Error If Chromecast Extension Is Not Installed or Using Incognito

Google Chromecast sender error if Chromecast extension is not installed or using incognito

Update: After several attempts, it looks like this may have been fixed in latest Chrome builds (per Paul Irish's comment below). That would suggest we will see this fixed in stable Chrome June-July 2016. Let's see ...

This is a known bug with the official Chromecast JavaScript library. Instead of failing silently, it dumps these error messages in all non-Chrome browsers as well as Chrome browsers where the Chromecast extension isn't present.

The Chromecast team have indicated they won't fix this bug.

If you are a developer shipping with this library, you can't do anything about it according to Chromecast team. You can only inform users to ignore the errors. (I believe Chromecast team is not entirely correct as the library could, at the least, avoid requesting the extension scipt if the browser is not Chrome. And I suspect it could be possible to suppress the error even if it is Chrome, but haven't tried anything.)

If you are a user annoyed by these console messages, you can switch to Chrome if not using it already. Within Chrome, either:

  • Install the Chromecast extension from here.
  • Configure devtools to hide the error message (see David's answer below).

Update [Nov 13, 2014]: The problem has now been acknowledged by Google. A member of the Chromecast team seems to suggest the issue will be bypassed by a change the team is currently working on.

Update 2 [Feb 17, 2015]: The team claim there's nothing they can do to remove the error logs as it's a standard Chrome network error and they are still working on a long-term fix. Public comments on the bug tracker were closed with that update.

Update 3 [Dec 4, 2015]: This has finally been fixed! In the end, Chrome team simply added some code to block out this specific error. Hopefully some combination of devtools and extensions API will be improved in the future to make it possible to fix this kind of problem without patching the browser. Chrome Canary already has the patch, so it should roll out to all users around mid-January. Additionally, the team has confirmed the issue no longer affects other browsers as the SDK was updated to only activate if it's in Chrome.

Update 4 (April 30): Nope, not yet anyway. Thankfully Google's developer relations team are more aware than certain other stakeholders how badly this has affected developer experience. More whitelist updates have recently been made to clobber these log messages. Current status at top of the post.

How to detect if Google Cast extension is installed in Chrome?

The standard way (used by the library itself) of detecting whether the extension is installed is to try and load a web-accessible file from it.

This, however, leads to an unwanted effect of producing error messages in the console (which are "network" errors and not JS errors, and therefore cannot be hidden) when Cast is not installed.

Also, you should not do this probing yourself, specifically because you don't control Google Cast - and it's not guaranteed to be stable in how it operates internally. There is a library you're expected to use as a Sender, and you should rely on the library initialization callback for detecting Cast.

Trying to detect google chrome cast and stop it slowing things down

This lets the videos use embed if non chrome or if they are on chrome with cast extension enabled.

If they are on chrome without cast then it checks for flash and if they support flash then it uses v.

If they have chrome without ether cast or flash then (they will just get the chrome cast errors, it's their fault at that point!)

v is for the depreciated flash embed while embed is for the html5 (broken/wont fix) embed.

Could do with improvements maybe...

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js"></script>
<script type="text/javascript">
function proceed(how){
document.getElementById('vid').innerHTML='<iframe src="https://www.youtube.com/'+how+'/M_lHI1opADk"></iframe>';
console.log(ischrome,iscast);
}
var ytv=['embed','v','embed','v'];
var ischrome=0;
var iscast=true;//maybe
if(/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)){
ischrome=1;
setTimeout(function(){
try{new chrome.cast.SessionRequest('794B7BBF');}
catch(e){console.log(e);
iscast=false;}
finally{
(iscast==true)&&(ischrome=2);
if(ischrome==1){
function hasflash(){if(navigator.plugins){for(var i=0,l=navigator.plugins.length;i<l;i++){if((navigator.plugins[i].name+navigator.plugins[i].description).indexOf("Flash")!=-1){return true;}}}return false;}
if(hasflash()){ischrome=3;}
proceed(ytv[ischrome]);
}
else{
proceed(ytv[ischrome]);
}}},1000);}
else{proceed(ytv[ischrome]);}
</script>
</head>
<body>
<div id="vid"></div>
</body>
</html>

You can test this by installing the cast extension disabling/enabling and refreshing the page.



Related Topics



Leave a reply



Submit