問題描述
我有一個網(wǎng)站突然開始崩潰 Internet Explorer.
I have a website that suddenly started to crash internet explorer.
網(wǎng)站加載并開始執(zhí)行 javascript,但其中某處機器爆炸了.我什至沒有收到腳本錯誤,它只是崩潰了.我嘗試使用內(nèi)置調(diào)試器手動單步執(zhí)行 js 的每一行,但當然不會出現(xiàn)問題.
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.
如果我選擇在應(yīng)用程序崩潰時對其進行調(diào)試,我會看到以下消息.
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.
調(diào)用堆棧中的前 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 時遇到了很多問題,必須按特定順序設(shè)置屬性,有時當您將元素附加到 dom 時您無法設(shè)置屬性,反之亦然(順便說一句,所有內(nèi)容均未記錄),但隨后出現(xiàn)了問題調(diào)試時通常可以重現(xiàn),但現(xiàn)在不行:(
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 :(
在無插件模式下也會出現(xiàn)此問題.
The problem also occurs in no plugin-mode.
有沒有比試錯法更好的方法來解決這個問題?
Is there a better approach than trial and error to solve this?
添加一個控制臺輸出對 DOM 的每個可疑修改,只會導致問題有時發(fā)生.(控制臺也在同一頁面上用 javascript 實現(xiàn),即使在崩潰后我也能看到輸出,因為窗口仍然可見)顯然它似乎是某種競爭條件.
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.
我設(shè)法進一步追蹤它,當您在剛添加對象后過快地從 DOM 中刪除對象時,似乎會發(fā)生這種情況.(很可能僅適用于具有某些特殊屬性的 vml 元素,沒有進一步嘗試)并且無法通過在 removeChild 前面添加死循環(huán)來修復它(無論如何都是非常糟糕的解決方案),頁面必須由瀏覽器在addChild 之后一次就可以調(diào)用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),而且看起來幾乎無法調(diào)試.
I had a very similar problem - including lots of complex VML (from Raphael), and it looked near-impossible to debug.
實際上,事實證明,最簡單的低技術(shù)方法是最好的.這是一種顯而易見的方法:我寫在這里是因為有時當面臨一個令人生畏的問題時,顯而易見、簡單的解決方案是人們最后想到的.
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.
所以,簡單的老式調(diào)試:在每個遠程要求或在我的代碼中進行復雜的調(diào)用,提供超級簡單的可靠斷點,不依賴任何本身可能崩潰的功能(例如開發(fā)人員工具).然后,只需查看在它崩潰之前您收到了哪個數(shù)字警報 - 問題必須出現(xiàn)在該警報和下一個警報之間.
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 無關(guān)——它是一個 for 循環(huán),出于某種原因,它只在 IE7 上無限地繼續(xù).
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.
這篇關(guān)于我的網(wǎng)站總是崩潰 IE,無法調(diào)試的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!