From d6b3eb6db9ab027a9a70eea24775f549abf8b025 Mon Sep 17 00:00:00 2001 From: elias Date: Wed, 13 Mar 2019 11:20:31 -0500 Subject: [PATCH 1/3] removed spurrious assert in Drop for LoadBlocker --- components/script/document_loader.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index 8fd447350f4..f9f31811d94 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -77,8 +77,8 @@ impl LoadBlocker { impl Drop for LoadBlocker { fn drop(&mut self) { - if !thread::panicking() { - debug_assert!(self.load.is_none()); + if let Some(script_thread) = self.load.take() { + self.doc.finish_load(script_thread); } } } From c713febe7a43695e5e43762c188f5baf62282687 Mon Sep 17 00:00:00 2001 From: elias Date: Wed, 13 Mar 2019 11:21:58 -0500 Subject: [PATCH 2/3] let mark_document_with_no_blocked_loads() take a None value silently --- components/script/script_thread.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 9e20b09ef20..b3bd5b1c396 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -809,11 +809,13 @@ impl ScriptThread { pub fn mark_document_with_no_blocked_loads(doc: &Document) { SCRIPT_THREAD_ROOT.with(|root| { - let script_thread = unsafe { &*root.get().unwrap() }; - script_thread - .docs_with_no_blocking_loads - .borrow_mut() - .insert(Dom::from_ref(doc)); + unsafe { + if let Some(script_thread) = root.get() { + (*script_thread) + .docs_with_no_blocking_loads + .borrow_mut() + .insert(Dom::from_ref(doc)); + }} }) } From be82d7c9058cd22c54b01a4b6aa0858307364f6c Mon Sep 17 00:00:00 2001 From: elias Date: Wed, 13 Mar 2019 11:39:14 -0500 Subject: [PATCH 3/3] ran ./mach fmt - removed unused import in document_loader.rs - limit unsafe block in mark_document_with_no_blocked_loads in script_thread.rs - changed name of if let value to load in Drop for LoadBlocker in document_loader.rs --- components/script/document_loader.rs | 5 ++--- components/script/script_thread.rs | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index f9f31811d94..dac891053d7 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -14,7 +14,6 @@ use net_traits::request::RequestInit; use net_traits::{CoreResourceMsg, FetchChannels, FetchResponseMsg}; use net_traits::{IpcSend, ResourceThreads}; use servo_url::ServoUrl; -use std::thread; #[derive(Clone, Debug, JSTraceable, MallocSizeOf, PartialEq)] pub enum LoadType { @@ -77,8 +76,8 @@ impl LoadBlocker { impl Drop for LoadBlocker { fn drop(&mut self) { - if let Some(script_thread) = self.load.take() { - self.doc.finish_load(script_thread); + if let Some(load) = self.load.take() { + self.doc.finish_load(load); } } } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index b3bd5b1c396..41a7192e70a 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -809,13 +809,13 @@ impl ScriptThread { pub fn mark_document_with_no_blocked_loads(doc: &Document) { SCRIPT_THREAD_ROOT.with(|root| { - unsafe { if let Some(script_thread) = root.get() { - (*script_thread) + let script_thread = unsafe { &*script_thread }; + script_thread .docs_with_no_blocking_loads .borrow_mut() .insert(Dom::from_ref(doc)); - }} + } }) }