Auto merge of #24862 - jdm:js-init-destroy-fit-the-second, r=asajeffrey

Ensure SpiderMonkey shuts down cleanly

This is the alternate solution that I described in #24845. Given how much simpler the resulting code is, I'm now much more in favour of this design. Depends on https://github.com/servo/rust-mozjs/pull/487.

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #21696 and fix #22276
- [x] There are tests for these changes
This commit is contained in:
bors-servo 2019-11-27 01:23:20 -05:00 committed by GitHub
commit f166422102
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 9 deletions

View file

@ -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();