mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #9401 - glennw:raf-timing, r=jdm
Fixes additional calls to rAF. Often, a rAF callback will request another rAF from the callback itself. Previously, the constellation would quickly receive two messages saying that there were no animations, and then there are animations again in the situation above. This would make the compositor tick the new animation straight away, causing strange fluctuations and timings in rAF callbacks. Instead, only send the NoAnimationCallbacks message if the animation callback queue is still empty after invoking the callbacks. This fixes rAF timing, which now runs at the correct (vsync) framerate. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9401) <!-- Reviewable:end -->
This commit is contained in:
commit
bc44ae679f
2 changed files with 45 additions and 26 deletions
|
@ -1199,11 +1199,6 @@ impl Document {
|
|||
{
|
||||
let mut list = self.animation_frame_list.borrow_mut();
|
||||
animation_frame_list = Vec::from_iter(list.drain());
|
||||
|
||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
||||
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
||||
AnimationState::NoAnimationCallbacksPresent);
|
||||
chan.send(event).unwrap();
|
||||
}
|
||||
let performance = self.window.Performance();
|
||||
let performance = performance.r();
|
||||
|
@ -1213,6 +1208,17 @@ impl Document {
|
|||
callback(*timing);
|
||||
}
|
||||
|
||||
// Only send the animation change state message after running any callbacks.
|
||||
// This means that if the animation callback adds a new callback for
|
||||
// the next frame (which is the common case), we won't send a NoAnimationCallbacksPresent
|
||||
// message quickly followed by an AnimationCallbacksPresent message.
|
||||
if self.animation_frame_list.borrow().is_empty() {
|
||||
let ConstellationChan(ref chan) = self.window.constellation_chan();
|
||||
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(),
|
||||
AnimationState::NoAnimationCallbacksPresent);
|
||||
chan.send(event).unwrap();
|
||||
}
|
||||
|
||||
self.window.reflow(ReflowGoal::ForDisplay,
|
||||
ReflowQueryType::NoQuery,
|
||||
ReflowReason::RequestAnimationFrame);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue