Skip to content

Have animations more closely match the HTML spec - #26407

Merged
bors-servo merged 2 commits into
servo:masterfrom
mrobinson:animation-restyle-model
May 6, 2020
Merged

bors-servo merged 2 commits into
servo:masterfrom
mrobinson:animation-restyle-model

Conversation

@mrobinson

@mrobinson mrobinson commented May 4, 2020 •

Copy link
Copy Markdown
Member

These two commits do two major things:

Have animations ticks trigger a restyle: This corrects synchronization issues with animations,
where the values used in layout are out of sync with what is returned by getComputedStyle.

Tick the animation timer in script according to spec: This greatly reduces the flakiness of
animation and transitions tests.

Fixes #13865.


@highfive

highfive commented May 4, 2020

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/window.rs, components/script/dom/testbinding.rs, components/script/dom/webidls/TestBinding.webidl, components/script/script_thread.rs, components/script/dom/node.rs and 1 more
  • @cbrewster: components/constellation/constellation.rs
  • @KiChjang: components/script/dom/window.rs, components/script_traits/lib.rs, components/script/dom/testbinding.rs, components/script/dom/webidls/TestBinding.webidl, components/script/script_thread.rs and 2 more
  • @emilio: components/layout/animation.rs, components/style/matching.rs, components/style/animation.rs, components/style/context.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 4, 2020
@highfive

highfive commented May 4, 2020

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@mrobinson

Copy link
Copy Markdown
Member Author

@bors-servo try=wpt

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 04d8e27 with merge 101c6e7...

bors-servo added a commit that referenced this pull request May 4, 2020
[RFC] Use a restyle for animation ticks

This change corrects synchronization issues with animations, by
reworking the animation processing model to do a quick restyle and
incremental layout when ticking animations.

While this change adds overhead to animation ticks, the idea is that
this will be the fallback when synchronous behavior is required to
fulfill specification requirements. In the optimistic case, many
animations could be updated and applied off-the-main-thread and then
resynchronized when style information is queried by script.

Fixes #13865.

<!-- 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
- [ ] These changes fix #13865

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- 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
Copy Markdown
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label May 4, 2020
@jdm

jdm commented May 4, 2020

Copy link
Copy Markdown
Member

Should this PR enable the disabled tests, or are there other prerequisites?

@mrobinson

Copy link
Copy Markdown
Member Author

@jdm, yep. Currently, I think there are only two disabled:

  • mozilla/css/animations/basic-transition.html
  • mozilla/css/animations/transition-raf.html

These are enabled by removing the ini files which were disabling them. Could it be that there are more disabled in another directory?

@mrobinson
mrobinson force-pushed the animation-restyle-model branch from 04d8e27 to 8131ee3 Compare May 4, 2020 15:33
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label May 4, 2020
@mrobinson

Copy link
Copy Markdown
Member Author

@bors-servo try=wpt

Removing two expectations for newly passing tests.

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 8131ee3 with merge 5875d05...

bors-servo added a commit that referenced this pull request May 4, 2020
[RFC] Use a restyle for animation ticks

This change corrects synchronization issues with animations, by
reworking the animation processing model to do a quick restyle and
incremental layout when ticking animations.

While this change adds overhead to animation ticks, the idea is that
this will be the fallback when synchronous behavior is required to
fulfill specification requirements. In the optimistic case, many
animations could be updated and applied off-the-main-thread and then
resynchronized when style information is queried by script.

Fixes #13865.

<!-- 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
- [ ] These changes fix #13865

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- 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. -->
@jdm

jdm commented May 4, 2020

Copy link
Copy Markdown
Member

What about the animation-related test directories skipped in include.ini?

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - status-taskcluster
State: approved= try=True

@mrobinson

Copy link
Copy Markdown
Member Author

I wasn't sure if it was better to unskip intermittent tests later, but I'm happy to give it a shot in this change.

@mrobinson

Copy link
Copy Markdown
Member Author

It looks like there is more required to eliminate the flakiness from animations and transitions tests. My suspicion is that this is #19242 and perhaps, in addition, making sure that transition and animation events arrive to the script thread before the next animation tick is triggered. I'll start taking a look at this tomorrow. It seems like it would be good to have this all sorted out before going too much further.

Comment thread components/script/dom/node.rs Outdated
Comment on lines +173 to +179
const CLICK_IN_PROGRESS = 1 << 2;
const CLICK_IN_PROGRESS = 1 << 3;

