From 5a0f651b28274336af2dec452748b0d2dd77e3e4 Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 25 Aug 2016 15:47:18 -0400 Subject: [PATCH] possibly work around #1713 -- until real underlying cause is identified --- src/js/tab.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/js/tab.js b/src/js/tab.js index 4843f3c21..597896e45 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -200,6 +200,7 @@ housekeep itself. this.rootDomain = ''; this.commitTimer = null; this.gcTimer = null; + this.onGCBarrier = false; this.netFiltering = true; this.netFilteringReadTime = 0; @@ -226,11 +227,21 @@ housekeep itself. }; TabContext.prototype.onGC = function() { - this.gcTimer = null; if ( vAPI.isBehindTheSceneTabId(this.tabId) ) { return; } + // https://github.com/gorhill/uBlock/issues/1713 + // For unknown reasons, Firefox's setTimeout() will sometimes + // causes the callback function to be called immediately, bypassing + // the main event loop. For now this should prevent uBO from crashing + // as a result of the bad setTimeout() behavior. + if ( this.onGCBarrier ) { + return; + } + this.onGCBarrier = true; + this.gcTimer = null; vAPI.tabs.get(this.tabId, this.onTab.bind(this)); + this.onGCBarrier = false; }; // https://github.com/gorhill/uBlock/issues/248