Do not create dummy node environment
There is a bug in V8 that using Private in a dummy environment would result in crash.
This commit is contained in:
parent
70f9cb098f
commit
896ea7b79d
1 changed files with 14 additions and 16 deletions
|
@ -90,18 +90,6 @@ void AtomRendererClient::WebKitInitialized() {
|
|||
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
|
||||
|
||||
OverrideNodeArrayBuffer();
|
||||
|
||||
node_bindings_->Initialize();
|
||||
node_bindings_->PrepareMessageLoop();
|
||||
|
||||
DCHECK(!global_env);
|
||||
|
||||
// Create a default empty environment which would be used when we need to
|
||||
// run V8 code out of a window context (like running a uv callback).
|
||||
v8::Isolate* isolate = blink::mainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
global_env = node::Environment::New(context, uv_default_loop());
|
||||
}
|
||||
|
||||
void AtomRendererClient::RenderThreadStarted() {
|
||||
|
@ -160,8 +148,14 @@ bool AtomRendererClient::OverrideCreatePlugin(
|
|||
|
||||
void AtomRendererClient::DidCreateScriptContext(
|
||||
v8::Handle<v8::Context> context) {
|
||||
// Give the node loop a run to make sure everything is ready.
|
||||
node_bindings_->RunMessageLoop();
|
||||
// Whether the node binding has been initialized.
|
||||
bool first_time = node_bindings_->uv_env() == nullptr;
|
||||
|
||||
// Prepare the node bindings.
|
||||
if (first_time) {
|
||||
node_bindings_->Initialize();
|
||||
node_bindings_->PrepareMessageLoop();
|
||||
}
|
||||
|
||||
// Setup node environment for each window.
|
||||
node::Environment* env = node_bindings_->CreateEnvironment(context);
|
||||
|
@ -169,10 +163,14 @@ void AtomRendererClient::DidCreateScriptContext(
|
|||
// Add atom-shell extended APIs.
|
||||
atom_bindings_->BindTo(env->isolate(), env->process_object());
|
||||
|
||||
// Make uv loop being wrapped by window context.
|
||||
if (node_bindings_->uv_env() == nullptr)
|
||||
if (first_time) {
|
||||
// Make uv loop being wrapped by window context.
|
||||
node_bindings_->set_uv_env(env);
|
||||
|
||||
// Give the node loop a run to make sure everything is ready.
|
||||
node_bindings_->RunMessageLoop();
|
||||
}
|
||||
|
||||
// Load everything.
|
||||
node_bindings_->LoadEnvironment(env);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue