From 1387af13abe35cc2265710e4de202db408acc3be Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 19 Mar 2020 03:36:54 +0000 Subject: [PATCH] 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 --- dom/animation/Animation.cpp | 5 ++- dom/animation/KeyframeEffect.cpp | 7 +++- dom/animation/test/mochitest.ini | 1 + .../test_mainthread_synchronization_pref.html | 42 +++++++++++++++++++ modules/libpref/init/StaticPrefList.yaml | 7 ++++ 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 dom/animation/test/mozilla/test_mainthread_synchronization_pref.html diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index c5964bb0bc37..9a46b21f57f2 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -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 = diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index 31c6c1c034a9..d0bab3500ede 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -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; diff --git a/dom/animation/test/mochitest.ini b/dom/animation/test/mochitest.ini index 308af2adb725..d951ee72d4e1 100644 --- a/dom/animation/test/mochitest.ini +++ b/dom/animation/test/mochitest.ini @@ -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] diff --git a/dom/animation/test/mozilla/test_mainthread_synchronization_pref.html b/dom/animation/test/mozilla/test_mainthread_synchronization_pref.html new file mode 100644 index 000000000000..3653fd953655 --- /dev/null +++ b/dom/animation/test/mozilla/test_mainthread_synchronization_pref.html @@ -0,0 +1,42 @@ + + + + + + + +
+ + diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index c1a6ccb23a72..44436a3dcd89 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -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