zackexplosion / swfobject

Automatically exported from code.google.com/p/swfobject
1 stars 0 forks source link

swfobject 2.2 inclusion throws JS error #332

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Just including swfobject 2.2 (page head section) with a certain config (see
below).

What is the expected output? What do you see instead?

Firebug reports a JavaScript error like:
   "Error calling method on NPObject!"
Stack trace goes to this line:
   var d = t.GetVariable("$version");

What version of the product are you using? On what operating system?
swfobject v2.2, Windows (Server 2003), FireFox 3.0.11, downgrade to Flash
8.0.22

Please provide any additional information below.

I was able to fix locally by simply surrounding the one line with a
try/catch. All other functionality seems to be fine.

Original issue reported on code.google.com by MartijnS...@gmail.com on 29 Jun 2009 at 8:47

GoogleCodeExporter commented 9 years ago
With this config, if you browse to our test suite you see the same error?
- http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test.html
- http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test_dynamic.html

If you open the Tools > Error console, do you see the same error displayed here?

And it only happens when you downgrade to Flash 8, not in later versions?

Original comment by bobbyvandersluis on 30 Jun 2009 at 6:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
For SWFObject it doesn't matter which version you target. Do you test locally? 
If so,
what if you put your files on a Web server?

Original comment by bobbyvandersluis on 30 Jun 2009 at 1:06

GoogleCodeExporter commented 9 years ago
I tried both your test suite, and the test suite included with swfobject 2.2
(ostensibly the same code?). I do not get the error using either. However, the 
test
suite targets Flash 9 and I do not see the alternative content.

When I target my local swfobject 2.2 test suite to Flash 8 (my installed 
version), I
do see the error on both pages (static and dynamic) and I see no movie.

When I apply my fix (try/catch) to my local swfobject 2.2 test suite, targeted 
to
Flash 9, the alternative content does appear and there is no error.

When I apply my fix (try/catch) to my local swfobject 2.2 test suite, targeted 
to
Flash 8, the test movie does appear and there is no error.

Problem appears in:
* Flash Player 8.0.22 (first v8 player)
* Flash Player 8.0.42 (last v8 player)

Problem does not appear in:
* Flash Player 9.0.15 (first v9 player)
* Internet Explorer (7)
* Chrome (2)
* Safari (3)

Original comment by MartijnS...@gmail.com on 30 Jun 2009 at 1:16

GoogleCodeExporter commented 9 years ago
I tested across machines (with the host running a web server).

I believe you that the target version does not affect the movie rendering, but 
I bet
it affects the code path taken in the swfobject library (rendering the movie 
vs. the
alternative content).

Original comment by MartijnS...@gmail.com on 30 Jun 2009 at 1:17

GoogleCodeExporter commented 9 years ago
I want to clarify my original bug report. I said the steps to reproduce were:
"Just including swfobject 2.2 (page head section) with a certain config (see
below)."

I am not sure that was accurate. I never tested just including the swfobject 
library.
I was always loading at least one movie as well.

Original comment by MartijnS...@gmail.com on 30 Jun 2009 at 1:22

GoogleCodeExporter commented 9 years ago
"Error calling method on NPObject!" on Firefox is usually caused by a security 
issue,
so I think something might be wrong with running things on a local server. I 
mean,
the code executes fine, GetVariable functionality is accessible, however the 
object
can not be accessed due to browser security constraints. That would also 
explain why
the files from the test suite are working correctly.

I see no cause for a SWFObject bug, if you would like to discuss/examine it 
further,
please repost the issue in the discussion group: 
http://groups.google.com/group/swfobject

Original comment by bobbyvandersluis on 1 Jul 2009 at 7:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm not running this on a local server. I'm running this from one machine to an 
IIS
server on another machine... Have you tried to reproduce this yourself and been
unsuccessful?

Original comment by MartijnS...@gmail.com on 1 Jul 2009 at 10:40

GoogleCodeExporter commented 9 years ago
Also, the files from the test suite are *not* working correctly. No alternative
content is displayed, and when you decrease the required Flash version to 8, 
you do
see the error.

