7

JavaScript 重度運算導致 IE 網頁重啟

 3 years ago
source link: https://blog.darkthread.net/blog/busy-js-crash-ie/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
JavaScript 重度運算導致 IE 網頁重啟-黑暗執行緒

最近用 IE 跑一段極耗資源的 JavaScript 程式(前陣子發現的 diff2html.js),當資料量大,JavaScript 函式在 Chrome 都要跑好幾分鐘,更不用說 IE 了。執行期間 CPU 單核滿載,此時 IE 陷入無回應狀態:

如果只是這樣倒也無所謂,IE 嘛,需要付付出更多的愛與耐心,我等!

BUT,在無回應一陣子後,IE 程序常會崩潰,冒出「這個網頁的問題已導致 Internet Explorer 關閉並重新開啟索引標籤。」錯誤,網頁重新載入:

多試幾次,有時還會被導到以下畫面:

試個十次有一兩次會成功,由此可確定 IE 有辦法跑完,但就是無法可靠算出結果,讓人很困擾。

爬文找到一些關於" is not responding due to a long-running script." 錯誤的建議,包含停用 JavaScript 偵錯(如下圖)、關閉防毒軟體等,但在我的案例無效:

後來我發現一招 Workaround - 執行前按 F12 開啟開發者工具,我猜在這種模式下 IE 會停用監看重啟機制或取消 Timeout 設定 (像是 ASP.NET web.config compliation 設 debug="true" executionTimeout 變無限長一樣道理),等上三五分鐘網頁也不會被重啟:

不想為了 IE 調程式,就靠這招再撐十年吧!

  • Posted in
  • IE
and has 1 comment

Comments

Post a comment

Comment
Name Captcha 99 - 26 =

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK