Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix performance interface timing member #25205

Merged

Conversation

@shnmorimoto
Copy link
Contributor

shnmorimoto commented Dec 7, 2019


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #23330 and #24468 (GitHub issue number if applicable)
  • There are tests for these changes
@highfive
Copy link

highfive commented Dec 7, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/performance.rs, components/script/network_listener.rs, components/script/script_thread.rs, components/script/dom/servoparser/mod.rs, components/script/dom/webidls/Performance.webidl
  • @KiChjang: components/script/dom/performance.rs, components/script/network_listener.rs, components/script/script_thread.rs, components/script/dom/servoparser/mod.rs, components/script/dom/webidls/Performance.webidl
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 8, 2019

When I run ./mach run https://www.google.com , I get a crash.

> ./mach run https://www.google.com                                                                                                                                    fix_performance_interface_timing_member ✱
[2019-12-08T07:06:36Z ERROR script::dom::bindings::error] Error at https://www.google.com/:345:1419 document.f.q is undefined
internal error: entered unreachable code: Are we trying to expose Performance.timing in workers? (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(1) }, at components/script/dom/
performance.rs:394)
stack backtrace:
   0: backtrace::backtrace::trace_unsynchronized
   1: <servo::backtrace::Print as core::fmt::Debug>::fmt
   2: core::fmt::write
   3: <std::io::stdio::Stdout as std::io::Write>::write_fmt
   4: std::io::stdio::_print
   5: servo::backtrace::print
   6: servo::main::{{closure}}
   7: std::panicking::rust_panic_with_hook
   8: rust_begin_unwind
   9: std::panicking::begin_panic_fmt
  10: <script::dom::performance::Performance as script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::PerformanceMethods>::Timing
  11: script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::get_timing::{{closure}}
  12: core::ops::function::FnOnce::call_once
  13: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  14: std::panicking::try::do_call
  15: __rust_maybe_catch_panic
  16: std::panicking::try
  17: std::panic::catch_unwind
  18: mozjs::panic::wrap_panic
  19: script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::get_timing
  20: CallJitGetterOp
  21: script::dom::bindings::utils::generic_call
  22: script::dom::bindings::utils::generic_getter
  23: _ZN2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstructE
  24: _ZN2js10CallGetterEP9JSContextN2JS6HandleINS2_5ValueEEES5_NS2_13MutableHandleIS4_EE
  25: _ZN2js17NativeGetPropertyEP9JSContextN2JS6HandleIPNS_12NativeObjectEEENS3_INS2_5ValueEEENS3_INS2_11PropertyKeyEEENS2_13MutableHandleIS7_EE
  26: _ZN2js3jit17DoGetElemFallbackEP9JSContextPNS0_13BaselineFrameEPNS0_18ICGetElem_FallbackEN2JS6HandleINS7_5ValueEEESA_NS7_13MutableHandleIS9_EE

[2019-12-08T07:06:38Z ERROR servo] internal error: entered unreachable code: Are we trying to expose Performance.timing in workers?

I'm trying to find out the cause of this error.

@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 9, 2019

@jdm
I inserted debug log like this.