Original comment by MartijnS...@gmail.com on 1 Jul 2009 at 11:25

GoogleCodeExporter commented 9 years ago
As I have said before, if I look at the error description I'm not convinced 
that this
issue is caused by SWFObject. It could be a security issue that has something 
to do
with your implementation or it could have something to do with the archived FP8
versions. 

Due to time constraints we only investigate issues of which we think they could 
be
caused by SWFObject, it's not up to us to prove you wrong. So for now your 
issue is
logged, if you'd like to discuss it further, please use the discussion group.

Original comment by bobbyvandersluis on 1 Jul 2009 at 12:10

GoogleCodeExporter commented 9 years ago
Fair enough. I've patched my local version, but I want to add some more 
information
to the record:

Normally these errors are security issues, as you mentioned. It's usually people
doing cross-domain flash calls without the correct domain permissions. In that 
case,
the fix would be to pass the proper access level in the allowscriptaccess param.

In this case the problem is reproducible by calling
swfobject.getFlashPlayerVersion(), without loading *any* of my own Flash 
content.

Original comment by MartijnS...@gmail.com on 1 Jul 2009 at 12:46

GoogleCodeExporter commented 9 years ago
I just confirmed/reproduced this error with FF3.0.11 on WinXP SP3, with FP 
8.0.22 
installed. I simply went to the first dynamic embed test suite page:

http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test_dynamic.html

And the error was reported. The error also occurred with FP 8.0.42 installed. 
But 
did *not* occur with FP 9.0.16 installed.

I also tried the above tests with the 2.1 test suite, and no errors occurred. 
So 
this is definitely a regression. Not sure why though. But we should look into 
it.

Original comment by get...@gmail.com on 6 Jul 2009 at 1:43

GoogleCodeExporter commented 9 years ago
Error reproduced on:
--------------------
* Firefox 3.0.11
* Windows XP SP3
* Flash Player 8.0 r22 (Debug version)

Additional information:
--------------------
In my code, I am requesting minimum SWF version = 8, which is same version as 
the one
installed in browser, but I am receiving the "Error calling method on 
NPObject!".

The code can be viewed at:
--------------------------
http://911-need-code-help.blogspot.com/2009/05/embed-youtube-videos-in-your-web.
html

The code snippet:
-----------------
  <script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js"></script>

  <a name="ytplayer1"></a>
  <div id="ytplayer1_div">You need Flash player 8+ and JavaScript enabled to view
this video.</div>
  <script type="text/javascript">
    swfobject.embedSWF(
      'http://www.youtube.com/v/21OH0wlkfbc&enablejsapi=1&rel=0&fs=1',
      'ytplayer1_div',
      '425',
      '344',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'ytplayer1_object'
      }
    );
  </script>

Output:
-------
* A div containing the message:

You need Flash player 8+ and JavaScript enabled to view this video.

* The error "Error calling method on NPObject!"

Original comment by schwarze...@hotmail.com on 13 Jul 2009 at 4:40

GoogleCodeExporter commented 9 years ago
Experiencing same problems here too - no error occurs with swfobject 1.1!

Original comment by martin.h...@hobnox.com on 14 Sep 2009 at 9:42

GoogleCodeExporter commented 9 years ago
Issue 389 has been merged into this issue.

Original comment by aran.rhee@gmail.com on 13 Oct 2009 at 4:52

GoogleCodeExporter commented 9 years ago
I can confirm this. Our content requires FP9, swfobject 2.2 fails to fall back 
when 
FP8 is installed and dynamic publishing method is used.

Original comment by brains.for.rent@gmail.com on 19 Oct 2009 at 5:49

GoogleCodeExporter commented 9 years ago
Follow-up for comment #17. Here's some minimal code for reproduction:

1) Install any Flash Player 8 (I used 8.0r24) in Firefox (I used 3.5.3).

2) Maka a simple test page with swfobject 2.2 but no embedded swf:

  <html>
    <head>
      <script src="swfobject22.js" type="text/javascript"></script>
    </head>
    <body>
      <script type="text/javascript">
        if(swfobject.hasFlashPlayerVersion("9.0.0"))
          alert("FP 9 or newer")
        else 
          alert("FP 8 or older");
      </script>
  </body>
