문제

The web worker just stops, no errors or anything. The code is entirely deterministic, but it will die at different points in the code.

Edit: The problem was that I was not maintaining a reference to my workers, and so they seemed to die randomly when they were garbage collected.

도움이 되었습니까?

해결책

The problem was that I was not maintaining a reference to my workers, and so they seemed to die randomly when they were garbage collected.

다른 팁

I found a similar situation in Firefox where my worker seemed to be silently failing after a random number of calls to postMessage. After more digging, I found the real problem. Apparently invocations of the worker in Firebug was the issue. Firebug was touching a service in Firefox's chrome JS (privileged code space) that was causing the worker to fail intermittently, you can see the patch for it here: https://bugzilla.mozilla.org/show_bug.cgi?id=651980

As long as you do everything in accordance with the worker spec you shouldn't see this problem. As for the fix to Firebug/Fx, it should arrive in Firefox 5 in late June. Hope this helps you!

Same here with a web worker silently failing in firefox but not in chrome. Was using arborjs.org Called like this:

buildVisualization = function() {
  var sys = arbor.ParticleSystem(200, 200, 0.9); // create the system with sensible repulsion/stiffness/friction 
  sys.parameters({gravity:true}); // use center-gravity to make the graph settle nicely (ymmv) 
  sys.renderer = Renderer("#viewport"); // our newly created renderer will have its .init() method called shortly by sys... 
}

Where arbor is the object using a webworker.

I added the window.sys = sys; line and it now works like a charm both in firefox and chrome.

buildVisualization = function() {
  var sys = arbor.ParticleSystem(200, 200, 0.9); // create the system with sensible repulsion/stiffness/friction
  window.sys = sys;
  sys.parameters({gravity:true}); // use center-gravity to make the graph settle nicely (ymmv)
  sys.renderer = Renderer("#viewport"); // our newly created renderer will have its .init() method called shortly by sys...
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top