From eccb5e759074277bfa2670abafe5731f40bd38b5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:29:21 +0800 Subject: [PATCH 1/4] Don't make setImmediate a local variable It makes more troubles than benefits, and somehow it is slowing message loop down. --- atom/common/lib/init.coffee | 9 ++------- vendor/node | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 4bc3e36986c0..5db6b7dcbbe0 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -37,6 +37,8 @@ wrapWithActivateUvLoop = (func) -> process.activateUvLoop() func.apply this, arguments process.nextTick = wrapWithActivateUvLoop process.nextTick +global.setImmediate = wrapWithActivateUvLoop timers.setImmediate +global.clearImmediate = timers.clearImmediate if process.type is 'browser' # setTimeout needs to update the polling timeout of the event loop, when @@ -45,10 +47,3 @@ if process.type is 'browser' # recalculate the timeout in browser process. global.setTimeout = wrapWithActivateUvLoop timers.setTimeout global.setInterval = wrapWithActivateUvLoop timers.setInterval - global.setImmediate = wrapWithActivateUvLoop timers.setImmediate - global.clearImmediate = wrapWithActivateUvLoop timers.clearImmediate -else - # There are no setImmediate under renderer process by default, so we need to - # manually setup them here. - global.setImmediate = setImmediate - global.clearImmediate = clearImmediate diff --git a/vendor/node b/vendor/node index aa9c7a2316ba..fa54694af435 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit aa9c7a2316ba7762f1d04d091585695be3e6be22 +Subproject commit fa54694af4350bf1720ff47e97a07c7c09325ee2 From 42515c6f41f85c9580de981b96236bfee165d15f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:30:54 +0800 Subject: [PATCH 2/4] No more need of manually setting process as local variable --- atom/common/lib/init.coffee | 9 ++++----- atom/renderer/api/lib/remote.coffee | 1 - atom/renderer/lib/init.coffee | 9 ++++----- atom/renderer/lib/override.coffee | 1 - 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 5db6b7dcbbe0..acb635edeaa4 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -1,8 +1,7 @@ -process = global.process -fs = require 'fs' -path = require 'path' -timers = require 'timers' -Module = require 'module' +fs = require 'fs' +path = require 'path' +timers = require 'timers' +Module = require 'module' process.atomBinding = (name) -> try diff --git a/atom/renderer/api/lib/remote.coffee b/atom/renderer/api/lib/remote.coffee index abd86e7eee0c..00d22ab8cf6d 100644 --- a/atom/renderer/api/lib/remote.coffee +++ b/atom/renderer/api/lib/remote.coffee @@ -1,4 +1,3 @@ -process = global.process ipc = require 'ipc' v8Util = process.atomBinding 'v8_util' CallbacksRegistry = require 'callbacks-registry' diff --git a/atom/renderer/lib/init.coffee b/atom/renderer/lib/init.coffee index 9825f75be928..274c50ec5f39 100644 --- a/atom/renderer/lib/init.coffee +++ b/atom/renderer/lib/init.coffee @@ -1,8 +1,7 @@ -process = global.process -events = require 'events' -path = require 'path' -url = require 'url' -Module = require 'module' +events = require 'events' +path = require 'path' +url = require 'url' +Module = require 'module' # We modified the original process.argv to let node.js load the # atom-renderer.js, we need to restore it here. diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index b60374e04754..6e6164a8f264 100644 --- a/atom/renderer/lib/override.coffee +++ b/atom/renderer/lib/override.coffee @@ -1,4 +1,3 @@ -process = global.process ipc = require 'ipc' remote = require 'remote' From 4a9197203745e6462f8f01dc35690725842a01d4 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:40:48 +0800 Subject: [PATCH 3/4] spec: Revert back to original behavior of setImmediate --- spec/webview-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/webview-spec.coffee b/spec/webview-spec.coffee index b310b7b129f8..961da0b9f160 100644 --- a/spec/webview-spec.coffee +++ b/spec/webview-spec.coffee @@ -86,7 +86,7 @@ describe ' tag', -> it 'preload script can still use "process" in required modules when nodeintegration is off', (done) -> webview.addEventListener 'console-message', (e) -> - assert.equal e.message, 'object function object' + assert.equal e.message, 'object undefined object' done() webview.setAttribute 'preload', "#{fixtures}/module/preload-node-off.js" webview.src = "file://#{fixtures}/api/blank.html" From 4cccce6bfe9a18820dc2c18f1be6bfbcecf1da00 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 22 Sep 2015 14:55:35 +0800 Subject: [PATCH 4/4] spec: Suppress beginFrameSubscription for now Since the callback is called asynchronously there is no way to prevent the callback from being called twice. --- spec/api-browser-window-spec.coffee | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index b2bca533b467..de713a6545c6 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -304,10 +304,7 @@ describe 'browser-window module', -> done() w.loadUrl url - describe 'beginFrameSubscription method', -> - # It is not very reliable on Travis CI. - return if process.env.TRAVIS is 'true' - + xdescribe 'beginFrameSubscription method', -> it 'subscribes frame updates', (done) -> w.loadUrl "file://#{fixtures}/api/blank.html" w.webContents.beginFrameSubscription (data) ->