</html>

this displays the alert but also causes a JS error: "Error calling method on 
NPObject!" in swfobject22.js line 4. It proves the problem is in swfobject and 
not 
in loaded content.

3. Create another test page:

  <html>
    <head>
      <script src="swfobject22.js" type="text/javascript"></script>
    </head>
    <body>
      <div id="mydiv">This page needs Flash Player 9+</div>
      <script type="text/javascript">
        swfobject.embedSWF("needf9.swf", "mydiv", "500", "400", "9.0.0");        
      </script>
    </body>
  </html>

This CLEARS the content of the div and THEN produces the JS error, leaving the 
div 
empty.

Original comment by brains.for.rent@gmail.com on 19 Oct 2009 at 6:52

GoogleCodeExporter commented 9 years ago
I can confirm having the same issue:

<script type="text/javascript">

            var fv = swfobject.getFlashPlayerVersion();

            alert(fv.major);
            var flashvars = {};
            var params = {};
            params.bgcolor = "#000000";
            params.allowfullscreen = "true";
            var attributes = {};
            attributes.id = "mainMovie";
            swfobject.embedSWF("main.swf?v=0.8.4", "nonFlashContent", "100%", "100%", "9",
"flash/expressInstall.swf", flashvars, params, attributes);
        </script>

The alert displays version 8, after you click ok on the alertbox the error is 
displayed.

Original comment by Nia...@gmail.com on 19 Oct 2009 at 8:42

GoogleCodeExporter commented 9 years ago
I had the exact same issue and using:

try
{
     var d = t.GetVariable("$version");
} catch(err) {
     //Handle errors here
}

instead of just:

var d = t.GetVariable("$version");

Worked great!

I'm a newbie on code.google.com, but why does the correction hasn't been made 
yet? It
just works!

Original comment by mocod...@gmail.com on 4 Nov 2009 at 12:10

GoogleCodeExporter commented 9 years ago
Same problem here with flash 8 and below. 

The fix http://code.google.com/p/swfobject/issues/detail?id=332#c20 by mocodere 
does
work for me, just try it! Thanks mocodere. There are over a dozen people having 
this
problem. How many must report till theres a official fix?

Original comment by felix.na...@gmail.com on 17 Dec 2009 at 1:20

GoogleCodeExporter commented 9 years ago
I have the same problem... and still no offical fix? I want to include 
swfobject from
googleapis, so i cant use the fix from mocodere.

Original comment by marcus.r...@gmail.com on 11 Feb 2010 at 10:08

GoogleCodeExporter commented 9 years ago
This bug with Flash version 8 is a fairly common problem. Any plan to have it 
fixed?

Original comment by brian.ka...@gmail.com on 11 May 2010 at 9:06

GoogleCodeExporter commented 9 years ago
script type="text/javascript">startIeFix();</script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0"
  id="name" width="468" height="60">
  <param name="movie" value="http://www.yourdomain.com/flashfile.swf">
  <param name="quality" value="high">
  <param name="wmode" value="transparent">
  <embed name="name" src="http://www.yourdomain.com/flashfile.swf"
  quality="high" wmode="transparent" width="468" height="60"
  type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?
P1_Prod_Version=ShockwaveFlash">
  </embed>
</object>
<script type="text/javascript">endIeFix();</script> 

Original comment by sonu12...@gmail.com on 17 May 2010 at 2:02

GoogleCodeExporter commented 9 years ago
We are facing the same issue at our Labs as well.

FusionCharts.js is throwing an error in Firefox 3.0.19.

The error is traced to the in Flash Player Detection code.

function testPlayerVersion()

var d = t.GetVariable("$version");

Original comment by shamasis...@gtempaccount.com on 4 Sep 2010 at 8:23

GoogleCodeExporter commented 9 years ago
FWIW: Adobe's Flash Detection Kit uses a try...catch around the call to 
.GetVariable('$version').

