mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #8175 - benschulz:set-timeout-panic, r=jdm
Fixed panic in ActiveTimers.set_timeout_or_interval. `ActiveTimers.set_timeout_or_interval` asserts that the pipeline is not currently frozen. Apparently that is too strict. When pending network requests complete after a pipeline is frozen, scripts may be executed and a timer scheduled. With these changes scheduling a timer while the pipeline is frozen behaves as if the timer was scheduled at the time the pipeline was frozen. To reproduce the panic 1. `./mach run -r http://google.com`, 2. immediately click on any link and 3. wait for the panic. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8175) <!-- Reviewable:end -->
This commit is contained in:
commit
f74754f582
1 changed files with 10 additions and 4 deletions
|
@ -139,8 +139,6 @@ impl ActiveTimers {
|
||||||
is_interval: IsInterval,
|
is_interval: IsInterval,
|
||||||
source: TimerSource)
|
source: TimerSource)
|
||||||
-> i32 {
|
-> i32 {
|
||||||
assert!(self.suspended_since.get().is_none());
|
|
||||||
|
|
||||||
// step 3
|
// step 3
|
||||||
let TimerHandle(new_handle) = self.next_timer_handle.get();
|
let TimerHandle(new_handle) = self.next_timer_handle.get();
|
||||||
self.next_timer_handle.set(TimerHandle(new_handle + 1));
|
self.next_timer_handle.set(TimerHandle(new_handle + 1));
|
||||||
|
@ -283,7 +281,10 @@ impl ActiveTimers {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn schedule_timer_call(&self) {
|
fn schedule_timer_call(&self) {
|
||||||
assert!(self.suspended_since.get().is_none());
|
if self.suspended_since.get().is_some() {
|
||||||
|
// The timer will be scheduled when the pipeline is thawed.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let timers = self.timers.borrow();
|
let timers = self.timers.borrow();
|
||||||
|
|
||||||
|
@ -318,7 +319,12 @@ impl ActiveTimers {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn base_time(&self) -> MsDuration {
|
fn base_time(&self) -> MsDuration {
|
||||||
precise_time_ms() - self.suspension_offset.get()
|
let offset = self.suspension_offset.get();
|
||||||
|
|
||||||
|
match self.suspended_since.get() {
|
||||||
|
Some(time) => time - offset,
|
||||||
|
None => precise_time_ms() - offset,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// see step 7 of https://html.spec.whatwg.org/multipage/#timer-initialisation-steps
|
// see step 7 of https://html.spec.whatwg.org/multipage/#timer-initialisation-steps
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue