Report panics in web worker threads.

This commit is contained in:
Ms2ger 2016-05-17 18:07:12 +02:00
parent aa8c835d3b
commit 1ebe681d8d
7 changed files with 42 additions and 12 deletions

View file

@ -36,8 +36,7 @@ use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::sync::{Arc, Mutex};
use url::Url;
use util::str::DOMString;
use util::thread::spawn_named;
use util::thread_state;
use util::thread::spawn_named_with_send_on_panic;
use util::thread_state::{IN_WORKER, SCRIPT};
/// Messages used to control the worker event loops
@ -218,9 +217,9 @@ impl DedicatedWorkerGlobalScope {
own_sender: Sender<(TrustedWorkerAddress, WorkerScriptMsg)>,
receiver: Receiver<(TrustedWorkerAddress, WorkerScriptMsg)>) {
let serialized_worker_url = worker_url.to_string();
spawn_named(format!("WebWorker for {}", serialized_worker_url), move || {
thread_state::initialize(SCRIPT | IN_WORKER);
let name = format!("WebWorker for {}", serialized_worker_url);
let panic_chan = init.panic_chan.clone();
spawn_named_with_send_on_panic(name, SCRIPT | IN_WORKER, move || {
let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
@ -284,7 +283,7 @@ impl DedicatedWorkerGlobalScope {
global.handle_event(event);
}
}, reporter_name, parent_sender, CommonScriptMsg::CollectReports);
});
}, Some(id.clone()), panic_chan);
}
pub fn script_chan(&self) -> Box<ScriptChan + Send> {