Changeset 255338 in webkit
- Timestamp:
- Jan 28, 2020 10:53:59 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r255335 r255338 1 2020-01-28 Said Abou-Hallawa <said@apple.com> 2 3 REGRESSION (r255158): http/tests/frame-throttling/raf-throttle-in-cross-origin-subframe.html is a flaky failure 4 https://bugs.webkit.org/show_bug.cgi?id=206839 5 6 Reviewed by Simon Fraser. 7 8 Logging on EWS has shown that in some cases ThrottlingReason::VisuallyIdle 9 was added to the Page::m_throttlingReasons but it was never removed. If 10 this happens renderingUpdate and requestAnimationFrame will be throttled 11 to 10 seconds which leads to test flakiness and timeout. 12 13 Currently the throttling reasons of Page or ScriptedAnimationController 14 can be changed by natural reasons (visibility, layout or device state) 15 unless Setting::renderingUpdateThrottlingEnabled is disabled. Low power 16 mode also can be overridden by a specific value set by the test. 17 18 To make things clearer, a new OptionSet<ThrottlingReason> will be added 19 to Page. Its name is m_throttlingReasonsOverrideForTestingMask. The 20 purpose of adding it is to allow disabling and overriding specific 21 ThrottlingReasons. The bits of m_throttlingReasonsOverrideForTestingMask 22 are not actually reasons. They prevent changing the corresponding bits in 23 Page::m_throttlingReasons by natural reasons. Here are the rules for 24 setting the bits of m_throttlingReasonsOverrideForTestingMask and 25 m_throttlingReasons: 26 27 -- Settings::renderingUpdateThrottlingEnabled is enabled: All the bits in 28 m_throttlingReasonsOverrideForTestingMask will be turned off expect 29 the bit of ThrottlingReason::VisuallyIdle. We need to disable it always 30 for testing. All the bits in m_throttlingReasons will be cleared. 31 ThrottlingReason::LowPowerMode will be added to m_throttlingReasons 32 if the device is already in low power mode. 33 34 -- Settings::renderingUpdateThrottlingEnabled is disabled: All the bits 35 in m_throttlingReasonsOverrideForTestingMask will be turned on. All the 36 bits in m_throttlingReasons will be cleared. 37 38 -- Low power mode is overridden: ThrottlingReason::LowPowerMode is added 39 to m_throttlingReasonsOverrideForTestingMask. The new overriding value 40 is set in m_throttlingReasons. 41 42 -- Low power mode is cleared: ThrottlingReason::LowPowerMode is removed 43 from m_throttlingReasonsOverrideForTestingMask. If the device is in 44 low power mode. ThrottlingReason::LowPowerMode will be added to 45 m_throttlingReasons 46 47 * dom/ScriptedAnimationController.cpp: 48 (WebCore::ScriptedAnimationController::addThrottlingReason): 49 (WebCore::ScriptedAnimationController::removeThrottlingReason): 50 Adding and removing ThrottlingReasons to ScriptedAnimationController will 51 be controlled by Page::m_throttlingReasonsOverrideForTestingMask. If the 52 bits of the corresponding reasons are on, no change will be allowed. 53 54 (WebCore::ScriptedAnimationController::clearThrottlingReasons): 55 (WebCore::ScriptedAnimationController::isThrottled const): 56 The bits in the m_throttlingReasons of Page and ScriptedAnimationController 57 reflect the state of the throttling. No need to check for the Settings. 58 59 (WebCore::ScriptedAnimationController::preferredScriptedAnimationInterval const): Deleted. 60 * dom/ScriptedAnimationController.h: 61 (WebCore::ScriptedAnimationController::preferredScriptedAnimationInterval const): 62 (WebCore::ScriptedAnimationController::addThrottlingReason): Deleted. 63 (WebCore::ScriptedAnimationController::removeThrottlingReason): Deleted. 64 65 * page/Page.cpp: 66 (WebCore::Page::Page): 67 Set the initial state of the low power mode throttling. 68 69 (WebCore::Page::setLowPowerModeEnabledOverrideForTesting): 70 This will override the low power mode state or clear it. If it overrides 71 it, no subsequent change will be allowed. 72 73 (WebCore::Page::renderingUpdateThrottlingEnabledChangedForTesting): 74 This called through changing the Settings from the tests only. 75 76 (WebCore::Page::setIsVisuallyIdleInternal): 77 (WebCore::Page::handleLowModePowerChange): 78 Prevent changing m_throttlingReasons if the throttling reasons can't be 79 altered. 80 81 (WebCore::Page::isLowPowerModeEnabled const): Deleted. 82 (WebCore::Page::renderingUpdateThrottlingEnabled const): Deleted. 83 (WebCore::Page::renderingUpdateThrottlingEnabledChanged): Deleted. 84 (WebCore::Page::isRenderingUpdateThrottled const): Deleted. 85 (WebCore::Page::preferredRenderingUpdateInterval const): Deleted. 86 * page/Page.h: 87 (WebCore::Page::isLowPowerModeEnabled const): 88 (WebCore::Page::canUpdateThrottlingReason const): 89 (WebCore::Page::isRenderingUpdateThrottled const): 90 (WebCore::Page::preferredRenderingUpdateInterval const): 91 * page/Settings.yaml: 92 * page/SettingsBase.cpp: 93 (WebCore::SettingsBase::renderingUpdateThrottlingEnabledChangedForTesting): 94 (WebCore::SettingsBase::renderingUpdateThrottlingEnabledChanged): Deleted. 95 * page/SettingsBase.h: 96 1 97 2020-01-28 Simon Fraser <simon.fraser@apple.com> 2 98 -
trunk/Source/WebCore/dom/ScriptedAnimationController.cpp
r255158 r255338 53 53 } 54 54 55 Seconds ScriptedAnimationController::preferredScriptedAnimationInterval() const56 {57 if (auto* page = this->page())58 return page->renderingUpdateThrottlingEnabled() ? preferredFrameInterval(m_throttlingReasons) : FullSpeedAnimationInterval;59 return FullSpeedAnimationInterval;60 }61 62 55 Seconds ScriptedAnimationController::interval() const 63 56 { … … 83 76 } 84 77 78 void ScriptedAnimationController::addThrottlingReason(ThrottlingReason reason) 79 { 80 if (auto* page = this->page()) { 81 if (!page->canUpdateThrottlingReason(reason)) 82 return; 83 } 84 m_throttlingReasons.add(reason); 85 } 86 87 void ScriptedAnimationController::removeThrottlingReason(ThrottlingReason reason) 88 { 89 if (auto* page = this->page()) { 90 if (!page->canUpdateThrottlingReason(reason)) 91 return; 92 } 93 m_throttlingReasons.remove(reason); 94 } 95 96 void ScriptedAnimationController::clearThrottlingReasons() 97 { 98 m_throttlingReasons = { }; 99 } 100 85 101 bool ScriptedAnimationController::isThrottled() const 86 102 { 87 if (auto* page = this->page()) 88 return page->renderingUpdateThrottlingEnabled() && (page->isRenderingUpdateThrottled() || !m_throttlingReasons.isEmpty()); 103 if (!m_throttlingReasons.isEmpty()) 104 return true; 105 if (auto* page = this->page()) 106 return page->isRenderingUpdateThrottled(); 89 107 return false; 90 108 } -
trunk/Source/WebCore/dom/ScriptedAnimationController.h
r255158 r255338 62 62 void resume(); 63 63 64 void addThrottlingReason(ThrottlingReason reason) { m_throttlingReasons.add(reason); } 65 void removeThrottlingReason(ThrottlingReason reason) { m_throttlingReasons.remove(reason); } 64 void addThrottlingReason(ThrottlingReason); 65 void removeThrottlingReason(ThrottlingReason); 66 void clearThrottlingReasons(); 66 67 WEBCORE_EXPORT bool isThrottled() const; 67 68 … … 70 71 71 72 Page* page() const; 72 Seconds preferredScriptedAnimationInterval() const ;73 Seconds preferredScriptedAnimationInterval() const { return preferredFrameInterval(m_throttlingReasons); } 73 74 bool isThrottledRelativeToPage() const; 74 75 bool shouldRescheduleRequestAnimationFrame(DOMHighResTimeStamp) const; -
trunk/Source/WebCore/page/Page.cpp
r255226 r255338 336 336 } 337 337 m_corsDisablingPatterns.shrinkToFit(); 338 339 if (m_lowPowerModeNotifier->isLowPowerModeEnabled()) 340 m_throttlingReasons.add(ThrottlingReason::LowPowerMode); 338 341 } 339 342 … … 1161 1164 } 1162 1165 1163 bool Page::isLowPowerModeEnabled() const1164 {1165 if (m_lowPowerModeEnabledOverrideForTesting)1166 return m_lowPowerModeEnabledOverrideForTesting.value();1167 1168 return m_lowPowerModeNotifier->isLowPowerModeEnabled();1169 }1170 1171 1166 void Page::setLowPowerModeEnabledOverrideForTesting(Optional<bool> isEnabled) 1172 1167 { 1173 m_lowPowerModeEnabledOverrideForTesting = isEnabled; 1174 handleLowModePowerChange(m_lowPowerModeEnabledOverrideForTesting.valueOr(false)); 1168 // Remove ThrottlingReason::LowPowerMode so handleLowModePowerChange() can do its work. 1169 m_throttlingReasonsOverridenForTesting.remove(ThrottlingReason::LowPowerMode); 1170 1171 if (isEnabled) { 1172 handleLowModePowerChange(isEnabled.value()); 1173 m_throttlingReasonsOverridenForTesting.add(ThrottlingReason::LowPowerMode); 1174 } else 1175 handleLowModePowerChange(m_lowPowerModeNotifier->isLowPowerModeEnabled()); 1175 1176 } 1176 1177 … … 1378 1379 } 1379 1380 1380 bool Page::renderingUpdateThrottlingEnabled() const 1381 { 1382 return m_settings->renderingUpdateThrottlingEnabled(); 1383 } 1384 1385 void Page::renderingUpdateThrottlingEnabledChanged() 1386 { 1381 void Page::renderingUpdateThrottlingEnabledChangedForTesting() 1382 { 1383 m_throttlingReasons = { }; 1384 1385 // This function can only be called through changing the Settings from the layout tests. 1386 // So disable ThrottlingReason::VisuallyIdle always. 1387 m_throttlingReasonsOverridenForTesting = ThrottlingReason::VisuallyIdle; 1388 1389 if (m_settings->renderingUpdateThrottlingEnabled()) { 1390 if (m_lowPowerModeNotifier->isLowPowerModeEnabled()) 1391 m_throttlingReasons.add(ThrottlingReason::LowPowerMode); 1392 } else { 1393 m_throttlingReasonsOverridenForTesting.add({ ThrottlingReason::OutsideViewport, ThrottlingReason::LowPowerMode, ThrottlingReason::NonInteractedCrossOriginFrame }); 1394 1395 forEachDocument([] (Document& document) { 1396 if (auto* scriptedAnimationController = document.scriptedAnimationController()) 1397 scriptedAnimationController->clearThrottlingReasons(); 1398 }); 1399 } 1400 1387 1401 renderingUpdateScheduler().adjustRenderingUpdateFrequency(); 1388 1402 } 1389 1403 1390 bool Page::isRenderingUpdateThrottled() const1391 {1392 return renderingUpdateThrottlingEnabled() && !m_throttlingReasons.isEmpty();1393 }1394 1395 Seconds Page::preferredRenderingUpdateInterval() const1396 {1397 return renderingUpdateThrottlingEnabled() ? preferredFrameInterval(m_throttlingReasons) : FullSpeedAnimationInterval;1398 }1399 1400 1404 void Page::setIsVisuallyIdleInternal(bool isVisuallyIdle) 1401 1405 { 1406 if (!canUpdateThrottlingReason(ThrottlingReason::VisuallyIdle)) 1407 return; 1408 1402 1409 if (isVisuallyIdle == m_throttlingReasons.contains(ThrottlingReason::VisuallyIdle)) 1403 1410 return; 1404 1411 1405 1412 m_throttlingReasons = m_throttlingReasons ^ ThrottlingReason::VisuallyIdle; 1406 1407 if (renderingUpdateThrottlingEnabled()) 1408 renderingUpdateScheduler().adjustRenderingUpdateFrequency(); 1413 renderingUpdateScheduler().adjustRenderingUpdateFrequency(); 1409 1414 } 1410 1415 1411 1416 void Page::handleLowModePowerChange(bool isLowPowerModeEnabled) 1412 1417 { 1418 if (!canUpdateThrottlingReason(ThrottlingReason::LowPowerMode)) 1419 return; 1420 1413 1421 if (isLowPowerModeEnabled == m_throttlingReasons.contains(ThrottlingReason::LowPowerMode)) 1414 1422 return; 1415 1423 1416 1424 m_throttlingReasons = m_throttlingReasons ^ ThrottlingReason::LowPowerMode; 1417 1418 if (renderingUpdateThrottlingEnabled()) 1419 renderingUpdateScheduler().adjustRenderingUpdateFrequency(); 1425 renderingUpdateScheduler().adjustRenderingUpdateFrequency(); 1420 1426 1421 1427 if (!RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) -
trunk/Source/WebCore/page/Page.h
r255226 r255338 699 699 bool isUtilityPage() const { return m_isUtilityPage; } 700 700 701 bool isLowPowerModeEnabled() const ;701 bool isLowPowerModeEnabled() const { return m_throttlingReasons.contains(ThrottlingReason::LowPowerMode); } 702 702 WEBCORE_EXPORT void setLowPowerModeEnabledOverrideForTesting(Optional<bool>); 703 703 704 bool renderingUpdateThrottlingEnabled() const;705 void renderingUpdateThrottlingEnabledChanged();706 bool isRenderingUpdateThrottled() const ;707 Seconds preferredRenderingUpdateInterval() const ;704 void renderingUpdateThrottlingEnabledChangedForTesting(); 705 bool canUpdateThrottlingReason(ThrottlingReason reason) const { return !m_throttlingReasonsOverridenForTesting.contains(reason); } 706 bool isRenderingUpdateThrottled() const { return !m_throttlingReasons.isEmpty(); } 707 Seconds preferredRenderingUpdateInterval() const { return preferredFrameInterval(m_throttlingReasons); } 708 708 709 709 WEBCORE_EXPORT void applicationWillResignActive(); … … 970 970 std::unique_ptr<PerformanceMonitor> m_performanceMonitor; 971 971 std::unique_ptr<LowPowerModeNotifier> m_lowPowerModeNotifier; 972 Optional<bool> m_lowPowerModeEnabledOverrideForTesting;973 972 974 973 Optional<Navigation> m_navigationToLogWhenVisible; … … 1005 1004 Vector<UserContentURLPattern> m_corsDisablingPatterns; 1006 1005 OptionSet<ThrottlingReason> m_throttlingReasons; 1006 OptionSet<ThrottlingReason> m_throttlingReasonsOverridenForTesting; 1007 1007 }; 1008 1008 -
trunk/Source/WebCore/page/Settings.yaml
r255158 r255338 768 768 renderingUpdateThrottlingEnabled: 769 769 initial: true 770 onChange: renderingUpdateThrottlingEnabledChanged 770 onChange: renderingUpdateThrottlingEnabledChangedForTesting 771 771 772 772 storageBlockingPolicy: -
trunk/Source/WebCore/page/SettingsBase.cpp
r255158 r255338 408 408 } 409 409 410 void SettingsBase::renderingUpdateThrottlingEnabledChanged ()411 { 412 if (m_page) 413 m_page->renderingUpdateThrottlingEnabledChanged ();410 void SettingsBase::renderingUpdateThrottlingEnabledChangedForTesting() 411 { 412 if (m_page) 413 m_page->renderingUpdateThrottlingEnabledChangedForTesting(); 414 414 } 415 415 -
trunk/Source/WebCore/page/SettingsBase.h
r255158 r255338 195 195 void hiddenPageDOMTimerThrottlingStateChanged(); 196 196 void hiddenPageCSSAnimationSuspensionEnabledChanged(); 197 void renderingUpdateThrottlingEnabledChanged ();197 void renderingUpdateThrottlingEnabledChangedForTesting(); 198 198 void resourceUsageOverlayVisibleChanged(); 199 199 void iceCandidateFilteringEnabledChanged();
Note: See TracChangeset
for help on using the changeset viewer.