diff --git a/atom/app/node_main.cc b/atom/app/node_main.cc index cc8df0e0c8fd..94a727f5aa90 100644 --- a/atom/app/node_main.cc +++ b/atom/app/node_main.cc @@ -58,7 +58,7 @@ int NodeMain(int argc, char *argv[]) { // Enable support for v8 inspector. NodeDebugger node_debugger(env); - node_debugger.Start(); + node_debugger.Start(gin_env.platform()); mate::Dictionary process(gin_env.isolate(), env->process_object()); #if defined(OS_WIN) diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 89ab75c33cbe..8d6bd013fa33 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -137,7 +137,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() { // Enable support for v8 inspector node_debugger_.reset(new NodeDebugger(env)); - node_debugger_->Start(); + node_debugger_->Start(js_env_->platform()); // Add Electron extended APIs. atom_bindings_->BindTo(js_env_->isolate(), env->process_object()); diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc index b7e3aae20aaf..a1e824cad315 100644 --- a/atom/browser/javascript_environment.cc +++ b/atom/browser/javascript_environment.cc @@ -8,6 +8,7 @@ #include "base/command_line.h" #include "base/message_loop/message_loop.h" +#include "base/task_scheduler/initialization_util.h" #include "base/threading/thread_task_runner_handle.h" #include "content/public/common/content_switches.h" #include "gin/array_buffer.h" @@ -44,9 +45,17 @@ bool JavascriptEnvironment::Initialize() { if (!js_flags.empty()) v8::V8::SetFlagsFromString(js_flags.c_str(), js_flags.size()); + // The V8Platform of gin relies on Chromium's task schedule, which has not + // been started at this point, so we have to rely on Node's V8Platform. + platform_ = node::CreatePlatform( + base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0), + uv_default_loop(), nullptr); + v8::V8::InitializePlatform(platform_); + gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras, - gin::ArrayBufferAllocator::SharedInstance()); + gin::ArrayBufferAllocator::SharedInstance(), + false); return true; } diff --git a/atom/browser/javascript_environment.h b/atom/browser/javascript_environment.h index 43a7295f9026..0754df212c87 100644 --- a/atom/browser/javascript_environment.h +++ b/atom/browser/javascript_environment.h @@ -10,6 +10,7 @@ namespace node { class Environment; +class NodePlatform; } namespace atom { @@ -22,6 +23,7 @@ class JavascriptEnvironment { void OnMessageLoopCreated(); void OnMessageLoopDestroying(); + node::NodePlatform* platform() const { return platform_; } v8::Isolate* isolate() const { return isolate_; } v8::Local context() const { return v8::Local::New(isolate_, context_); @@ -30,6 +32,9 @@ class JavascriptEnvironment { private: bool Initialize(); + // Leaked on exit. + node::NodePlatform* platform_; + bool initialized_; gin::IsolateHolder isolate_holder_; v8::Isolate* isolate_; diff --git a/atom/browser/node_debugger.cc b/atom/browser/node_debugger.cc index 1f43f47fb1c4..27d2ce799916 100644 --- a/atom/browser/node_debugger.cc +++ b/atom/browser/node_debugger.cc @@ -14,15 +14,13 @@ namespace atom { NodeDebugger::NodeDebugger(node::Environment* env) - : env_(env), platform_(nullptr) { + : env_(env) { } NodeDebugger::~NodeDebugger() { - if (platform_) - FreePlatform(platform_); } -void NodeDebugger::Start() { +void NodeDebugger::Start(node::NodePlatform* platform) { auto inspector = env_->inspector_agent(); if (inspector == nullptr) return; @@ -37,13 +35,6 @@ void NodeDebugger::Start() { } if (options.inspector_enabled()) { - // Use custom platform since the gin platform does not work correctly - // with node's inspector agent. We use the default thread pool size - // specified by node.cc - platform_ = node::CreatePlatform( - /* thread_pool_size */ 4, env_->event_loop(), - /* tracing_controller */ nullptr); - // Set process._debugWaitConnect if --inspect-brk was specified to stop // the debugger on the first line if (options.wait_for_connect()) { @@ -51,7 +42,7 @@ void NodeDebugger::Start() { process.Set("_breakFirstLine", true); } - inspector->Start(platform_, nullptr, options); + inspector->Start(platform, nullptr, options); } } diff --git a/atom/browser/node_debugger.h b/atom/browser/node_debugger.h index 609a4dda3c53..cb176c777648 100644 --- a/atom/browser/node_debugger.h +++ b/atom/browser/node_debugger.h @@ -20,11 +20,10 @@ class NodeDebugger { explicit NodeDebugger(node::Environment* env); ~NodeDebugger(); - void Start(); + void Start(node::NodePlatform* platform); private: node::Environment* env_; - node::NodePlatform* platform_; DISALLOW_COPY_AND_ASSIGN(NodeDebugger); }; diff --git a/vendor/libchromiumcontent b/vendor/libchromiumcontent index 5b358f66a994..734f8be87b49 160000 --- a/vendor/libchromiumcontent +++ b/vendor/libchromiumcontent @@ -1 +1 @@ -Subproject commit 5b358f66a9948225e006fa3807213edf6e604409 +Subproject commit 734f8be87b4962386f532b9b2ea35c6ac0cb9f44