Bug 1623469 - Add a pref to disable synchronization transform animations with geometric animations. r=boris

Differential Revision: https://phabricator.services.mozilla.com/D67391

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2020-03-19 03:36:54 +00:00
Родитель 6cd54550a2
Коммит 1387af13ab
5 изменённых файлов: 60 добавлений и 2 удалений

Просмотреть файл

@ -19,6 +19,7 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/DeclarationBlock.h"
#include "mozilla/Maybe.h" // For Maybe
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/TypeTraits.h" // For std::forward<>
#include "nsAnimationManager.h" // For CSSAnimation
#include "nsComputedDOMStyle.h"
@ -979,7 +980,9 @@ bool Animation::ShouldBeSynchronizedWithMainThread(
// We check this before calling ShouldBlockAsyncTransformAnimations, partly
// because it's cheaper, but also because it's often the most useful thing
// to know when you're debugging performance.
if (mSyncWithGeometricAnimations &&
if (StaticPrefs::
dom_animations_mainthread_synchronization_with_geometric_animations() &&
mSyncWithGeometricAnimations &&
keyframeEffect->HasAnimationOfPropertySet(
nsCSSPropertyIDSet::TransformLikeProperties())) {
aPerformanceWarning =

Просмотреть файл

@ -1658,6 +1658,10 @@ bool KeyframeEffect::ShouldBlockAsyncTransformAnimations(
return true;
}
const bool enableMainthreadSynchronizationWithGeometricAnimations =
StaticPrefs::
dom_animations_mainthread_synchronization_with_geometric_animations();
for (const AnimationProperty& property : mProperties) {
// If there is a property for animations level that is overridden by
// !important rules, it should not block other animations from running
@ -1674,7 +1678,8 @@ bool KeyframeEffect::ShouldBlockAsyncTransformAnimations(
continue;
}
// Check for geometric properties
if (IsGeometricProperty(property.mProperty)) {
if (enableMainthreadSynchronizationWithGeometricAnimations &&
IsGeometricProperty(property.mProperty)) {
aPerformanceWarning =
AnimationPerformanceWarning::Type::TransformWithGeometricProperties;
return true;

Просмотреть файл

@ -46,6 +46,7 @@ skip-if = (os == 'win' && bits == 64) # Bug 1363957
[mozilla/test_distance_of_transform.html]
[mozilla/test_document_timeline_origin_time_range.html]
[mozilla/test_hide_and_show.html]
[mozilla/test_mainthread_synchronization_pref.html]
[mozilla/test_moz_prefixed_properties.html]
[mozilla/test_pending_animation_tracker.html]
[mozilla/test_restyles.html]

Просмотреть файл

@ -0,0 +1,42 @@
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../testcommon.js"></script>
<style>
.compositable {
/* Element needs geometry to be eligible for layerization */
width: 100px;
height: 100px;
background-color: white;
}
</style>
<body>
<div id="log"></div>
<script>
'use strict';
promise_test(async t => {
await SpecialPowers.pushPrefEnv({
set: [[ 'dom.animations.mainthread-synchronization-with-geometric-animations', false ]]
});
const elemA = addDiv(t, { class: 'compositable' });
const elemB = addDiv(t, { class: 'compositable' });
const animA = elemA.animate({ transform: [ 'translate(0px)',
'translate(100px)' ] },
100 * MS_PER_SEC);
const animB = elemB.animate({ marginLeft: [ '0px', '100px' ] },
100 * MS_PER_SEC);
await waitForPaints();
assert_true(SpecialPowers.wrap(animA).isRunningOnCompositor,
'Transform animation should not synchronize with margin-left animation ' +
'created within the same tick with disabling the corresponding pref');
}, 'Transform animation should not synchronize with margin-left animation '
+ 'created within the same tick with disabling the corresponding pref');
</script>
</body>

Просмотреть файл

@ -1367,6 +1367,13 @@
value: true
mirror: always
# Synchronize transform animations with geometric animations on the
# main thread.
- name: dom.animations.mainthread-synchronization-with-geometric-animations
type: bool
value: true
mirror: always
# Is support for AudioWorklet enabled?
- name: dom.audioworklet.enabled
type: bool