Skip to content

Commit

Permalink
Report errors using the top-level frame id rather than the pipeline id.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Jeffrey committed Nov 18, 2016
1 parent 22aebdf commit c228a4c
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 194 deletions.
330 changes: 159 additions & 171 deletions components/constellation/constellation.rs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions components/constellation/pipeline.rs
Expand Up @@ -82,6 +82,8 @@ pub struct InitialPipelineState {
pub id: PipelineId,
/// The ID of the frame that contains this Pipeline.
pub frame_id: FrameId,
/// The ID of the top-level frame that contains this Pipeline.
pub top_level_frame_id: FrameId,
/// The ID of the parent pipeline and frame type, if any.
/// If `None`, this is the root.
pub parent_info: Option<(PipelineId, FrameType)>,
Expand Down Expand Up @@ -204,6 +206,7 @@ impl Pipeline {
let unprivileged_pipeline_content = UnprivilegedPipelineContent {
id: state.id,
frame_id: state.frame_id,
top_level_frame_id: state.top_level_frame_id,
parent_info: state.parent_info,
constellation_chan: state.constellation_chan,
scheduler_chan: state.scheduler_chan,
Expand Down Expand Up @@ -381,6 +384,7 @@ impl Pipeline {
pub struct UnprivilegedPipelineContent {
id: PipelineId,
frame_id: FrameId,
top_level_frame_id: FrameId,
parent_info: Option<(PipelineId, FrameType)>,
constellation_chan: IpcSender<ScriptMsg>,
layout_to_constellation_chan: IpcSender<LayoutMsg>,
Expand Down Expand Up @@ -416,6 +420,7 @@ impl UnprivilegedPipelineContent {
let layout_pair = STF::create(InitialScriptState {
id: self.id,
frame_id: self.frame_id,
top_level_frame_id: self.top_level_frame_id,
parent_info: self.parent_info,
control_chan: self.script_chan.clone(),
control_port: self.script_port,
Expand All @@ -433,6 +438,7 @@ impl UnprivilegedPipelineContent {
}, self.load_data.clone());

LTF::create(self.id,
Some(self.top_level_frame_id),
self.load_data.url,
self.parent_info.is_some(),
layout_pair,
Expand Down
11 changes: 8 additions & 3 deletions components/layout_thread/lib.rs
Expand Up @@ -42,7 +42,6 @@ extern crate selectors;
extern crate serde_json;
extern crate servo_url;
extern crate style;
extern crate style_traits;
extern crate util;
extern crate webrender_traits;

Expand Down Expand Up @@ -80,7 +79,7 @@ use layout::webrender_helpers::{WebRenderDisplayListConverter, WebRenderFrameBui
use layout::wrapper::LayoutNodeLayoutData;
use layout::wrapper::drop_style_and_layout_data;
use layout_traits::LayoutThreadFactory;
use msg::constellation_msg::PipelineId;
use msg::constellation_msg::{FrameId, PipelineId};
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
use net_traits::image_cache_thread::UsePlaceholder;
use parking_lot::RwLock;
Expand Down Expand Up @@ -235,6 +234,7 @@ impl LayoutThreadFactory for LayoutThread {

/// Spawns a new layout thread.
fn create(id: PipelineId,
top_level_frame_id: Option<FrameId>,
url: ServoUrl,
is_iframe: bool,
chan: (Sender<Msg>, Receiver<Msg>),
Expand All @@ -251,7 +251,11 @@ impl LayoutThreadFactory for LayoutThread {
thread::spawn_named(format!("LayoutThread {:?}", id),
move || {
thread_state::initialize(thread_state::LAYOUT);
PipelineId::install(id);

if let Some(top_level_frame_id) = top_level_frame_id {
FrameId::install(top_level_frame_id);
}

{ // Ensures layout thread is destroyed before we send shutdown message
let sender = chan.0;
let layout = LayoutThread::new(id,
Expand Down Expand Up @@ -718,6 +722,7 @@ impl LayoutThread {

fn create_layout_thread(&self, info: NewLayoutThreadInfo) {
LayoutThread::create(info.id,
FrameId::installed(),
info.url.clone(),
info.is_parent,
info.layout_pair,
Expand Down
3 changes: 2 additions & 1 deletion components/layout_traits/lib.rs
Expand Up @@ -20,7 +20,7 @@ extern crate webrender_traits;

use gfx::font_cache_thread::FontCacheThread;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
use msg::constellation_msg::PipelineId;
use msg::constellation_msg::{FrameId, PipelineId};
use net_traits::image_cache_thread::ImageCacheThread;
use profile_traits::{mem, time};
use script_traits::{ConstellationControlMsg, LayoutControlMsg};
Expand All @@ -33,6 +33,7 @@ use std::sync::mpsc::{Receiver, Sender};
pub trait LayoutThreadFactory {
type Message;
fn create(id: PipelineId,
top_level_frame_id: Option<FrameId>,
url: ServoUrl,
is_iframe: bool,
chan: (Sender<Self::Message>, Receiver<Self::Message>),
Expand Down
23 changes: 12 additions & 11 deletions components/msg/constellation_msg.rs
Expand Up @@ -217,8 +217,6 @@ impl PipelineNamespace {

thread_local!(pub static PIPELINE_NAMESPACE: Cell<Option<PipelineNamespace>> = Cell::new(None));

thread_local!(pub static PIPELINE_ID: Cell<Option<PipelineId>> = Cell::new(None));

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
pub struct PipelineNamespaceId(pub u32);

Expand Down Expand Up @@ -246,15 +244,6 @@ impl PipelineId {
let PipelineIndex(index) = self.index;
webrender_traits::PipelineId(namespace_id, index)
}

pub fn install(id: PipelineId) {
PIPELINE_ID.with(|tls| tls.set(Some(id)))
}

pub fn installed() -> Option<PipelineId> {
PIPELINE_ID.with(|tls| tls.get())
}

}

impl fmt::Display for PipelineId {
Expand All @@ -265,6 +254,8 @@ impl fmt::Display for PipelineId {
}
}

thread_local!(pub static TOP_LEVEL_FRAME_ID: Cell<Option<FrameId>> = Cell::new(None));

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
pub struct FrameIndex(pub u32);

Expand All @@ -283,6 +274,16 @@ impl FrameId {
new_frame_id
})
}

/// Each script and layout thread should have the top-level frame id installed,
/// since it is used by crash reporting.
pub fn install(id: FrameId) {
TOP_LEVEL_FRAME_ID.with(|tls| tls.set(Some(id)))
}

pub fn installed() -> Option<FrameId> {
TOP_LEVEL_FRAME_ID.with(|tls| tls.get())
}
}

impl fmt::Display for FrameId {
Expand Down
9 changes: 7 additions & 2 deletions components/script/dom/dedicatedworkerglobalscope.rs
Expand Up @@ -26,7 +26,7 @@ use js::jsapi::{HandleValue, JS_SetInterruptCallback};
use js::jsapi::{JSAutoCompartment, JSContext};
use js::jsval::UndefinedValue;
use js::rust::Runtime;
use msg::constellation_msg::PipelineId;
use msg::constellation_msg::FrameId;
use net_traits::{IpcSend, load_whole_resource};
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
use rand::random;
Expand Down Expand Up @@ -158,9 +158,14 @@ impl DedicatedWorkerGlobalScope {
closing: Arc<AtomicBool>) {
let serialized_worker_url = worker_url.to_string();
let name = format!("WebWorker for {}", serialized_worker_url);
let top_level_frame_id = FrameId::installed();

spawn_named(name, move || {
thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER);
PipelineId::install(init.pipeline_id);

if let Some(top_level_frame_id) = top_level_frame_id {
FrameId::install(top_level_frame_id);
}

let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
Expand Down
2 changes: 1 addition & 1 deletion components/script/script_thread.rs
Expand Up @@ -517,8 +517,8 @@ impl ScriptThreadFactory for ScriptThread {
thread::spawn_named(format!("ScriptThread {:?}", state.id),
move || {
thread_state::initialize(thread_state::SCRIPT);
PipelineId::install(state.id);
PipelineNamespace::install(state.pipeline_namespace_id);
FrameId::install(state.top_level_frame_id);
let roots = RootCollection::new();
let _stack_roots_tls = StackRootTLS::new(&roots);
let id = state.id;
Expand Down
6 changes: 4 additions & 2 deletions components/script_traits/lib.rs
Expand Up @@ -442,6 +442,8 @@ pub struct InitialScriptState {
pub parent_info: Option<(PipelineId, FrameType)>,
/// The ID of the frame this script is part of.
pub frame_id: FrameId,
/// The ID of the top-level frame this script is part of.
pub top_level_frame_id: FrameId,
/// A channel with which messages can be sent to us (the script thread).
pub control_chan: IpcSender<ConstellationControlMsg>,
/// A port on which messages sent by the constellation to script can be received.
Expand Down Expand Up @@ -699,8 +701,8 @@ pub enum ConstellationMsg {
WebDriverCommand(WebDriverCommandMsg),
/// Reload the current page.
Reload,
/// A log entry, with the pipeline id and thread name
LogEntry(Option<PipelineId>, Option<String>, LogEntry),
/// A log entry, with the top-level frame id and thread name
LogEntry(Option<FrameId>, Option<String>, LogEntry),
}

/// Resources required by workerglobalscopes
Expand Down
6 changes: 3 additions & 3 deletions components/script_traits/script_msg.rs
Expand Up @@ -15,8 +15,8 @@ use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
use euclid::point::Point2D;
use euclid::size::Size2D;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::{FrameId, PipelineId, TraversalDirection};
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
use msg::constellation_msg::{PipelineId, TraversalDirection};
use net_traits::CoreResourceMsg;
use net_traits::storage_thread::StorageType;
use offscreen_gl_context::{GLContextAttributes, GLLimits};
Expand Down Expand Up @@ -131,8 +131,8 @@ pub enum ScriptMsg {
ResizeTo(Size2D<u32>),
/// Script has handled a touch event, and either prevented or allowed default actions.
TouchEventProcessed(EventResult),
/// A log entry, with the pipeline id and thread name
LogEntry(Option<PipelineId>, Option<String>, LogEntry),
/// A log entry, with the top-level frame id and thread name
LogEntry(Option<FrameId>, Option<String>, LogEntry),
/// Notifies the constellation that this pipeline has exited.
PipelineExited(PipelineId),
/// Send messages from postMessage calls from serviceworker
Expand Down

0 comments on commit c228a4c

Please sign in to comment.