#[doc = "Specifies whether this node is focusable and whether it is supposed \
to be reachable with using sequential focus navigation."]
const SEQUENTIALLY_FOCUSABLE = 1 << 3;
const SEQUENTIALLY_FOCUSABLE = 1 << 4;

// There are two free bits here.
// There is one bit free here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these changes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. This is left over from a previous version of this change where I added NodeFlags::HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS. It turns out that isn't necessary for this change, so I'll remove these changes as well.

@jdm jdm added S-awaiting-answer Someone asked a question that requires an answer. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 4, 2020
@mrobinson mrobinson changed the title [RFC] Use a restyle for animation ticks [RFC] Have animations more closely match the HTML spec May 5, 2020
@mrobinson
mrobinson force-pushed the animation-restyle-model branch from 8131ee3 to 84b5f97 Compare May 5, 2020 13:08
@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 5, 2020
This change corrects synchronization issues with animations, by
reworking the animation processing model to do a quick restyle and
incremental layout when ticking animations.

While this change adds overhead to animation ticks, the idea is that
this will be the fallback when synchronous behavior is required to
fulfill specification requirements. In the optimistic case, many
animations could be updated and applied off-the-main-thread and then
resynchronized when style information is queried by script.

Fixes servo#13865.
@mrobinson
mrobinson force-pushed the animation-restyle-model branch from 84b5f97 to 7ff8900 Compare May 5, 2020 13:14
@mrobinson

Copy link
Copy Markdown
Member Author

@bors-servo try=wpt

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label May 5, 2020
This is a small step toward fixing servo#19242. The main idea is that the
clock for animations should advance as the event loop ticks. We
accomplish this by moving the clock from layout and naming it the
"animation timeline" which is the spec language. This should fix
flakiness with animations and transitions tests where a reflow could
move animations forward while script was running.

This change also starts to break out transition and animation events
into their own data structure, because it's quite likely that the next
step in fixing servo#19242 is to no longer send these events through a
channel.
@mrobinson
mrobinson force-pushed the animation-restyle-model branch from 3f3171e to 3a74013 Compare May 5, 2020 18:09
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label May 5, 2020
@mrobinson

Copy link
Copy Markdown
Member Author

@bors-servo try=wpt

bors-servo added a commit that referenced this pull request May 5, 2020
[RFC] Have animations more closely match the HTML spec

These two commits do two major things:

**Have animations ticks trigger a restyle**: This corrects synchronization issues with animations,
where the values used in layout are out of sync with what is returned by `getComputedStyle`.

**Tick the animation timer in script according to spec**: This greatly reduces the flakiness of
animation and transitions tests.

Fixes #13865.

<!-- 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
- [ ] These changes fix #13865

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- 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
Copy Markdown
Contributor

⌛ Trying commit 3a74013 with merge 47ba832...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - status-taskcluster
State: approved= try=True

@mrobinson

Copy link
Copy Markdown
Member Author

@bors-servo try=wpt-mac

@jdm

jdm commented May 5, 2020

Copy link
Copy Markdown
Member

@bors-servo retry

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 3a74013 with merge 473e368...

bors-servo added a commit that referenced this pull request May 5, 2020
[RFC] Have animations more closely match the HTML spec

These two commits do two major things:

**Have animations ticks trigger a restyle**: This corrects synchronization issues with animations,
where the values used in layout are out of sync with what is returned by `getComputedStyle`.

**Tick the animation timer in script according to spec**: This greatly reduces the flakiness of
animation and transitions tests.

Fixes #13865.

<!-- 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
- [ ] These changes fix #13865

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- 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
Copy Markdown
Contributor

☀️ Test successful - status-taskcluster
State: approved= try=True

@mrobinson mrobinson changed the title [RFC] Have animations more closely match the HTML spec Have animations more closely match the HTML spec May 6, 2020
@mrobinson

Copy link
Copy Markdown
Member Author

@bors-servo r=jdm

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 3a74013 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-awaiting-answer Someone asked a question that requires an answer. labels May 6, 2020
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 3a74013 with merge b290ad9...

@bors-servo

Copy link
Copy Markdown
Contributor

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

@bors-servo
bors-servo merged commit b290ad9 into servo:master May 6, 2020
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 6, 2020
@atouchet atouchet mentioned this pull request May 6, 2020
5 of 13 tasks
@mrobinson
mrobinson deleted the animation-restyle-model branch May 6, 2020 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix animation processing ordering and reenable animations/basic-transition.html test

4 participants