impl PerformanceMethods for Performance {
    // FIXME(avada): this should be deprecated in the future, but some sites still use it
    // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html#performance-timing-attribute
    fn Timing(&self) -> DomRoot<PerformanceNavigationTiming> {
        debug!("#25205 call Timing function");
        let entries = self.GetEntriesByType(DOMString::from("navigation"));
 ....

And, I investigated when each function was called.

[2019-12-09T15:01:15Z DEBUG script::dom::servoparser] #25205 call process_response func
[2019-12-09T15:01:15Z DEBUG script::dom::servoparser] #25205 call submit_resource_timing func
[2019-12-09T15:01:16Z DEBUG script::dom::performance] #25205 call Timing function
[2019-12-09T15:01:20Z DEBUG script::dom::servoparser] #25205 call process_response_eof func
[2019-12-09T15:01:20Z DEBUG script::dom::performance] #25205 call update_entry function
[2019-12-09T15:01:21Z DEBUG script::dom::performance] #25205 call Timing function
[2019-12-09T15:01:21Z DEBUG script::dom::performance] #25205 call Timing function
internal error: entered unreachable code: Are we trying to expose Performance.timing in workers? (thread ScriptThread PipelineId { namespace_id: PipelineNamespaceId(1), index: PipelineIndex(1) }, at components/script/dom/performance.rs:396)
[2019-12-09T15:01:21Z ERROR servo] internal error: entered unreachable code: Are we trying to expose Performance.timing in workers?
[2019-12-09T15:01:22Z DEBUG constellation::constellation] Sending log entry Panic("internal error: entered unreachable code: Are we trying to expose Performance.timing in workers?", "stack backtrace:\n   0: backtrace::backtrace::trace_unsynchronized\n   1: backtrace::backtrace::trace\n   2: backtrace::capture::Backtrace::create\n   3: backtrace::capture::Backtrace::new\n   4: constellation::constellation::log_entry\n   5: <constellation::constellation::FromCompositorLogger as log::Log>::log\n   6: <servo::BothLogger<Log1,Log2> as log::Log>::log\n   7: log::__private_api_log\n   8: servo::main::{{closure}}\n   9: std::panicking::rust_panic_with_hook\n  10: rust_begin_unwind\n  11: std::panicking::begin_panic_fmt\n  12: <script::dom::performance::Performance as script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::PerformanceMethods>::Timing\n  13: script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::get_timing::{{closure}}\n  14: core::ops::function::FnOnce::call_once\n  15: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once\n  16: std::panicking::try::do_call\n  17: __rust_maybe_catch_panic\n  18: std::panicking::try\n  19: std::panic::catch_unwind\n  20: mozjs::panic::wrap_panic\n  21: script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::get_timing\n  22: CallJitGetterOp\n  23: script::dom::bindings::utils::generic_call\n  24: script::dom::bindings::utils::generic_getter\n  25: _ZN2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstructE\n  26: _ZN2js10CallGetterEP9JSContextN2JS6HandleINS2_5ValueEEES5_NS2_13MutableHandleIS4_EE\n  27: _ZN2js17NativeGetPropertyEP9JSContextN2JS6HandleIPNS_12NativeObjectEEENS3_INS2_5ValueEEENS3_INS2_11PropertyKeyEEENS2_13MutableHandleIS7_EE\n  28: _ZN2js3jit17DoGetElemFallbackEP9JSContextPNS0_13BaselineFrameEPNS0_18ICGetElem_FallbackEN2JS6HandleINS7_5ValueEEESA_NS7_13MutableHandleIS9_EE\n").
[2019-12-09T15:01:22Z DEBUG constellation::constellation] Received log entry Panic("internal error: entered unreachable code: Are we trying to expose Performance.timing in workers?", "stack backtrace:\n   0: backtrace::backtrace::trace_unsynchronized\n   1: backtrace::backtrace::trace\n   2: backtrace::capture::Backtrace::create\n   3: backtrace::capture::Backtrace::new\n   4: constellation::constellation::log_entry\n   5: <constellation::constellation::FromCompositorLogger as log::Log>::log\n   6: <servo::BothLogger<Log1,Log2> as log::Log>::log\n   7: log::__private_api_log\n   8: servo::main::{{closure}}\n   9: std::panicking::rust_panic_with_hook\n  10: rust_begin_unwind\n  11: std::panicking::begin_panic_fmt\n  12: <script::dom::performance::Performance as script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::PerformanceMethods>::Timing\n  13: script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::get_timing::{{closure}}\n  14: core::ops::function::FnOnce::call_once\n  15: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once\n  16: std::panicking::try::do_call\n  17: __rust_maybe_catch_panic\n  18: std::panicking::try\n  19: std::panic::catch_unwind\n  20: mozjs::panic::wrap_panic\n  21: script::dom::bindings::codegen::Bindings::PerformanceBinding::PerformanceBinding::get_timing\n  22: CallJitGetterOp\n  23: script::dom::bindings::utils::generic_call\n  24: script::dom::bindings::utils::generic_getter\n  25: _ZN2js23InternalCallOrConstructEP9JSContextRKN2JS8CallArgsENS_14MaybeConstructE\n  26: _ZN2js10CallGetterEP9JSContextN2JS6HandleINS2_5ValueEEES5_NS2_13MutableHandleIS4_EE\n  27: _ZN2js17NativeGetPropertyEP9JSContextN2JS6HandleIPNS_12NativeObjectEEENS3_INS2_5ValueEEENS3_INS2_11PropertyKeyEEENS2_13MutableHandleIS7_EE\n  28: _ZN2js3jit17DoGetElemFallbackEP9JSContextPNS0_13BaselineFrameEPNS0_18ICGetElem_FallbackEN2JS6HandleINS7_5ValueEEESA_NS7_13MutableHandleIS9_EE\n").
[2019-12-09T15:01:22Z DEBUG constellation::constellation] Panic handler for top-level browsing context (0,1): internal error: entered unreachable code: Are we trying to expose Performance.timing in workers?.
[2019-12-09T15:01:22Z DEBUG script::dom::servoparser] #25205 call process_response func
[2019-12-09T15:01:22Z DEBUG script::dom::servoparser] #25205 call submit_resource_timing func
[2019-12-09T15:01:22Z DEBUG script::dom::servoparser] #25205 call process_response_eof func
[2019-12-09T15:01:22Z DEBUG script::dom::performance] #25205 call update_entry function

From the above results, it seems that there is a timing when Timing func is called earlier than process_response func.

Is there a way to investigate the cause of the problem?

@jdm
Copy link
Member

jdm commented Dec 9, 2019

Yes, this is #24468. I believe I have described the solution I have in mind that in that issue; let me know if it is unclear at all!

@jdm
Copy link
Member

jdm commented Dec 9, 2019

Oh, sorry, I didn't read your last message closely enough. I'll try and figure out what to do.

@jdm jdm assigned jdm and unassigned SimonSapin Dec 9, 2019
@jdm
Copy link
Member

jdm commented Dec 9, 2019

@shnmorimoto Do either of the following trigger the problem?

<iframe src="javascript:console.log(performance.timing)"></iframe>
<iframe srcdoc="<script>console.log(performance.timing)</script>"></iframe>
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 10, 2019

@jdm Thanks! Neither way caused problems.
This is the html used for the test.

<!DOCTYPE html>
<html>
<head>
<title>iframe 1</title>
</head>
<body>

Hello World.
<iframe src="javascript:console.log(performance.timing)"></iframe>

</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>iframe 2</title>
</head>
<body>

Hello World.

<iframe srcdoc="<script>console.log(performance.timing)</script>"></iframe>

</body>
</html>
@jdm
Copy link
Member

jdm commented Dec 10, 2019

@shnmorimoto I ended up using a debugger to figure out what was going on - I set a breakpoint in Performance::queue_entry and watched as self->buffer grew over time, then suddenly was empty. Looking at the code that modifies self.buffer, I realized that clear_entries_by_name_and_type has a bug - it is modeled after get_entries_by_name_and_type, so it ends up keeping any entries that match the name/type being cleared and throwing away any non-matching ones, which is the opposite behaviour from what we want. Fixing that bug should fix the google.com problem.

@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 11, 2019

@jdm Thank you for finding the cause and explaining how to way to find out.
I will try it when the same thing happens next time.

I understand the cause. I'll try to fix it.

@shnmorimoto shnmorimoto force-pushed the shnmorimoto:fix_performance_interface_timing_member branch from 2e91f26 to b0cabb7 Dec 11, 2019
@shnmorimoto
Copy link
Contributor Author

shnmorimoto commented Dec 11, 2019

I've fixed the clear_entries_by_name_and_type bug and confirmed that the google.com problem is resolved.

components/script/dom/performance.rs Outdated Show resolved Hide resolved
@shnmorimoto shnmorimoto force-pushed the shnmorimoto:fix_performance_interface_timing_member branch from b0cabb7 to aba4f0e Dec 11, 2019
@jdm
Copy link
Member

jdm commented Dec 11, 2019

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented Dec 11, 2019

Trying commit aba4f0e with merge 9a60282...

bors-servo added a commit that referenced this pull request Dec 11, 2019
…ember, r=<try>

Fix performance interface timing member

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

---
<!-- 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 #23330 and #24468 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

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

bors-servo commented Dec 11, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Dec 13, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Dec 13, 2019

📌 Commit 9b153ac has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Dec 13, 2019

Testing commit 9b153ac with merge f811bfa...

bors-servo added a commit that referenced this pull request Dec 13, 2019
…ember, r=jdm

Fix performance interface timing member

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

---
<!-- 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 #23330 and #24468 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

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

bors-servo commented Dec 13, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Dec 13, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Dec 13, 2019

Testing commit 9b153ac with merge 483f907...

bors-servo added a commit that referenced this pull request Dec 13, 2019
…ember, r=jdm

Fix performance interface timing member

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

---
<!-- 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 #23330 and #24468 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

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

bors-servo commented Dec 13, 2019

💔 Test failed - status-taskcluster

@jdm
Copy link
Member

jdm commented Dec 14, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Dec 14, 2019

Testing commit 9b153ac with merge 226b341...

bors-servo added a commit that referenced this pull request Dec 14, 2019
…ember, r=jdm

Fix performance interface timing member

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

---
<!-- 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 #23330 and #24468 (GitHub issue number if applicable)

<!-- Either: -->
- [x] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

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

bors-servo commented Dec 14, 2019

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing 226b341 to master...

@bors-servo bors-servo merged commit 9b153ac into servo:master Dec 14, 2019
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
@atouchet atouchet added this to Done in PanoMoments Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PanoMoments
  
Done
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.