Implement discarding Document objects to reclaim space. #14312

Merged
merged 5 commits into from Jan 4, 2017

Projects

None yet

10 participants

@asajeffrey
Member
asajeffrey commented Nov 21, 2016 edited

This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered.

Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit.

Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events.

To test this, I added a -Zdiscard-inactive-documents debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #14262.
  • These changes do not require tests because we should be able to use the existing tests with -Zdiscard-inactive-documents.

This change is Reviewable

@KiChjang KiChjang was assigned by highfive Nov 21, 2016
@highfive

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/script_thread.rs, components/script/dom/document.rs
  • @kichjang: components/script/script_thread.rs, components/script/dom/document.rs
@highfive

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify script code, but no tests are modified. Please consider adding a test!
@asajeffrey
Member

cc @Ms2ger @ConnorGBrewster @metajack

@metajack
Contributor

Maybe the name of that flag needs unsafe in it? It seems a little confusingly worded as is.

@bors-servo
Contributor

β˜”οΈ The latest upstream changes (presumably #14313) made this pull request unmergeable. Please resolve the merge conflicts.

@asajeffrey
Member

@metajack: yes, that option name isn't my best-ever writing. -Zaggressively-discard-documents? -Zdiscard-on-navigation? -Zunsafe-navigation-discard?

@bors-servo
Contributor

β˜”οΈ The latest upstream changes (presumably #14211) made this pull request unmergeable. Please resolve the merge conflicts.

@asajeffrey
Member

Might be worth disabling this by default, and enabling it with a flag?

@metajack
Contributor

@asajeffrey Why disable by default?

@asajeffrey
Member

@metajack just being conservative. This change makes servo a lot more like FF, in that back/fwd will almost always result in a reload. This is not necessarily bad, but it is different.

@metajack
Contributor

Leaving it off by default will make it consume infinite memory, no?

I can see a case for some middle ground setting being desireable, but I assume that is much more complex to guarantee since somehow we will have to keep the appropriate pipelines alive artificially.

@asajeffrey
Member

@metajack yes, there are more space leaks without this PR than with it. It wouldn't be too hard to implement whatever heuristic we want, we just add a message from the constellation to the script thread saying when a pipeline is discardable. I just piggybacked freeze/thaw because it was already there.

components/script/script_thread.rs
+/// The state that a document managed by this script thread could be in.
+#[must_root]
+enum DocumentState {
+ Kept(bool, JS<Document>),
@emilio
emilio Nov 26, 2016 Member

Could you document what this bool means? I guess it's thawed, but would be ok to have it written here, or alternatively add a binary enum or a Kept { thawed: bool, document: JS<Document> } instead of a plain bool.

components/script/script_thread.rs
+ fn trace(&self, trc: *mut JSTracer) {
+ // Note: we only trace thawed documents.
+ if let DocumentState::Kept(true, ref doc) = *self {
+ doc.trace(trc);
@nox
nox Nov 27, 2016 Member

Why is this needed? Just derive the trait on DocumentState.

@asajeffrey
asajeffrey Nov 28, 2016 Member

The derived version would trace documents even if they were Kept(false, doc). The idea is to implement poor-dev's weak references, that don't keep the documents alive.

@KiChjang
Member
KiChjang commented Dec 1, 2016

r? @jdm

@highfive highfive assigned jdm and unassigned KiChjang Dec 1, 2016
@bors-servo
Contributor

β˜”οΈ The latest upstream changes (presumably #13489) made this pull request unmergeable. Please resolve the merge conflicts.

@asajeffrey
Member

@metajack I renamed the option to -Zunsafe-discard-documents.

@metajack
Contributor

@asajeffrey πŸ‘

components/script/script_thread.rs
}
impl<'a> Iterator for DocumentsIter<'a> {
type Item = (PipelineId, Root<Document>);
fn next(&mut self) -> Option<(PipelineId, Root<Document>)> {
- self.iter.next().map(|(id, doc)| (*id, Root::from_ref(&**doc)))
+ while let Some((id, state)) = self.iter.next() {
@frewsxcv
frewsxcv Dec 14, 2016 Member

nit: I think this could just be a for loop

@asajeffrey
asajeffrey Dec 14, 2016 Member

I don't think it can, the important part is that the iterator is recomputed each time round the loop.

@bors-servo
Contributor

β˜”οΈ The latest upstream changes (presumably #14592) made this pull request unmergeable. Please resolve the merge conflicts.

@jdm

This change is nicely self-contained and I found it quite readable. Well done!

components/script/script_thread.rs
+ /// The boolean flag indicates whether the script thread is keeping the document alive.
+ /// When documents are active, the flag is true, but if they become inactive we
+ /// set it to false, at which point the document can be garbage collected.
+ Kept(bool, JS<Document>),
@jdm
jdm Dec 15, 2016 Member

It might be nice to use a enum DocumentReference { Strong, Weak } instead of a boolean.

components/script/script_thread.rs
+ }
+
+ // This function is safe as long as Document implements Drop
+ // to set the state to be discarded.
@jdm
jdm Dec 15, 2016 Member

Let's add a unit test verifying that Document at least implements the Drop trait.

@asajeffrey
asajeffrey Dec 15, 2016 Member

I can add a compile test that Document implements Drop, I can't think of a way to actually test the behaviour, since building a Document object is non-trivial.

components/script/script_thread.rs
+ SCRIPT_THREAD_ROOT.with(|root| {
+ if let Some(script_thread) = root.get() {
+ let script_thread = unsafe { &*script_thread };
+ if document.browsing_context().is_some() {
@jdm
jdm Dec 15, 2016 Member

Let's use is_none and early-return instead.

components/script/script_thread.rs
+ let pipeline_id = document.window().upcast::<GlobalScope>().pipeline_id();
+ let url = document.url().clone();
+ debug!("Document {} discarded.", pipeline_id);
+ if script_thread.documents.borrow_mut().discard(pipeline_id, url).is_some() {
@jdm
jdm Dec 15, 2016 Member

is_none and early-return.

components/script/script_thread.rs
+ DocumentState::Discarded(_) => {
+ warn!("Freezing already discarded pipeline {}.", id);
+ }
+ };
@jdm
jdm Dec 15, 2016 Member

I think this ; is unnecessary?

components/script/script_thread.rs
}
- }
- document.window().thaw();
+ };
@jdm
jdm Dec 15, 2016 Member

I think the ; is unecessary?

@jdm
Member
jdm commented Dec 16, 2016

Looks good! Squash and r=jdm!

@jdm
jdm approved these changes Dec 16, 2016 View changes
@asajeffrey
Member

@bors-servo r=jdm

@bors-servo
Contributor

πŸ“Œ Commit f918838 has been approved by jdm

@bors-servo
Contributor

βŒ›οΈ Testing commit f918838 with merge 74d9eb9...

@bors-servo bors-servo added a commit that referenced this pull request Dec 16, 2016
@bors-servo bors-servo Auto merge of #14312 - asajeffrey:script-discard-documents, r=jdm
Implement discarding Document objects to reclaim space.

<!-- Please describe your changes on the following line: -->

This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered.

Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit.

Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events.

To test this, I added a `-Zdiscard-inactive-documents` debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14262.
- [X] These changes do not require tests because we should be able to use the existing tests with `-Zdiscard-inactive-documents`.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14312)
<!-- Reviewable:end -->
74d9eb9
@bors-servo
Contributor

πŸ’” Test failed - mac-rel-wpt2

@asajeffrey
Member

Looks like there are two sources of panic here:

  β–Ά CRASH [expected OK] /_mozilla/mozilla/iframe_replacement.html
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”‚ 3.3 (Core Profile) Mesa 12.0.1
  β”‚ DOMRefCell<T> already borrowed: BorrowMutError (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }, at ../src/libcore/result.rs:837)
  β”‚ stack backtrace:
  β”‚    0:        0x10c026fbe - backtrace::backtrace::trace::he729cbd729f64e70
  β”‚    1:        0x10c0272ac - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:        0x10bf0f4e4 - servo::main::_{{closure}}::h49d5a9f20e768acc
  β”‚    3:        0x10da2a223 - std::panicking::rust_panic_with_hook::ha5aed1dfc0e220e3
  β”‚    4:        0x10da2a0f4 - std::panicking::begin_panic::hc066339e2fdc17d1
  β”‚    5:        0x10da2a012 - std::panicking::begin_panic_fmt::h5912b2d2df332044
  β”‚    6:        0x10da29f77 - rust_begin_unwind
  β”‚    7:        0x10da57e30 - core::panicking::panic_fmt::h561c5ee168a3d2cb
  β”‚    8:        0x10c4f9c2b - core::result::unwrap_failed::h1189d57f062a69a9
  β”‚    9:        0x10c8346e4 - script::script_thread::ScriptThread::load::ha40f84822528642d
  β”‚   10:        0x10c801183 - script::script_thread::ScriptThread::page_headers_available::hc1fc5494d68d9e11
  β”‚   11:        0x10c76f3e2 - _<script..dom..servoparser..ParserContext as net_traits..FetchResponseListener>::process_response::h78782db4774cad5a
  β”‚   12:        0x10c82ce07 - script::script_thread::ScriptThread::handle_new_layout::hc632a62a276fcebe
  β”‚   13:        0x10c804c05 - script::script_thread::ScriptThread::process_attach_layout::h5be5882c0a184922
  β”‚   14:        0x10c6b511f - script::dom::htmliframeelement::HTMLIFrameElement::navigate_or_reload_child_browsing_context::h1dc28b0010e55275
  β”‚   15:        0x10c6bb2f7 - _<script..dom..htmliframeelement..HTMLIFrameElement as script..dom..virtualmethods..VirtualMethods>::bind_to_tree::hf4fd38401e6445ad
  β”‚   16:        0x10c71bfed - script::dom::node::Node::insert::h03504a8da50b8464
  β”‚   17:        0x10c71b1b6 - script::dom::node::Node::pre_insert::h8725f9af280f333a
  β”‚   18:        0x10c335486 - std::panicking::try::do_call::h08ecd16fc6fa6632
  β”‚   19:        0x10da2b0fa - __rust_maybe_catch_panic
  β”‚   20:        0x10ca08080 - script::dom::bindings::codegen::Bindings::NodeBinding::NodeBinding::appendChild::h73a684313300ab6f
  β”‚   21:        0x10cb265c8 - CallJitMethodOp
  β”‚   22:        0x10c5d0632 - script::dom::bindings::utils::generic_call::ha930562ee924b3b8
  β”‚   23:        0x10d313ade - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚   24:        0x10d30d2fc - _ZL9InterpretP9JSContextRN2js8RunStateE
  β”‚   25:        0x10d3009ba - 2js9RunScriptEP9JSContextRNS_8RunState
  β”‚   26:        0x10d313e32 - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚   27:        0x10d313f95 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚   28:        0x10d2405a0 - 2js9fun_applyEP9JSContextjPN2JS5Value
  β”‚   29:        0x10d313ade - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚   30:        0x10d30d2fc - _ZL9InterpretP9JSContextRN2js8RunStateE
  β”‚   31:        0x10d3009ba - 2js9RunScriptEP9JSContextRNS_8RunState
  β”‚   32:        0x10d313e32 - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚   33:        0x10d313f95 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚   34:        0x10d2405a0 - 2js9fun_applyEP9JSContextjPN2JS5Value
  β”‚   35:        0x10d313ade - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚   36:        0x10d30d2fc - _ZL9InterpretP9JSContextRN2js8RunStateE
  β”‚   37:        0x10d3009ba - 2js9RunScriptEP9JSContextRNS_8RunState
  β”‚   38:        0x10d313e32 - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚   39:        0x10d313f95 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚   40:        0x10d1e0829 - _Z20JS_CallFunctionValueP9JSContextN2JS6HandleIP8JSObjectEENS2_INS1_5ValueEEERKNS1_16HandleValueArrayENS1_13MutableHandleIS6_EE
  β”‚   41:        0x10c951e50 - script::dom::bindings::codegen::Bindings::FunctionBinding::Function::Call::h182d4655c56b6d63
  β”‚   42:        0x10c67fecb - script::dom::globalscope::GlobalScope::fire_timer::hb880fb43000be939
  β”‚   43:        0x10c8109ad - script::script_thread::ScriptThread::handle_msgs::_{{closure}}::h631fbb1d6c7b50f3
  β”‚   44:        0x10c80b8e5 - script::script_thread::ScriptThread::handle_msgs::h35411c91588496a8
  β”‚   45:        0x10c4a1fc7 - std::panicking::try::do_call::hee5970deb3fae632
  β”‚   46:        0x10da2b0fa - __rust_maybe_catch_panic
  β”‚   47:        0x10c524416 - _<F as alloc..boxed..FnBox<A>>::call_box::h4bc90276e8ce5317
  β”‚   48:        0x10da291a4 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  β”‚   49:     0x7fff990dc059 - _pthread_body
  β”‚   50:     0x7fff990dbfd6 - _pthread_start
  β”‚ ERROR:servo: DOMRefCell<T> already borrowed: BorrowMutError
  β”” Pipeline failed in hard-fail mode.  Crashing!

  β–Ά CRASH [expected OK] /_mozilla/mozilla/mozbrowser/private_browsing.html
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”‚ 3.3 (Core Profile) Mesa 12.0.1
  β”‚ ALERT: private=active private=active
  β”‚ assertion failed: !(*untracked_reflector).get_jsobject().is_null() (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(2) }, at /Users/servo/buildbot/slave/mac-rel-wpt2/build/components/script/dom/bindings/js.rs:518)
  β”‚ stack backtrace:
  β”‚    0:        0x10bb16fbe - backtrace::backtrace::trace::he729cbd729f64e70
  β”‚    1:        0x10bb172ac - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:        0x10b9ff4e4 - servo::main::_{{closure}}::h49d5a9f20e768acc
  β”‚    3:        0x10d51a223 - std::panicking::rust_panic_with_hook::ha5aed1dfc0e220e3
  β”‚    4:        0x10be13604 - std::panicking::begin_panic::h5f0a1fd8f4de57ec
  β”‚    5:        0x10c32a2c8 - script::script_thread::shut_down_layout::h5ba04526943b39b5
  β”‚    6:        0x10c2f4e1b - script::script_thread::ScriptThread::discard_document::hbf430b5a74c9b8cf
  β”‚    7:        0x10bf5eb01 - std::panicking::try::do_call::hcb58e503341e6780
  β”‚    8:        0x10d51b0fa - __rust_maybe_catch_panic
  β”‚    9:        0x10c410704 - script::dom::bindings::codegen::Bindings::DocumentBinding::DocumentBinding::_finalize::he447ddbb5b80be7f
  β”‚   10:        0x10cda0f59 - _ZN2js14proxy_FinalizeEPNS_6FreeOpEP8JSObject
  β”‚   11:        0x10cd62750 - _ZN2js2gc5Arena8finalizeI8JSObjectEEmPNS_6FreeOpENS0_9AllocKindEm
  β”‚   12:        0x10cd3c73c - 2js2gc10ArenaLists30queueForegroundObjectsForSweepEPNS_6FreeOp
  β”‚   13:        0x10cd42e00 - 2js2gc9GCRuntime22beginSweepingZoneGroupERNS_26AutoLockForExclusiveAccess
  β”‚   14:        0x10cd4394e - 2js2gc9GCRuntime15beginSweepPhaseEbRNS_26AutoLockForExclusiveAccess
  β”‚   15:        0x10cd45bd9 - 2js2gc9GCRuntime23incrementalCollectSliceERNS_11SliceBudgetEN2JS8gcreason6ReasonERNS_26AutoLockForExclusiveAccess
  β”‚   16:        0x10cd4648b - 2js2gc9GCRuntime7gcCycleEbRNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   17:        0x10cd469d3 - 2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   18:        0x10cd46cc8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚   19:        0x10c2af03f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812
  β”‚   20:        0x10c32a175 - script::script_thread::shut_down_layout::h5ba04526943b39b5
  β”‚   21:        0x10c322221 - script::script_thread::ScriptThread::handle_exit_pipeline_msg::h0e7d95e366d5c293
  β”‚   22:        0x10c3025c4 - script::script_thread::ScriptThread::handle_msg_from_constellation::h1bd1ba5964cb0e7c
  β”‚   23:        0x10c300afc - script::script_thread::ScriptThread::handle_msgs::_{{closure}}::h631fbb1d6c7b50f3
  β”‚   24:        0x10c2fb8e5 - script::script_thread::ScriptThread::handle_msgs::h35411c91588496a8
  β”‚   25:        0x10bf91fc7 - std::panicking::try::do_call::hee5970deb3fae632
  β”‚   26:        0x10d51b0fa - __rust_maybe_catch_panic
  β”‚   27:        0x10c014416 - _<F as alloc..boxed..FnBox<A>>::call_box::h4bc90276e8ce5317
  β”‚   28:        0x10d5191a4 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  β”‚   29:     0x7fff990dc059 - _pthread_body
  β”‚   30:     0x7fff990dbfd6 - _pthread_start
  β”‚ ERROR:servo: assertion failed: !(*untracked_reflector).get_jsobject().is_null()
  β”” Pipeline failed in hard-fail mode.  Crashing!

Oh well, gives me something to work on tomorrow.

@jdm
Member
jdm commented Dec 16, 2016

The first one is #14553. The second one is very unfortunate reentry problems :(

@asajeffrey
Member

I'll have a look at the reentry problem tomorrow, hopefully it's similar to the reentry issues @Ms2ger fixed for Documents.

@asajeffrey
Member

The fix for the reentrancy problems is as per #14589. Probably easiest to land that PR first.

@bors-servo
Contributor

β˜”οΈ The latest upstream changes (presumably #14589) made this pull request unmergeable. Please resolve the merge conflicts.

@asajeffrey
Member
@bors-servo
Contributor

βŒ›οΈ Trying commit ee49841 with merge 3fce171...

@bors-servo bors-servo added a commit that referenced this pull request Dec 16, 2016
@bors-servo bors-servo Auto merge of #14312 - asajeffrey:script-discard-documents, r=<try>
Implement discarding Document objects to reclaim space.

<!-- Please describe your changes on the following line: -->

This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered.

Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit.

Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events.

To test this, I added a `-Zdiscard-inactive-documents` debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14262.
- [X] These changes do not require tests because we should be able to use the existing tests with `-Zdiscard-inactive-documents`.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14312)
<!-- Reviewable:end -->
3fce171
@bors-servo
Contributor

πŸ’” Test failed - mac-rel-wpt2

@asajeffrey
Member

Now the panics are:

  β–Ά CRASH [expected PASS] /_mozilla/css/layerization_layer_size.html
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”‚ 3.3 (Core Profile) Mesa 12.0.1
  β”‚ Shutting down the Constellation after generating an output file or exit flag specified
  β”‚ called `Option::unwrap()` on a `None` value (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }, at ../src/libcore/option.rs:323)
  β”‚ stack backtrace:
  β”‚    0:        0x101be361e - backtrace::backtrace::trace::he729cbd729f64e70
  β”‚    1:        0x101be390c - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:        0x101acba64 - servo::main::_{{closure}}::h49d5a9f20e768acc
  β”‚    3:        0x1035eafc3 - std::panicking::rust_panic_with_hook::ha5aed1dfc0e220e3
  β”‚    4:        0x1035eae94 - std::panicking::begin_panic::hc066339e2fdc17d1
  β”‚    5:        0x1035eadb2 - std::panicking::begin_panic_fmt::h5912b2d2df332044
  β”‚    6:        0x1035ead17 - rust_begin_unwind
  β”‚    7:        0x103618bd0 - core::panicking::panic_fmt::h561c5ee168a3d2cb
  β”‚    8:        0x103618ad4 - core::panicking::panic::h194ce5d68a8f28a1
  β”‚    9:        0x102376dfe - _<script..dom..window..Window as script..dom..bindings..codegen..Bindings..WindowBinding..WindowBinding..WindowMethods>::Document::hb1b4a910fa18398b
  β”‚   10:        0x10237e42d - script::dom::window::Window::get_url::h1810480ac5d2b9c8
  β”‚   11:        0x1023bf8a5 - script::script_thread::ScriptThread::discard_window::h18eee6f0e553e989
  β”‚   12:        0x101ffad8a - std::panicking::try::do_call::hab8a6b73afa31fb7
  β”‚   13:        0x1035ebe9a - __rust_maybe_catch_panic
  β”‚   14:        0x1026a59d4 - script::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::_finalize::hd13a5ac98ab26490
  β”‚   15:        0x102e33530 - _ZN2js2gc5Arena8finalizeI8JSObjectEEmPNS_6FreeOpENS0_9AllocKindEm
  β”‚   16:        0x102e0e5fc - 2js2gc10ArenaLists30queueForegroundObjectsForSweepEPNS_6FreeOp
  β”‚   17:        0x102e13be0 - 2js2gc9GCRuntime22beginSweepingZoneGroupERNS_26AutoLockForExclusiveAccess
  β”‚   18:        0x102e1472e - 2js2gc9GCRuntime15beginSweepPhaseEbRNS_26AutoLockForExclusiveAccess
  β”‚   19:        0x102e169b9 - 2js2gc9GCRuntime23incrementalCollectSliceERNS_11SliceBudgetEN2JS8gcreason6ReasonERNS_26AutoLockForExclusiveAccess
  β”‚   20:        0x102e1726b - 2js2gc9GCRuntime7gcCycleEbRNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   21:        0x102e177b3 - 2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   22:        0x102e17aa8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚   23:        0x102379c0f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812
  β”‚   24:        0x1023f4cf5 - script::script_thread::shut_down_layout::h5ba04526943b39b5
  β”‚   25:        0x1023ece61 - script::script_thread::ScriptThread::handle_exit_pipeline_msg::h0e7d95e366d5c293
  β”‚   26:        0x1023cd134 - script::script_thread::ScriptThread::handle_msg_from_constellation::h1bd1ba5964cb0e7c
  β”‚   27:        0x1023cb65d - script::script_thread::ScriptThread::handle_msgs::_{{closure}}::h631fbb1d6c7b50f3
  β”‚   28:        0x1023c6465 - script::script_thread::ScriptThread::handle_msgs::h35411c91588496a8
  β”‚   29:        0x10205ed87 - std::panicking::try::do_call::hee5970deb3fae632
  β”‚   30:        0x1035ebe9a - __rust_maybe_catch_panic
  β”‚   31:        0x1020e1336 - _<F as alloc..boxed..FnBox<A>>::call_box::h4bc90276e8ce5317
  β”‚   32:        0x1035e9f44 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  β”‚   33:     0x7fff990dc059 - _pthread_body
  β”‚   34:     0x7fff990dbfd6 - _pthread_start
  β”‚ ERROR:servo: called `Option::unwrap()` on a `None` value
  β”” Pipeline failed in hard-fail mode.  Crashing!

caused by Window::get_url being called on a window without a Document, and:

  β–Ά TIMEOUT [expected PASS] /_mozilla/css/stacked_layers.html
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”‚ 3.3 (Core Profile) Mesa 12.0.1
  β”‚ Shutting down the Constellation after generating an output file or exit flag specified
  β”‚ Assertion failure: !rt->isHeapBusy(), at /Users/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsgc.cpp:6239
  β”‚ Stack trace for thread "ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }"
  β”‚ stack backtrace:
  β”‚    0:        0x101d4e61e - backtrace::backtrace::trace::he729cbd729f64e70
  β”‚    1:        0x101d4e90c - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:        0x101c3454c - servo::install_crash_handler::handler::hd0510429f5634b95
  β”‚    3:     0x7fff91e69f19 - _sigtramp
  β”‚    4:        0x102f82a3d - 2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚    5:        0x102f82aa8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚    6:        0x1024e4c0f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812
  β”‚    7:        0x10255fcf5 - script::script_thread::shut_down_layout::h5ba04526943b39b5
  β”‚    8:        0x10252a9a4 - script::script_thread::ScriptThread::discard_window::h18eee6f0e553e989
  β”‚    9:        0x102165d8a - std::panicking::try::do_call::hab8a6b73afa31fb7
  β”‚   10:        0x103756e9a - __rust_maybe_catch_panic
  β”‚   11:        0x1028109d4 - script::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::_finalize::hd13a5ac98ab26490
  β”‚   12:        0x102f9e530 - _ZN2js2gc5Arena8finalizeI8JSObjectEEmPNS_6FreeOpENS0_9AllocKindEm
  β”‚   13:        0x102f795fc - 2js2gc10ArenaLists30queueForegroundObjectsForSweepEPNS_6FreeOp
  β”‚   14:        0x102f7ebe0 - 2js2gc9GCRuntime22beginSweepingZoneGroupERNS_26AutoLockForExclusiveAccess
  β”‚   15:        0x102f7f72e - 2js2gc9GCRuntime15beginSweepPhaseEbRNS_26AutoLockForExclusiveAccess
  β”‚   16:        0x102f819b9 - 2js2gc9GCRuntime23incrementalCollectSliceERNS_11SliceBudgetEN2JS8gcreason6ReasonERNS_26AutoLockForExclusiveAccess
  β”‚   17:        0x102f8226b - 2js2gc9GCRuntime7gcCycleEbRNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   18:        0x102f827b3 - 2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   19:        0x102f82aa8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚   20:        0x1024e4c0f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812
  β”‚   21:        0x10255fcf5 - script::script_thread::shut_down_layout::h5ba04526943b39b5
  β”‚   22:        0x102557e61 - script::script_thread::ScriptThread::handle_exit_pipeline_msg::h0e7d95e366d5c293
  β”‚   23:        0x102538134 - script::script_thread::ScriptThread::handle_msg_from_constellation::h1bd1ba5964cb0e7c
  β”‚   24:        0x10253665d - script::script_thread::ScriptThread::handle_msgs::_{{closure}}::h631fbb1d6c7b50f3
  β”‚   25:        0x102531465 - script::script_thread::ScriptThread::handle_msgs::h35411c91588496a8
  β”‚   26:        0x1021c9d87 - std::panicking::try::do_call::hee5970deb3fae632
  β”‚   27:        0x103756e9a - __rust_maybe_catch_panic
  β”‚   28:        0x10224c336 - _<F as alloc..boxed..FnBox<A>>::call_box::h4bc90276e8ce5317
  β”‚   29:        0x103754f44 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  β”‚   30:     0x7fff990dc059 - _pthread_body
  β”‚   31:     0x7fff990dbfd6 - _pthread_start
  β”‚ Stack trace for thread "ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }"
  β”‚ stack backtrace:
  β”‚    0:        0x101d4e61e - backtrace::backtrace::trace::he729cbd729f64e70
  β”‚    1:        0x101d4e90c - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:        0x101c3454c - servo::install_crash_handler::handler::hd0510429f5634b95
  β”‚    3:     0x7fff91e69f19 - _sigtramp
  β”‚    4:        0x101c345d0 - servo::install_crash_handler::handler::hd0510429f5634b95
  β”‚    5:     0x7fff91e69f19 - _sigtramp
  β”‚    6:        0x102f82a3d - 2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚    7:        0x102f82aa8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚    8:        0x1024e4c0f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812
  β”‚    9:        0x10255fcf5 - script::script_thread::shut_down_layout::h5ba04526943b39b5
  β”‚   10:        0x10252a9a4 - script::script_thread::ScriptThread::discard_window::h18eee6f0e553e989
  β”‚   11:        0x102165d8a - std::panicking::try::do_call::hab8a6b73afa31fb7
  β”‚   12:        0x103756e9a - __rust_maybe_catch_panic
  β”‚   13:        0x1028109d4 - script::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::_finalize::hd13a5ac98ab26490
  β”‚   14:        0x102f9e530 - _ZN2js2gc5Arena8finalizeI8JSObjectEEmPNS_6FreeOpENS0_9AllocKindEm
  β”‚   15:        0x102f795fc - 2js2gc10ArenaLists30queueForegroundObjectsForSweepEPNS_6FreeOp
  β”‚   16:        0x102f7ebe0 - 2js2gc9GCRuntime22beginSweepingZoneGroupERNS_26AutoLockForExclusiveAccess
  β”‚   17:        0x102f7f72e - 2js2gc9GCRuntime15beginSweepPhaseEbRNS_26AutoLockForExclusiveAccess
  β”‚   18:        0x102f819b9 - 2js2gc9GCRuntime23incrementalCollectSliceERNS_11SliceBudgetEN2JS8gcreason6ReasonERNS_26AutoLockForExclusiveAccess
  β”‚   19:        0x102f8226b - 2js2gc9GCRuntime7gcCycleEbRNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   20:        0x102f827b3 - 2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚   21:        0x102f82aa8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚   22:        0x1024e4c0f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812
  β”‚   23:        0x10255fcf5 - script::script_thread::shut_down_layout::h5ba04526943b39b5
  β”‚   24:        0x102557e61 - script::script_thread::ScriptThread::handle_exit_pipeline_msg::h0e7d95e366d5c293
  β”‚   25:        0x102538134 - script::script_thread::ScriptThread::handle_msg_from_constellation::h1bd1ba5964cb0e7c
  β”‚   26:        0x10253665d - script::script_thread::ScriptThread::handle_msgs::_{{closure}}::h631fbb1d6c7b50f3
  β”‚   27:        0x102531465 - script::script_thread::ScriptThread::handle_msgs::h35411c91588496a8
  β”‚   28:        0x1021c9d87 - std::panicking::try::do_call::hee5970deb3fae632
  β”‚   29:        0x103756e9a - __rust_maybe_catch_panic
  β”‚   30:        0x10224c336 - _<F as alloc..boxed..FnBox<A>>::call_box::h4bc90276e8ce5317
  β”‚   31:        0x103754f44 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  β”‚   32:     0x7fff990dc059 - _pthread_body
  β””   33:     0x7fff990dbfd6 - _pthread_start

which is scarier, and is presumably caused by shutting down layout on a window that is in the middle of a GC.

@jdm
Member
jdm commented Dec 16, 2016

The scarier one is another instance of calling shut_down_layout from within shut_down_layout, like you implied.

@asajeffrey
Member

From the stack trace fragment:

  β”‚    3:     0x7fff91e69f19 - _sigtramp
  β”‚    4:        0x102f82a3d - 2js2gc9GCRuntime7collectEbNS_11SliceBudgetEN2JS8gcreason6Reason
  β”‚    5:        0x102f82aa8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚    6:        0x1024e4c0f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812
...
  β”‚   21:        0x102f82aa8 - 2js2gc9GCRuntime2gcE18JSGCInvocationKindN2JS8gcreason6Reason
  β”‚   22:        0x1024e4c0f - script::dom::window::Window::clear_js_runtime::hcb0ce2179ef9b812

it looks like the probem is that clear_js_runtime calls GC, which starts a GC inside a GC, and oh dear.

@asajeffrey
Member

Gulp, switched off the GC during Window::clear_js_runtime. @bors-servo try

@bors-servo
Contributor

βŒ›οΈ Trying commit ed3edbe with merge 938ab84...

@bors-servo bors-servo added a commit that referenced this pull request Dec 18, 2016
@bors-servo bors-servo Auto merge of #14312 - asajeffrey:script-discard-documents, r=<try>
Implement discarding Document objects to reclaim space.

<!-- Please describe your changes on the following line: -->

This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered.

Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit.

Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events.

To test this, I added a `-Zdiscard-inactive-documents` debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14262.
- [X] These changes do not require tests because we should be able to use the existing tests with `-Zdiscard-inactive-documents`.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14312)
<!-- Reviewable:end -->
938ab84
@asajeffrey
Member
asajeffrey commented Dec 18, 2016 edited

Hmm, I wouldn't call those tests successful... so switching off the GC in Window::clear_js_runtime causes:

  β–Ά TIMEOUT [expected PASS] /css-text-decor-3_dev/html/text-emphasis-style-property-010Cn.htm
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”‚ 3.3 (Core Profile) Mesa 12.0.1
  β”‚ assertion failed: glyphs[0] != 0 (thread LayoutThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }, at /Users/servo/buildbot/slave/mac-rel-css/build/components/gfx/platform/macos/font.rs:267)
  β”‚ stack backtrace:
  β”‚    0:        0x10da483ee - backtrace::backtrace::trace::he729cbd729f64e70
  β”‚    1:        0x10da486dc - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:        0x10d931454 - servo::main::_{{closure}}::h7a39b0613d7eb22d
  β”‚    3:        0x10f445053 - std::panicking::rust_panic_with_hook::ha5aed1dfc0e220e3
  β”‚    4:        0x10e65c5b4 - std::panicking::begin_panic::h5f0a1fd8f4de57ec
  β”‚    5:        0x10e67bc17 - _<gfx..platform..macos..font..FontHandle as gfx..font..FontHandleMethods>::glyph_index::hb477c7d1a722d02c
  β”‚    6:        0x10e639e0a - layout::text::TextRunScanner::scan_for_runs::h45b85dd37d7a27bb
  β”‚    7:        0x10dca5804 - _<layout..construct..FlowConstructor<'a, ConcreteThreadSafeLayoutNode>>::build_flow_for_block_starting_with_fragments::h35d92843a28d5968
  β”‚    8:        0x10dca287e - _<layout..construct..FlowConstructor<'a, ConcreteThreadSafeLayoutNode>>::build_flow_for_block_like::hd438f1c814cf25c0
  β”‚    9:        0x10dca1de4 - _<layout..construct..FlowConstructor<'a, ConcreteThreadSafeLayoutNode>>::build_flow_for_block::h1f218f6f80be8adc
  β”‚   10:        0x10dc4e21a - _<layout..construct..FlowConstructor<'a, ConcreteThreadSafeLayoutNode> as layout..traversal..PostorderNodeMutTraversal<ConcreteThreadSafeLayoutNode>>::process::hb490b0cc92eb23d8
  β”‚   11:        0x10dc3c2ad - _<layout..traversal..RecalcStyleAndConstructFlows as style..traversal..DomTraversal<N>>::process_postorder::h20fa1d293c552758
  β”‚   12:        0x10dc81670 - style::sequential::traverse_dom::doit::h2ae7c0238d86f98f
  β”‚   13:        0x10dc81650 - style::sequential::traverse_dom::doit::h2ae7c0238d86f98f
  β”‚   14:        0x10dc81650 - style::sequential::traverse_dom::doit::h2ae7c0238d86f98f
  β”‚   15:        0x10dcbffda - layout_thread::LayoutThread::handle_reflow::h7e37df945eab21a6
  β”‚   16:        0x10dcb9b13 - layout_thread::LayoutThread::handle_request_helper::h8d97870334705967
  β”‚   17:        0x10dcb583d - layout_thread::LayoutThread::handle_request::h15f88002b59c2ee3
  β”‚   18:        0x10dcafaba - _<layout_thread..LayoutThread as layout_traits..LayoutThreadFactory>::create::_{{closure}}::hb1dbde4a5862c30e
  β”‚   19:        0x10dc62687 - std::panicking::try::do_call::h0a2ab3d0f222855c
  β”‚   20:        0x10f445f2a - __rust_maybe_catch_panic
  β”‚   21:        0x10dc7ab14 - _<F as alloc..boxed..FnBox<A>>::call_box::h8240e0292a693dae
  β”‚   22:        0x10f443fd4 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  β”‚   23:     0x7fff97f2c059 - _pthread_body
  β”‚   24:     0x7fff97f2bfd6 - _pthread_start
  β”‚ ERROR:servo: assertion failed: glyphs[0] != 0
  β”‚ called `Result::unwrap()` on an `Err` value: "SendError(..)" (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }, at ../src/libcore/result.rs:837)
  β”‚ stack backtrace:
  β”‚    0:        0x10da483ee - backtrace::backtrace::trace::he729cbd729f64e70
  β”‚    1:        0x10da486dc - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:        0x10d931454 - servo::main::_{{closure}}::h7a39b0613d7eb22d
  β”‚    3:        0x10f445053 - std::panicking::rust_panic_with_hook::ha5aed1dfc0e220e3
  β”‚    4:        0x10f444f24 - std::panicking::begin_panic::hc066339e2fdc17d1
  β”‚    5:        0x10f444e42 - std::panicking::begin_panic_fmt::h5912b2d2df332044
  β”‚    6:        0x10f444da7 - rust_begin_unwind
  β”‚    7:        0x10f472c60 - core::panicking::panic_fmt::h561c5ee168a3d2cb
  β”‚    8:        0x10df17660 - core::result::unwrap_failed::h483129cba6fcb6b8
  β”‚    9:        0x10e1dae5e - script::dom::window::Window::force_reflow::h0f216dd4e54f5dd8
  β”‚   10:        0x10e24f28f - script::script_thread::ScriptThread::handle_event::h1665494f7d7b42b5
  β”‚   11:        0x10e21f8c2 - script::script_thread::ScriptThread::handle_msgs::h4227226015adfa7f
  β”‚   12:        0x10ddd80c7 - std::panicking::try::do_call::h577c97600ae39910
  β”‚   13:        0x10f445f2a - __rust_maybe_catch_panic
  β”‚   14:        0x10df40dd6 - _<F as alloc..boxed..FnBox<A>>::call_box::h0ee36894adbcadf8
  β”‚   15:        0x10f443fd4 - std::sys::imp::thread::Thread::new::thread_start::h8084b1107992ae5b
  β”‚   16:     0x7fff97f2c059 - _pthread_body
  β”‚   17:     0x7fff97f2bfd6 - _pthread_start
  β”” ERROR:servo: called `Result::unwrap()` on an `Err` value: "SendError(..)"

and some other errors that look unrelated.

@asajeffrey
Member

Wrote documentation around removing the forced GC. Gulp. @jdm is this still r=you?

@asajeffrey
Member

The try panic was #14378.

@asajeffrey
Member

Fixed the "non-scary" panic from #14312 (comment).

@cbrewster

I haven't had a chance to comb through this completely, but here are some initial comments. Looks very promising though!

- }
- }
- },
+ let traversal_info: HashMap<FrameId, Instant> = match direction {
@cbrewster
cbrewster Dec 22, 2016 Member

This will no longer return earlier in the cases where delta is greater than the jsh future/past

@asajeffrey
asajeffrey Dec 22, 2016 Member

Good point. Fixed, but at the cost of the use of collect, oh well.

- .chain(once(&frame.current)))
- .map(|state| state.pipeline_id)
- .collect();
+ .flat_map(|frame| frame.prev.iter().chain(frame.next.iter())
@cbrewster
cbrewster Dec 22, 2016 Member

Should this iter chain also include once(frame.pipeline_id)?

@asajeffrey
asajeffrey Dec 22, 2016 Member

It does, two lines later :)

