我的 javascript web 工作人员在随机的地方默默地死去。我该如何调试这个?
网络工作者只是停止,没有错误或任何东西。代码是完全确定性的,但它会在代码的不同点处终止。
编辑:问题是我没有维护对我的工人的引用,因此他们在被垃圾收集时似乎随机死亡。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
问题是我没有维护对我的工人的引用,因此他们在被垃圾收集时似乎随机死亡。
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.
我在 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!
同样,网络工作者在 Firefox 中默默地失败,但在 Chrome 中却没有。使用 arborjs.org 调用如下:
其中 arbor 是使用 webworker 的对象。
我添加了
window.sys = sys;
行,现在它在 Firefox 和 Chrome 中都像魅力一样工作。Same here with a web worker silently failing in firefox but not in chrome. Was using arborjs.org Called like this:
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.