我的 javascript web 工作人员在随机的地方默默地死去。我该如何调试这个?

发布于 2024-10-13 02:57:57 字数 98 浏览 4 评论 0原文

网络工作者只是停止,没有错误或任何东西。代码是完全确定性的,但它会在代码的不同点处终止。

编辑:问题是我没有维护对我的工人的引用,因此他们在被垃圾收集时似乎随机死亡。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

み青杉依旧 2024-10-20 02:57:57

问题是我没有维护对我的工人的引用,因此他们在被垃圾收集时似乎随机死亡。

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.

独享拥抱 2024-10-20 02:57:57

我在 Firefox 中发现了类似的情况,我的工作人员在随机多次调用 postMessage 后似乎默默地失败了。经过更多挖掘,我发现了真正的问题。显然,Firebug 中的工作者调用是问题所在。 Firebug 正在接触 Firefox chrome JS(特权代码空间)中的一项服务,导致工作程序间歇性失败,您可以在此处查看其补丁:https://bugzilla.mozilla.org/show_bug.cgi?id=651980

只要您按照工作规范执行所有操作,您就不会看到此内容问题。至于 Firebug/Fx 的修复,应该会在 6 月底出现在 Firefox 5 中。希望这对您有帮助!

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!

天煞孤星 2024-10-20 02:57:57

同样,网络工作者在 Firefox 中默默地失败,但在 Chrome 中却没有。使用 arborjs.org 调用如下:

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... 
}

其中 arbor 是使用 webworker 的对象。

我添加了 window.sys = sys; 行,现在它在 Firefox 和 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...
}

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...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文