diff options
author | Josh Matthews <josh@joshmatthews.net> | 2019-11-25 15:21:27 -0500 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2019-11-26 21:54:33 -0500 |
commit | 7944d9548cdac3eb18e28035378821a17076e2e5 (patch) | |
tree | 31c11c4c55a5c3c6dcc019fdfd63c794b6a1a11f /components/servo/lib.rs | |
parent | f1aa5d8dbdc32f6f474b09234558652b9bead686 (diff) | |
download | servo-7944d9548cdac3eb18e28035378821a17076e2e5.tar.gz servo-7944d9548cdac3eb18e28035378821a17076e2e5.zip |
script: Ensure JS engine is initialized and deinitialized on the same thread.
Diffstat (limited to 'components/servo/lib.rs')
-rw-r--r-- | components/servo/lib.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/components/servo/lib.rs b/components/servo/lib.rs index 811a4a002d9..cd1296e608c 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -105,6 +105,7 @@ use profile::mem as profile_mem; use profile::time as profile_time; use profile_traits::mem; use profile_traits::time; +use script::JSEngineSetup; use script_traits::{ ConstellationMsg, SWManagerSenders, ScriptToConstellationChan, WindowSizeData, }; @@ -271,6 +272,10 @@ pub struct Servo<Window: WindowMethods + 'static + ?Sized> { embedder_receiver: EmbedderReceiver, embedder_events: Vec<(Option<BrowserId>, EmbedderMsg)>, profiler_enabled: bool, + /// For single-process Servo instances, this field controls the initialization + /// and deinitialization of the JS Engine. Multiprocess Servo instances have their + /// own instance that exists in the content process instead. + _js_engine_setup: Option<JSEngineSetup>, } #[derive(Clone)] @@ -415,7 +420,11 @@ where // Important that this call is done in a single-threaded fashion, we // can't defer it after `create_constellation` has started. - script::init(); + let js_engine_setup = if !opts.multiprocess { + Some(script::init()) + } else { + None + }; if pref!(dom.webxr.enabled) && pref!(dom.webvr.enabled) { panic!("We don't currently support running both WebVR and WebXR"); @@ -556,6 +565,7 @@ where embedder_receiver: embedder_receiver, embedder_events: Vec::new(), profiler_enabled: false, + _js_engine_setup: js_engine_setup, } } @@ -980,7 +990,7 @@ pub fn run_content_process(token: String) { // send the required channels to the service worker manager let sw_senders = unprivileged_content.swmanager_senders(); - script::init(); + let _js_engine_setup = script::init(); script::init_service_workers(sw_senders); media_platform::init(); |