Original comment by anthon.p...@gmail.com on 6 Sep 2010 at 7:09

GoogleCodeExporter commented 9 years ago
I am having the same problem also, using Flash player 8.0.24. The try catch 
worked a treat. Thanks

Original comment by pthrobin...@gmail.com on 7 Sep 2010 at 9:10

GoogleCodeExporter commented 9 years ago
No new versions, no bug fixes. Obviously, swfobject is not being developed 
anymore.

Original comment by razetdi...@gmail.com on 7 Sep 2010 at 9:20

GoogleCodeExporter commented 9 years ago
SWFObject development has definitely slowed as the JavaScript community has 
focused a lot more lately on different technologies than Flash. But it has not 
been abandoned. For awhile, we've been discussing several bug fixes that we 
plan to roll into a 2.3 release at some point, but we've been unable to nail 
down exactly when that will occur or the priority of such an effort.

With respect to this particular bug, we've studied/polled and found that 
there's a very small percentage of the overall web community that still has 
exactly Flash 8 installed (<1%), and so it's a pretty small footprint of an 
impact this bug actually has out in the real world.

The problem with the try/catch is that in the case of an error that try/catch 
basically catches and ignores, the version detection actually is being 
completely ignored. This may "work" for your test cases, but I'd hazard a guess 
that most people don't just want no version detection at all. So it's not a 
feasible solution for us.

Original comment by get...@gmail.com on 7 Sep 2010 at 12:34

GoogleCodeExporter commented 9 years ago
Failing gracefully is much better that throwing a JS error though. As long as 
your saying we need to extend the solution to actually get some sort of version 
in the failed state, I agree. Otherwise, they're already not getting any 
version detection so the try catch is definitely not worse.

I ran across this bug because I was trying to test the expressInstall 
functionality which is a lot less useful if version detection doesn't work for 
Flash 8.

Original comment by neclim...@gmail.com on 7 Sep 2010 at 5:35

GoogleCodeExporter commented 9 years ago
Diziler http://www.turkdizi.tv/ http://www.turkdizi.tv/kolej-gunlugu/ 
http://www.turkdizi.tv/duz-adam/ http://www.turkdizi.tv/yeniden-basla/ 
http://www.turkdizi.tv/karakol/ http://www.turkdizi.tv/basrolde-ask/

Original comment by xdag...@gmail.com on 21 Apr 2011 at 11:04

GoogleCodeExporter commented 9 years ago
As Kyle said, a try/catch clause will cause version detection to fail, which 
will not help folks wanting to use ExpressInstall.

Unfortunately swf.GetVariable("$version") has a history of being unreliable:
http://lists.deconcept.com/pipermail/swfobject-deconcept.com/2006-May/000276.htm
l

We don't have many options to choose from. FP v8 suffers from this (at least in 
Firefox) while newer versions do not. Considering FP8's current market 
saturation, I'm wondering if we're best off leaving this as-is?

Original comment by platelu...@gmail.com on 21 May 2011 at 12:00

GoogleCodeExporter commented 9 years ago
I think we should drop support for detecting any specific versions from 8 and 
below... we should assume that any version string 8 or below is the same as 8, 
and try to detect, with a try/catch to prevent the error. If the error happens, 
we assume 8. If the error doesn't happen, but version looks less than 8, we 
still say it's 8.

Actually, we'd call it "8 and below" officially. I can't see any reason for 
sites to distinguish anymore between FP 6, FP7 and FP8... we should roll all of 
them up into "8 and below" and move on. And a year from now, we should roll it 
up to "9 and below", etc.

Original comment by get...@gmail.com on 21 May 2011 at 3:32

GoogleCodeExporter commented 9 years ago
Kyle: Agreed. At this point, I think it's a reasonable stance. Plus this only 
affects people using Flash Player 8 on Firefox, which is bound to be a very 
small group of people.

I've submitted a patch on GitHub:

t.GetVariable("$version") is known to fail in Flash Player 8 on Firefox; if 
this error is encountered, assume FP8 or lower (returns FP version 8.0.0). Time 
to upgrade your Flash Player.