@cbrewster
cbrewster Dec 22, 2016 Member

ahhh, didn't realize this was all inside flat_map... I was confused what frame was even referencing 2 lines below.

// Check if the currently focused pipeline is the pipeline being replaced
// (or a child of it). This has to be done here, before the current
// frame tree is modified below.
let update_focus_pipeline = self.focused_pipeline_in_tree(frame_id);
- let prev_pipeline_id = match self.frames.get_mut(&frame_id) {
+ let (prev_pipeline_id, next_pipeline_id, entry) = match self.frames.get_mut(&frame_id) {
@cbrewster
cbrewster Dec 22, 2016 Member

Could we have this match return the previous entry and the next entry instead of returning the pipelines? This will be needed in the future and you're already returning both next_pipeline_id and entry.

@asajeffrey
asajeffrey Dec 22, 2016 Member

Done. In fact I realized it's cleaner to pass in an entry rather than a timestamp.

@asajeffrey
asajeffrey Dec 22, 2016 Member

Ooops, I remembered why I was doing this! Frame::pipeline_id is a PIpelineId, but FrameState::pipeline_id is an Option<PipelineId>.

+ let prev_pipeline_id = frame.pipeline_id;
+ let mut entry = frame.current();
+
+ if instant > frame.instant {
@cbrewster
cbrewster Dec 22, 2016 Member

This is much cleaner! Hopefully there can never be a case where an Instant is passed that is not in the Frame history. I can't think of any cases where that could happen, but it would be pretty destructive if it did happen.

@asajeffrey
asajeffrey Dec 22, 2016 Member

I could put in a warn! at least.

@asajeffrey
asajeffrey Dec 22, 2016 Member

I added a debug_assert_eq!.

@asajeffrey
Member

Running the wpt test suite with max-session-history=0, there's a bunch of panics in /html/browsers/, which look like they've all got the same cause:

$ ./mach test-wpt --release --binary-arg=--max-session-history=0
...
β–Ά CRASH [expected TIMEOUT] /html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”‚ 3.3 (Core Profile) Mesa 12.0.1
  β”‚ ERROR:script::dom::bindings::error: Error at http://www1.web-platform.test:8000/html/browsers/windows/support-nested-browsing-contexts.html:6:3 window.opener is undefined
  β”‚ ScriptThread: received fire timer msg for a pipeline not in this script thread. This is a bug. (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }, at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:715)
  β”‚ stack backtrace:
  β”‚    0:     0x5613a324607d - backtrace::backtrace::trace::h4f27741ec31c8869
  β”‚    1:     0x5613a3246702 - backtrace::capture::Backtrace::new::h3416c1b891724916
  β”‚    2:     0x5613a2fe183d - servo::main::_{{closure}}::h7416ee08d66cedf8
  β”‚    3:     0x5613a4e95704 - std::panicking::rust_panic_with_hook
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:554
  β”‚    4:     0x5613a4e955c4 - std::panicking::begin_panic<collections::string::String>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:515
  β”‚    5:     0x5613a4e954e9 - std::panicking::begin_panic_fmt
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:499
  β”‚    6:     0x5613a4e95477 - std::panicking::rust_begin_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:475
  β”‚    7:     0x5613a4ec292d - core::panicking::panic_fmt
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/panicking.rs:69
  β”‚    8:     0x5613a4ec299d - core::option::expect_failed
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:715
  β”‚    9:     0x5613a39721f9 - script::script_thread::ScriptThread::handle_msgs::_{{closure}}::h6937e7da41f554d9
  β”‚   10:     0x5613a396cd00 - script::script_thread::ScriptThread::handle_msgs::h8e7499af91698914
  β”‚   11:     0x5613a360d987 - std::panicking::try::do_call::hfe4efc1dec3985bf
  β”‚   12:     0x5613a4e9c64a - panic_unwind::__rust_maybe_catch_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  β”‚   13:     0x5613a3676ed4 - _<F as alloc..boxed..FnBox<A>>::call_box::h1e71131e9049eb89
  β”‚   14:     0x5613a4e94384 - alloc::boxed::{{impl}}::call_once<(),()>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:615
  β”‚                          - std::sys_common::thread::start_thread
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
  β”‚                          - std::sys::imp::thread::{{impl}}::new::thread_start
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  β”‚   15:     0x7f5d83ac86b9 - start_thread
  β”‚   16:     0x7f5d835e882c - clone
  β”‚   17:                0x0 - <unknown>
  β”‚ ERROR:servo: ScriptThread: received fire timer msg for a pipeline not in this script thread. This is a bug.
  β”” Pipeline failed in hard-fail mode.  Crashing!

The problem is that when a document is reloaded, the constellation knows about the pipeline before the script thread does, so we can end up with the script thread being sent messages for a pipeline it's never heard of.

@asajeffrey
Member

This is related to #14666, the current code in this PR traverses immediately, even if the document needs to be reloaded. Oops.

@bors-servo
Contributor

β˜”οΈ The latest upstream changes (presumably #14679) made this pull request unmergeable. Please resolve the merge conflicts.

@asajeffrey
Member

Rebased.

@bors-servo
Contributor

β˜”οΈ The latest upstream changes (presumably #14698) made this pull request unmergeable. Please resolve the merge conflicts.

@cbrewster cbrewster referenced this pull request Dec 25, 2016
Closed

Keep same timestamp when replacing frame state #14664

2 of 5 tasks complete
@cbrewster

Looks mostly good, I had a couple questions. Other than that LGTM.

components/config/opts.rs
@@ -518,6 +521,7 @@ pub fn default_opts() -> Opts {
userscripts: None,
user_stylesheets: Vec::new(),
output_file: None,
+ max_session_history: 256,
@cbrewster
cbrewster Jan 3, 2017 Member

Out of curiosity, is there a reason the default is 256? That seems a bit large to me

@asajeffrey
asajeffrey Jan 4, 2017 Member

Number rather chosen at random. I'm not sure how to make a rational choice for this number, especially since the choice is probably very dependent on hardware: the main resource I expect we're saving is swap space (since frozen threads don't have timers so shouldn't be swapping themselves back in) which is very different, e.g. on a phone vs a PC.

struct FrameState {
+ // The timestamp for when this session history entry was created
@cbrewster
cbrewster Jan 3, 2017 Member

nit: Could we make these doc comments?

+ // URL instead. When the document has activated, it will
+ // traverse to the entry, but with the new pipeline id.
+ debug!("Reloading document {} for frame {}.", entry.url, frame_id);
+ // TODO: referrer?
@cbrewster
cbrewster Jan 3, 2017 Member

Should we store LoadData in the FrameState/Frame instead of the just ServoUrl?

@asajeffrey
asajeffrey Jan 4, 2017 Member

That is an interesting point. Step 1 of https://html.spec.whatwg.org/multipage/browsers.html#history-traversal just refers to the URL of the entry, not anything else, though the note does imply we should at least store the HTTP method. We may also want to store persisted user state, e.g. the scroll position as per https://html.spec.whatwg.org/multipage/browsers.html#an-entry-with-persisted-user-state. (cc @paulrouget because this is relevant to the discussions around load data in the embedding API).

Not sure what we should do right now, just do a URL right now and file an issue?

+ } else if let Some(frame) = self.frames.get_mut(&frame_change.frame_id) {
+ debug!("Adding pipeline to existing frame.");
+ frame.load(frame_change.new_pipeline_id, frame_change.url.clone());
+ let evicted_id = frame.prev.get_mut(opts::get().max_session_history)
@cbrewster
cbrewster Jan 3, 2017 Member

Do we want to handle discarding Documents in future as well?

@asajeffrey
asajeffrey Jan 4, 2017 Member

At the moment I'm just handling discarding the past, since the future is discarded whenever navigation happens, so you really have to go out of your way to build up significant session future.

@@ -228,18 +228,18 @@ impl OneshotTimers {
}
pub fn suspend(&self) {
- assert!(self.suspended_since.get().is_none());
+ // Suspend is idempotent: do nothing if the timers are already suspended.
@cbrewster
cbrewster Jan 3, 2017 Member

While I think making freeze/thaw/suspend idempotent isn't a bad idea, I think it can let some issues fall through the cracks. For example #13716 is caused by a some Pipelines not being frozen when navigated from. We would have no idea that this was happening if suspend was idempotent. At a minimum, it might be nice to add a warn! when returning early here and in resume

@asajeffrey
asajeffrey Jan 4, 2017 Member

Added warnings.

@jdm

Sorry about the long delay; I was surprised by the fact that all of the discarding code was moved out of script and into constellation and it took me a while to understand the new model.

components/config/opts.rs
@@ -791,6 +784,10 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
}
};
+ let max_session_history = opt_match.opt_str("max-session-history").map(|max| {
+ max.parse().unwrap_or_else(|err| args_fail(&format!("Error parsing option: --max-session-history ({})", err)))
+ }).unwrap_or(256);
@jdm
jdm Jan 3, 2017 Member

This feels like it might be better as a preference, rather than a command-line switch.

@asajeffrey
asajeffrey Jan 4, 2017 Member

Do we have a way to set a numeric preference from the command line? AFAICT we can only set strings and booleans. We use the command line for running the wpt suite with --binary-arg=--max-session-history=N.

@jdm
jdm Jan 4, 2017 Member

You're right; we should definitely add that ability.

@asajeffrey
asajeffrey Jan 4, 2017 Member

For the moment, I'm going to leave this alone then.

+ // The pipeline id of the current active document
+ pipeline_id: PipelineId,
+ // The timestamp for the current session history entry
+ instant: Instant,
@jdm
jdm Jan 3, 2017 Member

This name seems like it could be more descriptive.

@asajeffrey
asajeffrey Jan 4, 2017 Member

I chose it to match FrameState. Rename both to timestamp?

+ .filter_map(|entry| entry.pipeline_id)
+ .chain(once(frame.pipeline_id))
+ .filter_map(|pipeline_id| pipelines.get(&pipeline_id))
+ .flat_map(|pipeline| pipeline.children.iter());
@jdm
jdm Jan 3, 2017 Member

I wonder if it would be more readable to put this in a standalone helper named all_child_frames_of_frame. I have to think about what this is collecting every time I read it.

@asajeffrey
asajeffrey Jan 4, 2017 Member

The issue with doing this is that we can't make the return type of the helper function impl Iterator<Item=FrameId> because of lifetime issues:

error[E0564]: only named lifetimes are allowed in `impl Trait`, but `` was found in the type `std::iter::Cloned<std::iter::FlatMap<std::iter::FilterMap<std::iter::Chain<std::iter::FilterMap<std::iter::Chain<std::slice::Iter<'_, frame::FrameState>, std::slice::Iter<'_, frame::FrameState>>, [closure@/home/ajeffrey/github/asajeffrey/servo/components/constellation/frame.rs:209:25: 209:50]>, std::iter::Once<msg::constellation_msg::PipelineId>>, [closure@/home/ajeffrey/github/asajeffrey/servo/components/constellation/frame.rs:211:25: 211:71 self:&&frame::FullFrameTreeIterator<'a>]>, std::slice::Iter<'_, msg::constellation_msg::FrameId>, [closure@/home/ajeffrey/github/asajeffrey/servo/components/constellation/frame.rs:212:23: 212:58]>>`
- },
- None => return warn!("invalid traversal delta"),
- }
+ for entry in self.joint_session_past(top_level_frame_id).take(delta) {
@jdm
jdm Jan 3, 2017 Member

It's tempting to suggest:

let (joint_session, delta) = match direction {
    TraversalDirection::Forward(delta) => (Constellation::joint_session_future, delta),
    TraversalDirection::Back(delta) => (Constellation::join_session_past, delta),
};

for entry in joint_session(self, top_level_frame_id).take(delta) {
@asajeffrey
asajeffrey Jan 4, 2017 Member

An extra pointer indirection at runtime and possibly some lost inlining, but the code would be cleaner.

+ let (old_pipeline_id, parent_info, window_size, is_private) = match self.frames.get(&frame_id) {
+ Some(frame) => match self.pipelines.get(&frame.pipeline_id) {
+ Some(pipeline) => (frame.pipeline_id, pipeline.parent_info, pipeline.size, pipeline.is_private),
+ None => (frame.pipeline_id, None, None, false),
@jdm
jdm Jan 3, 2017 Member

I'm not sure I follow when this case can occur.

@asajeffrey
asajeffrey Jan 4, 2017 Member

Possibly it can't, you'd need a frame who's current pipeline has been closed. Really, all this information should be stored in the frame, not in the pipeline (#14692), which would get rid of this silly case.

components/script/dom/window.rs
+ pub fn freeze(&self) {
+ self.upcast::<GlobalScope>().suspend();
+ // A hint to the JS runtime that now would be a good time to GC this window.
+ self.Gc();
@jdm
jdm Jan 3, 2017 Member

This window will not be GCed because it is being accessed by a root that will prevent it being GCed. I'm not sure that this hint makes sense here.

@asajeffrey
asajeffrey Jan 4, 2017 Member

We are GCing user script data and unattached DOM nodes here. Attached DOM nodes can't be reclaimed.

@jdm
jdm Jan 4, 2017 Member

I guess I read "GC this window" as "GC this particular window object."

@asajeffrey
asajeffrey Jan 4, 2017 Member

Good point, the comment isn't as clear as it could be. I'll fix that.

@asajeffrey asajeffrey Implement discarding Document objects to reclaim space.
78c87ea
@asajeffrey
Member

Rebased. Now to address review comments...

@asajeffrey asajeffrey Added warnings for idempotent freeze/thaw.
67bf230
@asajeffrey
Member

@jdm: yes, the rewrite from the GC-based version to the constellation-based version was quite drastic!

asajeffrey added some commits Jan 4, 2017
@asajeffrey asajeffrey Updated comment.
ef50a64
@asajeffrey asajeffrey Pass test-tidy.
1a201fc
@asajeffrey
Member

Some panics, one of which manages to not have a stack trace!

$ ./mach test-wpt --release --binary-arg=--max-session-history=0 /html/browsers
Running 209 tests in web-platform-tests

  β–Ά CRASH [expected OK] /html/browsers/origin/cross-origin-objects/cross-origin-objects-exceptions.html
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”‚ 3.3 (Core Profile) Mesa 12.0.1
  β”‚ called `Option::unwrap()` on a `None` value (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }, at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:323)
  β”‚ stack backtrace:
  β”‚    0:     0x55a6c81ec81d - backtrace::backtrace::trace::he26d3ea809136443
  β”‚    1:     0x55a6c81ecee2 - backtrace::capture::Backtrace::new::hd6fb6e83f9059b0d
  β”‚    2:     0x55a6c80383dd - servo::main::{{closure}}::hbd42942b97f42442
  β”‚    3:     0x55a6c9edb474 - std::panicking::rust_panic_with_hook
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:556
  β”‚    4:     0x55a6c9edb2e4 - std::panicking::begin_panic<collections::string::String>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:517
  β”‚    5:     0x55a6c9edb259 - std::panicking::begin_panic_fmt
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:501
  β”‚    6:     0x55a6c9edb1e7 - std::panicking::rust_begin_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:477
  β”‚    7:     0x55a6c9f086bd - core::panicking::panic_fmt
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/panicking.rs:69
  β”‚    8:     0x55a6c9f085f4 - core::panicking::panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/panicking.rs:49
  β”‚    9:     0x55a6c8878db7 - script::dom::window::Window::parent::he82afbcdf61edf0b
  β”‚   10:     0x55a6c886edca - <script::dom::window::Window as script::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods>::Parent::hbb1fb491e0211590
  β”‚   11:     0x55a6c847b9b5 - std::panicking::try::do_call::h8039daef51ee6ea0
  β”‚   12:     0x55a6c9ee23da - panic_unwind::__rust_maybe_catch_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  β”‚   13:     0x55a6c8b5ab8b - script::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::get_parent::h201aae1df57f42a2
  β”‚   14:     0x55a6c94fa6e4 - CallJitGetterOp
  β”‚   15:     0x55a6c8668e24 - script::dom::bindings::utils::generic_call::h89379b22f6121940
  β”‚   16:     0x55a6c98a49d3 - 2js12CallJSNativeEP9JSContextPFbS1_jPN2JS5ValueEERKNS2_8CallArgs
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jscntxtinlines.h:232
  β”‚                          - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:453
  β”‚   17:     0x55a6c98a4c67 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:517
  β”‚   18:     0x55a6c98a4d2c - 2js10CallGetterEP9JSContextN2JS6HandleINS2_5ValueEEES5_NS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:631
  β”‚   19:     0x55a6c98a4e16 - CallGetter
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:1737
  β”‚   20:     0x55a6c98a5189 - GetExistingProperty<(js::AllowGC)1u>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:1785
  β”‚                          - NativeGetPropertyInline<(js::AllowGC)1u>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:2012
  β”‚                          - 2js17NativeGetPropertyEP9JSContextN2JS6HandleIPNS_12NativeObjectEEENS3_INS2_5ValueEEENS3_I4jsidEENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:2046
  β”‚   21:     0x55a6c96f5da4 - 2js11GetPropertyEP9JSContextN2JS6HandleIP8JSObjectEENS3_INS2_5ValueEEENS3_I4jsidEENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.h:1481
  β”‚                          - _Z23JS_ForwardGetPropertyToP9JSContextN2JS6HandleIP8JSObjectEENS2_I4jsidEENS2_INS1_5ValueEEENS1_13MutableHandleIS8_EE
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsapi.cpp:2527
  β”‚   22:     0x55a6c869591f - script::dom::browsingcontext::get::hf43a7c8b0d7ddbba
  β”‚   23:     0x55a6c97f777a - 2js5Proxy3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/Proxy.cpp:310
  β”‚   24:     0x55a6c97f1990 - 2js11GetPropertyEP9JSContextN2JS6HandleIP8JSObjectEENS3_INS2_5ValueEEENS3_I4jsidEENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.h:1480
  β”‚                          - K2js7Wrapper3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/Wrapper.cpp:143
  β”‚   25:     0x55a6c97ee0d7 - K2js23CrossCompartmentWrapper3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/CrossCompartmentWrapper.cpp:205
  β”‚   26:     0x55a6c97f777a - 2js5Proxy3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/Proxy.cpp:310
  β”‚   27:     0x55a6c98a5771 - 2js11GetPropertyEP9JSContextN2JS6HandleIP8JSObjectEENS3_INS2_5ValueEEEPNS_12PropertyNameENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsobj.h:831
  β”‚                          - 2js11GetPropertyEP9JSContextN2JS6HandleINS2_5ValueEEENS3_IPNS_12PropertyNameEEENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:4161
  β”‚   28:     0x55a6c9897e68 - GetPropertyOperation
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:189
  β”‚                          - Interpret
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:2590
  β”‚   29:     0x55a6c98a46df - 2js9RunScriptEP9JSContextRNS_8RunState
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:399
  β”‚   30:     0x55a6c98a4902 - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:471
  β”‚   31:     0x55a6c98a4c67 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:517
  β”‚   32:     0x55a6c9790445 - 2js9fun_applyEP9JSContextjPN2JS5Value
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsfun.cpp:1325
  β”‚   33:     0x55a6c98a49d3 - 2js12CallJSNativeEP9JSContextPFbS1_jPN2JS5ValueEERKNS2_8CallArgs
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jscntxtinlines.h:232
  β”‚                          - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:453
  β”‚   34:     0x55a6c989f70c - 2js13CallFromStackEP9JSContextRKN2JS8CallArgs
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:504
  β”‚                          - Interpret
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:2873
  β”‚   35:     0x55a6c98a46df - 2js9RunScriptEP9JSContextRNS_8RunState
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:399
  β”‚   36:     0x55a6c98a4902 - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:471
  β”‚   37:     0x55a6c98a4c67 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:517
  β”‚   38:     0x55a6c972513c - _Z20JS_CallFunctionValueP9JSContextN2JS6HandleIP8JSObjectEENS2_INS1_5ValueEEERKNS1_16HandleValueArrayENS1_13MutableHandleIS6_EE
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsapi.cpp:2781
  β”‚   39:     0x55a6c89e405a - script::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull::Call::hdb60c8ea2d328567
  β”‚   40:     0x55a6c89e3cf5 - script::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull::Call_::hcf51d2f4a280196c
  β”‚   41:     0x55a6c8715119 - script::dom::eventdispatcher::handle_event::h36f70ce07609b3bc
  β”‚   42:     0x55a6c8717a46 - script::dom::eventdispatcher::invoke::h24e26b6baf14e26f
  β”‚   43:     0x55a6c8716c7d - script::dom::eventdispatcher::dispatch_event::h71a44d3ce49b4545
  β”‚   44:     0x55a6c872145f - script::dom::eventtarget::EventTarget::fire_event_with_params::hb3d816feeacbaab8
  β”‚   45:     0x55a6c876bf11 - script::dom::htmliframeelement::HTMLIFrameElement::iframe_load_event_steps::h946d99d0890b7cb3
  β”‚   46:     0x55a6c88c279c - script::script_thread::ScriptThread::handle_msg_from_constellation::h9d514135546e715d
  β”‚   47:     0x55a6c88c02c1 - script::script_thread::ScriptThread::handle_msgs::{{closure}}::h513f36a45af2d994
  β”‚   48:     0x55a6c88bb002 - script::script_thread::ScriptThread::handle_msgs::h725f01291923d8f5
  β”‚   49:     0x55a6c853ab97 - std::panicking::try::do_call::hfaef61911c06fae2
  β”‚   50:     0x55a6c9ee23da - panic_unwind::__rust_maybe_catch_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  β”‚   51:     0x55a6c85ab107 - <F as alloc::boxed::FnBox<A>>::call_box::hff64fe533e2cc3e1
  β”‚   52:     0x55a6c9eda114 - alloc::boxed::{{impl}}::call_once<(),()>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:615
  β”‚                          - std::sys_common::thread::start_thread
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
  β”‚                          - std::sys::imp::thread::{{impl}}::new::thread_start
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  β”‚   53:     0x7f7786706709 - start_thread
  β”‚   54:     0x7f77862290ae - __clone
  β”‚   55:                0x0 - <unknown>
  β”‚ ERROR:servo: called `Option::unwrap()` on a `None` value
  β”” Pipeline failed in hard-fail mode.  Crashing!

  β–Ά CRASH [expected OK] /html/browsers/windows/noreferrer.html
  β”‚ 
  β”‚ VMware, Inc.
  β”‚ Gallium 0.4 on softpipe
  β”” 3.3 (Core Profile) Mesa 12.0.1

Ran 209 tests finished in 242.0 seconds.
  β€’ 207 ran as expected. 37 tests skipped.
  β€’ 2 tests crashed unexpectedly
@asajeffrey
Member

And in debug mode, showing how impressively deep in the weeds this crash is:

$ ./mach test-wpt --debug-build --binary-arg=--max-session-history=0 /html/browsers/origin/cross-origin-objects/cross-origin-objects-exceptions.html
Running 1 tests in web-platform-tests

  β–Ά CRASH [expected OK] /html/browsers/origin/cross-origin-objects/cross-origin-objects-exceptions.html
  β”‚ 
  β”‚ called `Option::unwrap()` on a `None` value (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(0), index: PipelineIndex(1) }, at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:323)
  β”‚ stack backtrace:
  β”‚    0:     0x55c8a03b3331 - backtrace::backtrace::libunwind::trace
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.2.3/src/backtrace/mod.rs:82
  β”‚                          - backtrace::backtrace::trace<closure>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.2.3/src/backtrace/mod.rs:70
  β”‚    1:     0x55c8a03b41b8 - backtrace::capture::{{impl}}::new
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.2.3/src/lib.rs:96
  β”‚    2:     0x55c89fbcd06c - servo::main::{{closure}}
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/ports/servo/main.rs:122
  β”‚    3:     0x55c8a5284fe4 - std::panicking::rust_panic_with_hook
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:556
  β”‚    4:     0x55c8a5284e54 - std::panicking::begin_panic<collections::string::String>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:517
  β”‚    5:     0x55c8a5284dc9 - std::panicking::begin_panic_fmt
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:501
  β”‚    6:     0x55c8a5284d57 - std::panicking::rust_begin_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:477
  β”‚    7:     0x55c8a52b226d - core::panicking::panic_fmt
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/panicking.rs:69
  β”‚    8:     0x55c8a52b21a4 - core::panicking::panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/panicking.rs:49
  β”‚    9:     0x55c8a0f76986 - core::option::{{impl}}::unwrap<script::dom::bindings::js::Root<script::dom::browsingcontext::BrowsingContext>>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/macros.rs:21
  β”‚   10:     0x55c8a20507a1 - script::dom::window::{{impl}}::browsing_context
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/window.rs:302
  β”‚   11:     0x55c8a205c9a4 - script::dom::window::{{impl}}::parent
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/window.rs:1518
  β”‚   12:     0x55c8a20529fa - script::dom::window::{{impl}}::Parent
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/window.rs:555
  β”‚   13:     0x55c8a26f6c39 - script::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::get_parent::{{closure}}
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/bindings/mod.rs:164
  β”‚   14:     0x55c8a27fbdf8 - core::ops::FnOnce::call_once::h7e8f5975e316428e
  β”‚   15:     0x55c8a1ca5bda - std::panic::{{impl}}::call_once<bool,closure>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panic.rs:296
  β”‚   16:     0x55c8a147775c - std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,bool>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:460
  β”‚   17:     0x55c8a528bf4a - panic_unwind::__rust_maybe_catch_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  β”‚   18:     0x55c8a11c7da4 - std::panicking::try<bool,std::panic::AssertUnwindSafe<closure>>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:436
  β”‚   19:     0x55c8a107cd99 - std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,bool>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panic.rs:361
  β”‚   20:     0x55c8a0a982dd - js::panic::wrap_panic<std::panic::AssertUnwindSafe<closure>,bool>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/rust-mozjs-8611526964119dd6/15ff1e8/src/panic.rs:22
  β”‚   21:     0x55c8a26f6bf1 - script::dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::get_parent
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/bindings/mod.rs:164
  β”‚   22:     0x55c8a44d5486 - CallJitGetterOp
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/rust-mozjs-8611526964119dd6/15ff1e8/src/jsglue.cpp:454
  β”‚   23:     0x55c8a1e370fa - script::dom::bindings::utils::generic_call
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/bindings/utils.rs:446
  β”‚   24:     0x55c8a1e372a1 - script::dom::bindings::utils::generic_getter
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/bindings/utils.rs:462
  β”‚   25:     0x55c8a4880c43 - 2js12CallJSNativeEP9JSContextPFbS1_jPN2JS5ValueEERKNS2_8CallArgs
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jscntxtinlines.h:232
  β”‚                          - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:453
  β”‚   26:     0x55c8a4880ed7 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:517
  β”‚   27:     0x55c8a4880f9c - 2js10CallGetterEP9JSContextN2JS6HandleINS2_5ValueEEES5_NS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:631
  β”‚   28:     0x55c8a4881086 - CallGetter
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:1737
  β”‚   29:     0x55c8a48813f9 - GetExistingProperty<(js::AllowGC)1u>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:1785
  β”‚                          - NativeGetPropertyInline<(js::AllowGC)1u>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:2012
  β”‚                          - 2js17NativeGetPropertyEP9JSContextN2JS6HandleIPNS_12NativeObjectEEENS3_INS2_5ValueEEENS3_I4jsidEENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.cpp:2046
  β”‚   30:     0x55c8a46d21a4 - 2js11GetPropertyEP9JSContextN2JS6HandleIP8JSObjectEENS3_INS2_5ValueEEENS3_I4jsidEENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.h:1481
  β”‚                          - _Z23JS_ForwardGetPropertyToP9JSContextN2JS6HandleIP8JSObjectEENS2_I4jsidEENS2_INS1_5ValueEEENS1_13MutableHandleIS8_EE
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsapi.cpp:2527
  β”‚   31:     0x55c8a1e601ee - script::dom::browsingcontext::get
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/browsingcontext.rs:230
  β”‚   32:     0x55c8a44d3f54 - K19WrapperProxyHandler3getEP9JSContextN2JS6HandleIP8JSObjectEENS3_INS2_5ValueEEENS3_I4jsidEENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/rust-mozjs-8611526964119dd6/15ff1e8/src/jsglue.cpp:272
  β”‚   33:     0x55c8a47d3aea - 2js5Proxy3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/Proxy.cpp:310
  β”‚   34:     0x55c8a47cdd00 - 2js11GetPropertyEP9JSContextN2JS6HandleIP8JSObjectEENS3_INS2_5ValueEEENS3_I4jsidEENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/NativeObject.h:1480
  β”‚                          - K2js7Wrapper3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/Wrapper.cpp:143
  β”‚   35:     0x55c8a47ca447 - K2js23CrossCompartmentWrapper3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/CrossCompartmentWrapper.cpp:205
  β”‚   36:     0x55c8a47d3aea - 2js5Proxy3getEP9JSContextN2JS6HandleIP8JSObjectEENS4_INS3_5ValueEEENS4_I4jsidEENS3_13MutableHandleIS8_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/proxy/Proxy.cpp:310
  β”‚   37:     0x55c8a48819e1 - 2js11GetPropertyEP9JSContextN2JS6HandleIP8JSObjectEENS3_INS2_5ValueEEEPNS_12PropertyNameENS2_13MutableHandleIS7_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsobj.h:831
  β”‚                          - 2js11GetPropertyEP9JSContextN2JS6HandleINS2_5ValueEEENS3_IPNS_12PropertyNameEEENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:4161
  β”‚   38:     0x55c8a48740d8 - GetPropertyOperation
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:189
  β”‚                          - Interpret
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:2590
  β”‚   39:     0x55c8a488094f - 2js9RunScriptEP9JSContextRNS_8RunState
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:399
  β”‚   40:     0x55c8a4880b72 - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:471
  β”‚   41:     0x55c8a4880ed7 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:517
  β”‚   42:     0x55c8a476c7b5 - 2js9fun_applyEP9JSContextjPN2JS5Value
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsfun.cpp:1325
  β”‚   43:     0x55c8a4880c43 - 2js12CallJSNativeEP9JSContextPFbS1_jPN2JS5ValueEERKNS2_8CallArgs
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jscntxtinlines.h:232
  β”‚                          - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:453
  β”‚   44:     0x55c8a487b97c - 2js13CallFromStackEP9JSContextRKN2JS8CallArgs
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:504
  β”‚                          - Interpret
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:2873
  β”‚   45:     0x55c8a488094f - 2js9RunScriptEP9JSContextRNS_8RunState
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:399
  β”‚   46:     0x55c8a4880b72 - 2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstruct
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:471
  β”‚   47:     0x55c8a4880ed7 - 2js4CallEP9JSContextN2JS6HandleINS2_5ValueEEES5_RKNS_13AnyInvokeArgsENS2_13MutableHandleIS4_E
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/vm/Interpreter.cpp:517
  β”‚   48:     0x55c8a470153c - _Z20JS_CallFunctionValueP9JSContextN2JS6HandleIP8JSObjectEENS2_INS1_5ValueEEERKNS1_16HandleValueArrayENS1_13MutableHandleIS6_EE
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/f7917c4/mozjs/js/src/jsapi.cpp:2781
  β”‚   49:     0x55c8a236d3d9 - script::dom::bindings::codegen::Bindings::EventHandlerBinding::{{impl}}::Call
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/bindings/mod.rs:164
  β”‚   50:     0x55c8a236cad7 - script::dom::bindings::codegen::Bindings::EventHandlerBinding::{{impl}}::Call_<script::dom::eventtarget::EventTarget>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/bindings/mod.rs:164
  β”‚   51:     0x55c8a1ef2c98 - script::dom::eventtarget::{{impl}}::call_or_handle_event<script::dom::eventtarget::EventTarget>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventtarget.rs:203
  β”‚   52:     0x55c8a1eea064 - script::dom::eventdispatcher::handle_event
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventdispatcher.rs:45
  β”‚   53:     0x55c8a1eebab2 - script::dom::eventdispatcher::inner_invoke
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventdispatcher.rs:213
  β”‚   54:     0x55c8a1eeb949 - script::dom::eventdispatcher::invoke
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventdispatcher.rs:188
  β”‚   55:     0x55c8a1eea5d0 - script::dom::eventdispatcher::dispatch_to_listeners
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventdispatcher.rs:82
  β”‚   56:     0x55c8a1eeb320 - script::dom::eventdispatcher::dispatch_event
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventdispatcher.rs:156
  β”‚   57:     0x55c8a1ef3b58 - script::dom::eventtarget::{{impl}}::dispatch_event
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventtarget.rs:307
  β”‚   58:     0x55c8a1ee9ada - script::dom::event::{{impl}}::fire
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/event.rs:316
  β”‚   59:     0x55c8a1ef68c1 - script::dom::eventtarget::{{impl}}::fire_event_with_params
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventtarget.rs:529
  β”‚   60:     0x55c8a1ef6607 - script::dom::eventtarget::{{impl}}::fire_event
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/eventtarget.rs:496
  β”‚   61:     0x55c8a1f3ac0d - script::dom::htmliframeelement::{{impl}}::iframe_load_event_steps
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/dom/htmliframeelement.rs:308
  β”‚   62:     0x55c8a20b2c47 - script::script_thread::{{impl}}::handle_frame_load_event
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:1684
  β”‚   63:     0x55c8a20a14bb - script::script_thread::{{impl}}::handle_msg_from_constellation
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:1001
  β”‚   64:     0x55c8a209eedd - script::script_thread::{{impl}}::handle_msgs::{{closure}}
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:861
  β”‚   65:     0x55c8a209fc87 - script::script_thread::{{impl}}::profile_event<closure,core::option::Option<bool>>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:955
  β”‚   66:     0x55c8a209d2e9 - script::script_thread::{{impl}}::handle_msgs
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:855
  β”‚   67:     0x55c8a209b76e - script::script_thread::{{impl}}::start
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:713
  β”‚   68:     0x55c8a2097844 - script::script_thread::{{impl}}::create::{{closure}}::{{closure}}
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:551
  β”‚   69:     0x55c8a0957f15 - profile_traits::mem::{{impl}}::run_with_memory_reporting<closure,fn(profile_traits::mem::ReportsChan) -> script::script_runtime::CommonScriptMsg,script::script_runtime::CommonScriptMsg,std::sync::mpsc::Sender<script::script_thread::MainThreadScriptMsg>>
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/profile_traits/mem.rs:63
  β”‚   70:     0x55c8a2097f19 - script::script_thread::{{impl}}::create::{{closure}}
  β”‚                         at /home/ajeffrey/github/asajeffrey/servo/components/script/script_thread.rs:550
  β”‚   71:     0x55c8a1c6e3fa - std::panic::{{impl}}::call_once<(),closure>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panic.rs:296
  β”‚   72:     0x55c8a13fd1e8 - std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:460
  β”‚   73:     0x55c8a528bf4a - panic_unwind::__rust_maybe_catch_panic
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  β”‚   74:     0x55c8a12eae41 - std::panicking::try<(),std::panic::AssertUnwindSafe<closure>>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:436
  β”‚   75:     0x55c8a100ebc4 - std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panic.rs:361
  β”‚   76:     0x55c8a108c5fc - std::thread::{{impl}}::spawn::{{closure}}<closure,()>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/thread/mod.rs:302
  β”‚   77:     0x55c8a199fca9 - alloc::boxed::{{impl}}::call_box<(),closure>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:605
  β”‚   78:     0x55c8a5283c64 - alloc::boxed::{{impl}}::call_once<(),()>
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/liballoc/boxed.rs:615
  β”‚                          - std::sys_common::thread::start_thread
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
  β”‚                          - std::sys::imp::thread::{{impl}}::new::thread_start
  β”‚                         at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  β”‚   79:     0x7fa67aafd709 - start_thread
  β”‚   80:     0x7fa67a6200ae - __clone
  β”‚   81:                0x0 - <unknown>
  β”‚ ERROR:servo: called `Option::unwrap()` on a `None` value
  β”” Pipeline failed in hard-fail mode.  Crashing!

Ran 1 tests finished in 12.0 seconds.
  β€’ 0 ran as expected. 0 tests skipped.
  β€’ 1 tests crashed unexpectedly
@asajeffrey
Member

An IRC conversation with @jdm, @Ms2ger and @cbrewster: http://logs.glob.uno/?c=mozilla%23servo&s=4+Jan+2017&e=4+Jan+2017#c586779

TL;DR: this crash is probably caused by us not doing the window proxy to window mapping quite right, since we are generating a new BrowsingContext object for every Window.

@asajeffrey asajeffrey Default --max-session-history is now 16.
c14c431
@asajeffrey
Member
@bors-servo
Contributor

βŒ›οΈ Trying commit c14c431 with merge 9673fcb...

@bors-servo bors-servo added a commit that referenced this pull request Jan 4, 2017
@bors-servo bors-servo Auto merge of #14312 - asajeffrey:script-discard-documents, r=<try>
Implement discarding Document objects to reclaim space.

<!-- Please describe your changes on the following line: -->

This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered.

Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit.

Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events.

To test this, I added a `-Zdiscard-inactive-documents` debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14262.
- [X] These changes do not require tests because we should be able to use the existing tests with `-Zdiscard-inactive-documents`.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14312)
<!-- Reviewable:end -->
9673fcb
@jdm
Member
jdm commented Jan 4, 2017

This is ready to merge from my point of view.

@asajeffrey
Member

@bors-servo r=cbrewster cross fingers

@bors-servo
Contributor

πŸ“Œ Commit c14c431 has been approved by cbrewster

@highfive highfive assigned cbrewster and unassigned jdm Jan 4, 2017
@cbrewster
Member

@bors-servo retry

@bors-servo
Contributor

βŒ›οΈ Testing commit c14c431 with merge 16b0da5...

@bors-servo bors-servo added a commit that referenced this pull request Jan 4, 2017
@bors-servo bors-servo Auto merge of #14312 - asajeffrey:script-discard-documents, r=cbrewster
Implement discarding Document objects to reclaim space.

<!-- Please describe your changes on the following line: -->

This PR implements document discarding. Active documents are kept alive strongly, but inactive documents are only kept alive weakly. When a document is GCd, it is marked as discarded, and if it is every reactivated, a reload of the URL is triggered.

Note that this PR is pretty aggressive about discarding, and can any inactive document (other than those being kept alive by other same-origin pipelines). We might want to damp it down a bit.

Also note that this interacts with browser.html in that the reloading triggered by reactivating a document triggers mozbrowser events.

To test this, I added a `-Zdiscard-inactive-documents` debug flag, which discards all inactive documents, even ones which are reachable through other same-origin pipelines.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14262.
- [X] These changes do not require tests because we should be able to use the existing tests with `-Zdiscard-inactive-documents`.

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14312)
<!-- Reviewable:end -->
16b0da5
@bors-servo bors-servo merged commit c14c431 into servo:master Jan 4, 2017

1 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor was unable to build non-mergeable pull request
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
homu Test successful
Details
@bors-servo bors-servo added a commit that referenced this pull request Jan 5, 2017
@bors-servo bors-servo Auto merge of #14860 - asajeffrey:constellation-index-past-correctly-…
…when-discarding, r=cbrewster

Index the session past correctly when discarding.

<!-- Please describe your changes on the following line: -->

Oops, indexed from the wrong end when discarding documents in #14312.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because we're not testing document discarding

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14860)
<!-- Reviewable:end -->
390985a
@bors-servo bors-servo added a commit that referenced this pull request Jan 5, 2017
@bors-servo bors-servo Auto merge of #14860 - asajeffrey:constellation-index-past-correctly-…
…when-discarding, r=cbrewster

Index the session past correctly when discarding.

<!-- Please describe your changes on the following line: -->

Oops, indexed from the wrong end when discarding documents in #14312.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because we're not testing document discarding

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14860)
<!-- Reviewable:end -->
2bc27d8
@bors-servo bors-servo added a commit that referenced this pull request Jan 6, 2017
@bors-servo bors-servo Auto merge of #14860 - asajeffrey:constellation-index-past-correctly-…
…when-discarding, r=cbrewster

Index the session past correctly when discarding.

<!-- Please describe your changes on the following line: -->

Oops, indexed from the wrong end when discarding documents in #14312.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because we're not testing document discarding

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14860)
<!-- Reviewable:end -->
7f9fd0e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment