views:

953

answers:

3

Here's the Question: What is the best way to make sure that your requirement for Flash Version "x" on a site will properly detect presence of later-version Adobe Flash Player Version "10" (or "1y" for that matter)?

Now here's the mystery: Why are so many sites that require Flash Player versions 8 and 9 or better failing to detect Flash Player version 10?

And here's the juicy background, in technicolor screen captures in my post, "WTF: The Adobe Flash Version 1x Crisis."

UPDATE 2: I have since confirmed that the problem I am seeing is not about improper comparison for the same-or-more-recent version. It appears that some client-side detection is unable to determine whether there is any Flash Player installed at all, much less what version it is. I have also discovered that if I am running as admin I don't have the problem: detection of Flash 10 works just fine. That makes this a bigger can of snakes than I first thought. I'm not ready to change this question's title just yet, and I am continuing to dissect client-side code to see what wondrous logic unfolds. Details on these latest revelations are on my blog.

UPDATE: Although I did a search, I missed the related question "Why don't flash videos play after upgrading to Flash 10?" The speculations there are interesting but they don't get to the bottom of it. Also, it's not clear how Levi's problem was resolved. Interesting ... Maybe we can get to the bottom of things here.


Some Background

I managed to install the new Adobe Flash Player version 10.0.12.36 as a clean install (with previous versions removed using the Adobe-provided uninstaller).

The first disappointment was noticed when I couldn't play the latest NCIS program from the CBS Television site, not in HD, not in plain-old standard. But I could play videos of my favorite programs on Hulu. The more I nosed around, the more times I found those obnoxious you-don't-have-Flash, you-need-a-later-version-of-Flash, your-version-of-Flash-old messages that offered a button for downloading.

Every time I clicked the download/update button, and told the Adobe site to do the install (which should fail if attempted, because I am not running as admin), my already having version 10.0.12.36 was confirmed instantly and no update was attempted.

Curious, huh?


The Challenge

I think I know exactly what the most-likely bug is in the Flash-detection script that people are using. It is just too juicy to not be the bug.

Now, that does not mean all sites that fail to detect version 10 suffer from the same bug. I just think the one I have in mind is really likely. I should probably seal my theory in an envelope somewhere. Meanwhile, let's see what the StackOverflow community has to offer and what we conclude the lesson is.

I say the bug is really simple and very funny. What do you say?

+1  A: 

My guess would be detection from string which is something like "Flash Player version X.Y" by doing something like "get the character before '.' and convert it to number." I've done this a few times myself, it's just stupid.

P Arrayah
Great! I would have never thought of that. It would certainly account for some of the messages I get that say I am running version "0" or my version is older than the version (8 or 9) they want. You may be onto something. Let's see what others have to say.
orcmid
The sample code I've encountered uses split to break up the version string into an array of strings, so that mistake won't happen. It does matter how the parts are compared after that, though. There appear to be an excessive number of ways to get this wrong. I wonder what the winner will be.
orcmid
+1  A: 

Unfortunately the problem is caused because the poor version detection shipped with flash. That's right, the shoddy code it actually created by Adobe Flash (not sure which versions), which is the reason it's so widespread.

Personally I use swfObject to embed flash.

Greg
I was hoping it was not their doing. Can you provide links to where Adobe ships detection code. I don't quite follow what the path is to its use on a site that serves up the video stream and selects the Flash Player.
orcmid
The swfObject site is very handy. I found the Adobe Flash Player Detection Kit 1.5 at http://www.adobe.com/products/flashplayer/download/detection_kit/I'll be interested in seeing if they blew it.
orcmid
I'm now working my way through the Client-Side detection sample of the Adobe Flash Player Detection Kit 1.5. So far, the problem is not with comparisons but with finding a Flash Player at all. I now have to dig into the GetSwfVer to see why it is finding no Flash Player.
orcmid
Ah, I also just determined by near accident that Flash Player detection works when I run from an administrator account, but not from a Limited User Account. I've been seeing this kind of thing under other conditions. Maybe I can pinpoint it as I continue my anatomy of the Client-side example.
orcmid
+2  A: 

My guess is the javascript is doing string comparison, and in string land, "10" < "9".

Also, Flash10 changed their security model somewhat (breaking a tool I use called SWFUpload) so it may be related to that (see: http://benr75.com/articles/2008/11/25/swfupload-with-flash-10-fix )

Matt Rogish
I suspected this too. After nosing around I discovered that JavaScript doesn't fail the way strcmp does in C. x < y in JavaScript is always a numeric compare, and it converts any strings there into numbers before comparing. So in the JavaScript detection code I'm inspecting, that's not it.
orcmid
alert("In string land, \"10\" is " + ( "10" < "9" ? "less" : "more") + " than \"9\".")
some
if ("10" < "9") { alert("10 is less than 9 in string land")}
some
var high="10", low="9";if (high < low) { alert (high + " is less than " + low)}
some
@orcmid: Try the 3 javascript examples above. All of them will give you the result that 10 is less than 9 since they do a string compare (tested in Firefox, IE, Opera and Crome)
some
When both parameters are strings they will be compared as strings. But if one of them is numeric, the string will be converted, so alert("10" < 9) returns false.
some
My Pure JavaScript book says "<" is always a numeric compare, so the bug will happen if someone believes that. Fortunately, the sample Client-Side code and .js file for the Adobe Flash Player Detection Kit 1.5 uses splits to parse version strings and makes the "<" be numeric via parseFloat.
orcmid
So now I know why parseFloat is used there. The problem I'm having may be a complete failure to detect an installed Flash Player, not even getting to the version check.
orcmid