Original comment by platelu...@gmail.com on 21 May 2011 at 4:02

GoogleCodeExporter commented 9 years ago
Issue 372 has been merged into this issue.

Original comment by platelu...@gmail.com on 21 May 2011 at 5:34

GoogleCodeExporter commented 9 years ago
Wait what? How is this "Fixed"? I'm still getting "Error calling method on 
NPObject!" while calling YOUTUBE api methods on Firefox 6 with flash player 
10.3. 

Chrome and ie don't experience any issues, but for example in firefox only, 
listening for onStateChange events fire FOUR times for each event (play, pause, 
etc). And when calling loadVideoById() i get the NPObject Error and the youtube 
player fails to load the new video.

Any new updates? Is this a firefox issue not playing well with how Youtube 
embeds itself (possibly Swfobject) or a dropped discussion on the Swfobject 
side?

Original comment by nicotroia@gmail.com on 8 Sep 2011 at 7:26

GoogleCodeExporter commented 9 years ago
nicotroia, are you using the version in github? It isn't an official release 
yet. 
https://github.com/pipwerks/swfobject/blob/master/swfobject/src/swfobject.js

Original comment by platelu...@gmail.com on 8 Sep 2011 at 9:03

GoogleCodeExporter commented 9 years ago
I am encountering the same problem as nicotroia on FF 7.0.1 Ubuntu 11.04. Using 
swfobject 2.2 (hosted on Google) and the sample at 
https://code.google.com/apis/ajax/playground/?exp=youtube#chromeless_player.

The weird thing is that the sample works well from the Google site, but when I 
copy it locally and access it via Apache 2 on localhost, the error above is 
thrown.

Any idea how to go about debugging this?

Original comment by karim.ra...@gmail.com on 27 Oct 2011 at 4:35

GoogleCodeExporter commented 9 years ago
@karim Thanks for the info. Please keep in mind SWFObject merely writes the 
<object> to the page, and does not provide event listeners. All event listeners 
are handled by Flash Player, the SWF itself, and/or the browser.

It looks to me like Firefox or the FF-compatible version of Flash Player has a 
bug.

Original comment by platelu...@gmail.com on 27 Oct 2011 at 6:59

GoogleCodeExporter commented 9 years ago
I'm seeing this error "Error calling method on NPObject" using Flash 11, on 
Chrome 15, on OSX 10.7, using the version 2.2 of SwfObject from 
code.google.com.  Therefore I think the problem is broader than Flash 8/FF.  
The error occurs when dynamically loading swfobject.js on the page, even before 
a SWF movie is loaded due to:
t.GetVariable("$version")

@platelu, your linked version on GitHub works fine for dynamic loading.  Thanks 
for pointing it out.  The page loads without error, the js injection works w/o 
error, and .swf files load and play correctly.

Original comment by JasonThr...@gmail.com on 2 Nov 2011 at 7:02

GoogleCodeExporter commented 9 years ago
For what it's worth, the github version did not resolve my problem. Also noting 
that the Dailymotion player, which uses a similar event listener mechanism, is 
still working correctly on the same configuration. So we might be talking (in 
my case at least) about a YouTube player problem.

Original comment by karim.ra...@gmail.com on 2 Nov 2011 at 3:59

GoogleCodeExporter commented 9 years ago
FYI the github.com/pipwerks updates have been merged into the official 
SWFObject master (2.3 beta):
https://github.com/swfobject/swfobject/blob/master/swfobject/src/swfobject.js

Original comment by platelu...@gmail.com on 2 Nov 2011 at 5:20

GoogleCodeExporter commented 9 years ago
I was also getting NPObject errors on my app that used JS to interact with an 
embedded YouTube player. Turns out disabling HTTPS Everywhere fixed it...

Original comment by lurayl on 5 Nov 2011 at 6:25

GoogleCodeExporter commented 9 years ago
@lurayl, thank you for the most excellent observation. Fixed it for me as well.

Original comment by karim.ra...@gmail.com on 5 Nov 2011 at 7:01