Skip to content
This repository has been archived by the owner on Feb 16, 2021. It is now read-only.

ZeroClipboard intermittently fails in Firefox showing deactivated=true in state dump #661

Open
kevgrig opened this issue Aug 2, 2016 · 4 comments

Comments

@kevgrig
Copy link

kevgrig commented Aug 2, 2016

I have a single page application with a constantly changing DOM and sometimes, ZC fails to work. Running console.log( JSON.stringify( ZeroClipboard.state(), null, 2 ) ); in the failing case shows deactivated=true:

{
  "browser": {
    "userAgent": "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0",
    "platform": "Linux x86_64",
    "appName": "Netscape"
  },
  "flash": {
    "version": "11.2.202",
    "pluginType": "netscape",
    "disabled": false,
    "outdated": false,
    "sandboxed": false,
    "unavailable": false,
    "degraded": false,
    "deactivated": true,
    "overdue": false,
    "ready": false
  },
  "zeroclipboard": {
    "version": "2.2.0",
    "config": {
      "swfPath": "/assets/ZeroClipboard-4e34ce62512bcf38aecb53e4aaafa931.swf",
      "trustedDomains": [
        "myplaceonline.com"
      ],
      "cacheBust": false,
      "forceEnhancedClipboard": false,
      "flashLoadTimeout": 30000,
      "autoActivate": true,
      "bubbleEvents": true,
      "containerId": "global-zeroclipboard-html-bridge",
      "containerClass": "global-zeroclipboard-container",
      "swfObjectId": "global-zeroclipboard-flash-bridge",
      "hoverClass": "zeroclipboard-is-hover",
      "activeClass": "zeroclipboard-is-active",
      "forceHandCursor": false,
      "title": null,
      "zIndex": 999999999
    }
  }
}

If I do a full refresh on the same exact page, it works fine and a diff with the state dump shows that the only changes are that deactivated=false (and ready=true).

How do I debug this further? What causes Flash to be deactivated?

@JamesMGreene
Copy link
Member

JamesMGreene commented Oct 27, 2016

That is very strange.

From docs/api/ZeroClipboard.md#errorname--flash-deactivated:

error[name = "flash-deactivated"]

This type of error event fires when the browser's installation of Flash Player is either too old
for the browser [but not too old for ZeroClipboard] or if Flash objects are configured as
click-to-play and the user does not authorize it within _globalConfig.flashLoadTimeout
milliseconds or does not authorize it at all.

This event may also be fired in some browsers if the ZeroClipboard SWF object cannot be loaded at all. See error\[name = "swf-not-found"\] for more information.

ZeroClipboard.on("error", function(e) {
/*
  e = {
    type: "error",
    name: "flash-deactivated",
    messsage: "Flash is too outdated for your browser and/or is configured as click-to-activate. This may also mean that the ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity. May also be attempting to run Flash in a sandboxed iframe, which is impossible.",
    target: null,
    relatedTarget: null,
    currentTarget: flashSwfObjectRef,
    timeStamp: Date.now(),
    minimumVersion: "11.0.0",
    version: "11.2.202"
  };
*/
});

@kevgrig
Copy link
Author

kevgrig commented Dec 29, 2016

I'm waiting to reproduce this. I've added the following code to my site:

ZeroClipboard.on("error", function(e) {
  console.log("ZeroClipboard error: " + e);
  console.log(new Error().stack);
  console.dir(e);
});

@kevgrig
Copy link
Author

kevgrig commented Jan 7, 2017

This problem was reproduced on a Windows machine with the following console.dir of the error object:

{
  type: "error",
  name: "flash-deactivated",
  target: null,
  relatedTarget: null,
  currentTarget: <object#global-zeroclipboard-flash-bridge>,
  timeStamp: 1483765793740,
  message: "Flash is too outdated for your browser and/or is configured as click-to-activate. This may also mean that the ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity. May also be attempting to run Flash in a sandboxed iframe, which is impossible.",
  minimumVersion: "11.0.0",
  version: "24.0.0"
}

Refreshing the page made it work again.

This is part of a web application called myplaceonline.com which uses a Single Page Application model using JQueryMobile so that all page navigations are intercepted, executed as AJAX, and then the contents of the DOM are replaced. These DOM replacements may include ZeroClipboard objects and scripts, so I suspect that under some conditions, Flash gets confused. One Adobe engineer agrees that this is likely the driver of a bug in Flash that's causing a crash on my Linux machine. In this case, I was watching the user do this and I didn't see any evidence that Flash crashed. So I guess the question is: how can we diagnose whether this is an issue in ZeroClipboard or in Flash? Is there a debug version of the SWF that prints some sort of debug log?

@kevgrig
Copy link
Author

kevgrig commented Jan 7, 2017

As a follow-up to my last comment, I realized the Adobe engineer's comment wasn't in that forum thread, so here it is from a private message:

Yeah, this is a good recipe for creating a scenario where we're accessing a pointer into a SWF that the browser has already unloaded. My guess is that the SWF is unloaded and JavaScript attempts to invoke a function. The DOM has unloaded that SWF, but Flash is still running, so we dereference the pointer to the SWF we had when we instantiated ExternalInterface, and we blow up. If the page refreshed, this would never come up. We'll know more once someone debugs it, but I'm not surprised by what you're saying. If the page was refreshing, the Flash process would restart and we wouldn't have any stale pointers. It sounds like this is something we probably do correctly already on Mac and Windows, so hopefully it's a straightforward fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants