我的网站总是崩溃 IE,无法调试
我有一个网站突然开始崩溃 Internet Explorer.
I have a website that suddenly started to crash internet explorer.
网站加载并开始执行 javascript,但其中某处机器爆炸了.我什至没有收到脚本错误,它只是崩溃了.我尝试使用内置调试器手动单步执行 js 的每一行,但当然不会出现问题.
The website loads and starts executing javascript but somewhere in there the machinery explodes. I don't even get a script error, it just crashes. I've tried to manually step through every single line of js with the built in debugger but then of course the problem doesn't occur.
如果我选择在应用程序崩溃时对其进行调试,我会看到以下消息.
If i choose to debug the application when it crashes i see the following message.
iexplore.exe 中 0x6c5dedf5 处未处理的异常:0xC0000005:访问冲突读取位置 0x00000090.
Unhandled exception at 0x6c5dedf5 in iexplore.exe: 0xC0000005: Access violation reading location 0x00000090.
调用堆栈中的前 5 项如下所示
The top 5 items in the call stack looks like this
VGX.dll!6c5dedf5()
[以下帧可能不正确和/或丢失,没有为 VGX.dll 加载符号]
VGX.dll!6c594d70()
VGX.dll!6c594f63()
VGX.dll!6c595350()
VGX.dll!6c58f5e3()
mshtml.dll!6f88dd17()
VGX.dll!6c5dedf5()
[Frames below may be incorrect and/or missing, no symbols loaded for VGX.dll]
VGX.dll!6c594d70()
VGX.dll!6c594f63()
VGX.dll!6c595350()
VGX.dll!6c58f5e3()
mshtml.dll!6f88dd17()
VGX.dll 似乎是 vml 渲染器的一部分,而我实际上正在使用 VML.我并不感到惊讶,因为我在使用 vml 时遇到了很多问题,必须按特定顺序设置属性,有时当您将元素附加到 dom 时您无法设置属性,反之亦然(顺便说一句,所有内容均未记录),但随后出现了问题调试时通常可以重现,但现在不行:(
VGX.dll seems to be part of the vml renderer and i am in fact using VML. I'm not suprised because i've had so many problems with vml, attributes has to be set in specific order, sometimes you cant set attributes when you have elements attached to the dom or vice versa (everything undocumented btw) but then the problems can usually be reproduced when debugging but not now :(
在无插件模式下也会出现此问题.
The problem also occurs in no plugin-mode.
有没有比试错法更好的方法来解决这个问题?
Is there a better approach than trial and error to solve this?
添加一个控制台输出对 DOM 的每个可疑修改,只会导致问题有时发生.(控制台也在同一页面上用 javascript 实现,即使在崩溃后我也能看到输出,因为窗口仍然可见)显然它似乎是某种竞争条件.
Adding a console outputting every suspect modification to the DOM made the problem only occur sometimes. (the console is also implemented in javascript on the same page, i'm able to see the output even after a crash as the window is still visible) Apparently it seems to be some kind of race condition.
我设法进一步追踪它,当您在刚添加对象后过快地从 DOM 中删除对象时,似乎会发生这种情况.(很可能仅适用于具有某些特殊属性的 vml 元素,没有进一步尝试)并且无法通过在 removeChild 前面添加死循环来修复它(无论如何都是非常糟糕的解决方案),页面必须由浏览器在addChild 之后一次就可以调用removeChild.叹息
I managed to track it down even further, and it seems to occur when you remove an object from the DOM too quickly after it's just been added. (most likely only for vml-elements with some special attribute, didn't try further) And it can't be fixed by adding a dead loop in front of removeChild(pretty bad solution anyway), the page has to be rendered by the browser once after the addChild before you can call removeChild. sigh
推荐答案
(老问题但很重要)
我遇到了一个非常相似的问题 - 包括许多复杂的 VML(来自 Raphael),而且看起来几乎无法调试.
I had a very similar problem - including lots of complex VML (from Raphael), and it looked near-impossible to debug.
实际上,事实证明,最简单的低技术方法是最好的.这是一种显而易见的方法:我写在这里是因为有时当面临一个令人生畏的问题时,显而易见、简单的解决方案是人们最后想到的.
Actually, it turned out the simplest low-tech approach was the best. It's an obvious approach: I'm writing here because sometimes when faced with an intimidating problem the obvious, simple solutions are the last a person thinks of.
所以,简单的老式调试:在每个远程要求或在我的代码中进行复杂的调用,提供超级简单的可靠断点,不依赖任何本身可能崩溃的功能(例如开发人员工具).然后,只需查看在它崩溃之前您收到了哪个数字警报 - 问题必须出现在该警报和下一个警报之间.
So, simple old-school debugging: Lots of alert("1");
, alert("2");
etc before and after every remotely demanding or complex call in my code, giving super-simple reliable breakpoints that don't rely on any features (e.g. developer tools) that might themselves crash out. Then, just see which number alert you get to before it crashes - the problem must arise between that alert and the next one.
添加更多警报,直到您将其缩小到确切的行.在我的例子中,它实际上与复杂的 VML 无关——它是一个 for 循环,出于某种原因,它只在 IE7 上无限地继续.
Add more alerts until you narrow it down to the exact line. In my case, it was actually nothing to do with the complex VML - it was a for loop that, for some reason was continuing infinitely only on IE7.
相关文章