Changeset 286991 in webkit
- Timestamp:
- Dec 13, 2021, 3:49:02 PM (5 years ago)
- Location:
- branches/safari-612-branch/Source/WebKit
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
WebProcess/WebPage/EventDispatcher.cpp (modified) (1 diff)
-
WebProcess/WebPage/EventDispatcher.h (modified) (1 diff)
-
WebProcess/WebPage/EventDispatcher.messages.in (modified) (1 diff)
-
WebProcess/WebPage/MomentumEventDispatcher.cpp (modified) (10 diffs)
-
WebProcess/WebPage/MomentumEventDispatcher.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-612-branch/Source/WebKit/ChangeLog
r286977 r286991 1 2021-12-13 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r286919. rdar://problem/86247557 4 5 Momentum Event Dispatcher: Tail frames are the wrong velocity if momentum event dispatch rate doesn't match screen refresh rate 6 https://bugs.webkit.org/show_bug.cgi?id=234168 7 <rdar://problem/86247557> 8 9 Reviewed by Simon Fraser. 10 11 In r286671, I scaled the tail frames into the momentum event disaptch 12 rate, but they are actually always dispatched at display refresh 13 frequency. In many cases these things are the same, but in some 14 cases can differ (most commonly a 120Hz display with 60Hz event dispatch), 15 so to always have the tail move at the right rate, scale into the display 16 refresh rate instead). 17 18 * UIProcess/WebPageProxy.cpp: 19 (WebKit::WebPageProxy::windowScreenDidChange): 20 * WebProcess/WebPage/EventDispatcher.cpp: 21 (WebKit::EventDispatcher::pageScreenDidChange): 22 * WebProcess/WebPage/EventDispatcher.h: 23 * WebProcess/WebPage/EventDispatcher.messages.in: 24 * WebProcess/WebPage/MomentumEventDispatcher.cpp: 25 (WebKit::MomentumEventDispatcher::didStartMomentumPhase): 26 (WebKit::MomentumEventDispatcher::displayProperties const): 27 (WebKit::MomentumEventDispatcher::startDisplayLink): 28 (WebKit::MomentumEventDispatcher::stopDisplayLink): 29 (WebKit::MomentumEventDispatcher::pageScreenDidChange): 30 (WebKit::MomentumEventDispatcher::displayWasRefreshed): 31 (WebKit::MomentumEventDispatcher::displayID const): Deleted. 32 * WebProcess/WebPage/MomentumEventDispatcher.h: 33 Plumb and store the nominal display refresh rate. 34 35 (WebKit::MomentumEventDispatcher::buildOffsetTableWithInitialDelta): 36 Scale the tail frames from the 60Hz ideal rate into the display refresh 37 rate, instead of the event dispatch rate. 38 39 Incoming events still scale *in* from the event dispatch rate, since 40 that's... the rate they come at. 41 42 43 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286919 268f45cc-cd09-0410-ab3c-d52691b4dbfc 44 45 2021-12-11 Tim Horton <timothy_horton@apple.com> 46 47 Momentum Event Dispatcher: Tail frames are the wrong velocity if momentum event dispatch rate doesn't match screen refresh rate 48 https://bugs.webkit.org/show_bug.cgi?id=234168 49 <rdar://problem/86247557> 50 51 Reviewed by Simon Fraser. 52 53 In r286671, I scaled the tail frames into the momentum event disaptch 54 rate, but they are actually always dispatched at display refresh 55 frequency. In many cases these things are the same, but in some 56 cases can differ (most commonly a 120Hz display with 60Hz event dispatch), 57 so to always have the tail move at the right rate, scale into the display 58 refresh rate instead). 59 60 * UIProcess/WebPageProxy.cpp: 61 (WebKit::WebPageProxy::windowScreenDidChange): 62 * WebProcess/WebPage/EventDispatcher.cpp: 63 (WebKit::EventDispatcher::pageScreenDidChange): 64 * WebProcess/WebPage/EventDispatcher.h: 65 * WebProcess/WebPage/EventDispatcher.messages.in: 66 * WebProcess/WebPage/MomentumEventDispatcher.cpp: 67 (WebKit::MomentumEventDispatcher::didStartMomentumPhase): 68 (WebKit::MomentumEventDispatcher::displayProperties const): 69 (WebKit::MomentumEventDispatcher::startDisplayLink): 70 (WebKit::MomentumEventDispatcher::stopDisplayLink): 71 (WebKit::MomentumEventDispatcher::pageScreenDidChange): 72 (WebKit::MomentumEventDispatcher::displayWasRefreshed): 73 (WebKit::MomentumEventDispatcher::displayID const): Deleted. 74 * WebProcess/WebPage/MomentumEventDispatcher.h: 75 Plumb and store the nominal display refresh rate. 76 77 (WebKit::MomentumEventDispatcher::buildOffsetTableWithInitialDelta): 78 Scale the tail frames from the 60Hz ideal rate into the display refresh 79 rate, instead of the event dispatch rate. 80 81 Incoming events still scale *in* from the event dispatch rate, since 82 that's... the rate they come at. 83 1 84 2021-12-13 Alan Coon <alancoon@apple.com> 2 85 -
branches/safari-612-branch/Source/WebKit/UIProcess/WebPageProxy.cpp
r286973 r286991 4017 4017 return; 4018 4018 4019 send(Messages::EventDispatcher::PageScreenDidChange(m_webPageID, displayID ));4019 send(Messages::EventDispatcher::PageScreenDidChange(m_webPageID, displayID, nominalFramesPerSecond)); 4020 4020 send(Messages::WebPage::WindowScreenDidChange(displayID, nominalFramesPerSecond)); 4021 4021 #if HAVE(CVDISPLAYLINK) -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
r286683 r286991 331 331 #endif 332 332 333 void EventDispatcher::pageScreenDidChange(PageIdentifier pageID, PlatformDisplayID displayID )334 { 335 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 336 m_momentumEventDispatcher->pageScreenDidChange(pageID, displayID );333 void EventDispatcher::pageScreenDidChange(PageIdentifier pageID, PlatformDisplayID displayID, std::optional<unsigned> nominalFramesPerSecond) 334 { 335 #if ENABLE(MOMENTUM_EVENT_DISPATCHER) 336 m_momentumEventDispatcher->pageScreenDidChange(pageID, displayID, nominalFramesPerSecond); 337 337 #else 338 338 UNUSED_PARAM(pageID); -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.h
r286694 r286991 127 127 #endif 128 128 129 void pageScreenDidChange(WebCore::PageIdentifier, WebCore::PlatformDisplayID );129 void pageScreenDidChange(WebCore::PageIdentifier, WebCore::PlatformDisplayID, std::optional<unsigned> nominalFramesPerSecond); 130 130 131 131 Ref<WorkQueue> m_queue; -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/EventDispatcher.messages.in
r286683 r286991 37 37 SetScrollingAccelerationCurve(WebCore::PageIdentifier pageID, std::optional<WebKit::ScrollingAccelerationCurve> curve) 38 38 #endif 39 PageScreenDidChange(WebCore::PageIdentifier pageID, uint32_t displayID )39 PageScreenDidChange(WebCore::PageIdentifier pageID, uint32_t displayID, std::optional<unsigned> nominalFramesPerSecond) 40 40 } -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/MomentumEventDispatcher.cpp
r286974 r286991 41 41 static constexpr Seconds deltaHistoryMaximumAge = 500_ms; 42 42 static constexpr Seconds deltaHistoryMaximumInterval = 150_ms; 43 static constexpr floatidealCurveFrameRate = 60;43 static constexpr WebCore::FramesPerSecond idealCurveFrameRate = 60; 44 44 static constexpr Seconds idealCurveFrameInterval = 1_s / idealCurveFrameRate; 45 45 … … 185 185 void MomentumEventDispatcher::didStartMomentumPhase(WebCore::PageIdentifier pageIdentifier, const WebWheelEvent& event) 186 186 { 187 auto displayProperties = this->displayProperties(pageIdentifier); 188 if (!displayProperties) 189 return; 190 187 191 tracePoint(SyntheticMomentumStart); 188 192 … … 194 198 m_currentGesture.currentOffset = { }; 195 199 m_currentGesture.startTime = MonotonicTime::now() - momentumStartInterval; 200 m_currentGesture.displayNominalFrameRate = displayProperties->nominalFrameRate; 196 201 m_currentGesture.accelerationCurve = [&] () -> std::optional<ScrollingAccelerationCurve> { 197 202 auto curveIterator = m_accelerationCurves.find(m_currentGesture.pageIdentifier); … … 242 247 } 243 248 244 WebCore::PlatformDisplayID MomentumEventDispatcher::displayID() const245 { 246 ASSERT( m_currentGesture.pageIdentifier);247 auto display IDIterator = m_displayIDs.find(m_currentGesture.pageIdentifier);248 if (display IDIterator == m_displayIDs.end())249 return { };250 return displayIDIterator->value;249 std::optional<MomentumEventDispatcher::DisplayProperties> MomentumEventDispatcher::displayProperties(WebCore::PageIdentifier pageIdentifier) const 250 { 251 ASSERT(pageIdentifier); 252 auto displayPropertiesIterator = m_displayProperties.find(pageIdentifier); 253 if (displayPropertiesIterator == m_displayProperties.end()) 254 return std::nullopt; 255 return { displayPropertiesIterator->value }; 251 256 } 252 257 253 258 void MomentumEventDispatcher::startDisplayLink() 254 259 { 255 auto display ID = this->displayID();256 if (!display ID) {260 auto displayProperties = this->displayProperties(m_currentGesture.pageIdentifier); 261 if (!displayProperties) { 257 262 RELEASE_LOG(ScrollAnimations, "MomentumEventDispatcher failed to start display link"); 258 263 return; … … 260 265 261 266 // FIXME: Switch down to lower-than-full-speed frame rates for the tail end of the curve. 262 WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::StartDisplayLink(m_observerID, display ID, WebCore::FullSpeedFramesPerSecond), 0);263 #if ENABLE(MOMENTUM_EVENT_DISPATCHER_TEMPORARY_LOGGING) 264 RELEASE_LOG(ScrollAnimations, "MomentumEventDispatcher starting display link for display %d", display ID);267 WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::StartDisplayLink(m_observerID, displayProperties->displayID, WebCore::FullSpeedFramesPerSecond), 0); 268 #if ENABLE(MOMENTUM_EVENT_DISPATCHER_TEMPORARY_LOGGING) 269 RELEASE_LOG(ScrollAnimations, "MomentumEventDispatcher starting display link for display %d", displayProperties->displayID); 265 270 #endif 266 271 } … … 268 273 void MomentumEventDispatcher::stopDisplayLink() 269 274 { 270 auto display ID = this->displayID();271 if (!display ID) {275 auto displayProperties = this->displayProperties(m_currentGesture.pageIdentifier); 276 if (!displayProperties) { 272 277 RELEASE_LOG(ScrollAnimations, "MomentumEventDispatcher failed to stop display link"); 273 278 return; 274 279 } 275 280 276 WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::StopDisplayLink(m_observerID, display ID), 0);277 #if ENABLE(MOMENTUM_EVENT_DISPATCHER_TEMPORARY_LOGGING) 278 RELEASE_LOG(ScrollAnimations, "MomentumEventDispatcher stopping display link for display %d", display ID);279 #endif 280 } 281 282 void MomentumEventDispatcher::pageScreenDidChange(WebCore::PageIdentifier pageID, WebCore::PlatformDisplayID displayID )281 WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::StopDisplayLink(m_observerID, displayProperties->displayID), 0); 282 #if ENABLE(MOMENTUM_EVENT_DISPATCHER_TEMPORARY_LOGGING) 283 RELEASE_LOG(ScrollAnimations, "MomentumEventDispatcher stopping display link for display %d", displayProperties->displayID); 284 #endif 285 } 286 287 void MomentumEventDispatcher::pageScreenDidChange(WebCore::PageIdentifier pageID, WebCore::PlatformDisplayID displayID, std::optional<unsigned> nominalFramesPerSecond) 283 288 { 284 289 bool affectsCurrentGesture = (pageID == m_currentGesture.pageIdentifier); … … 286 291 stopDisplayLink(); 287 292 288 m_displayIDs.set(pageID, displayID); 293 DisplayProperties properties; 294 properties.displayID = displayID; 295 properties.nominalFrameRate = nominalFramesPerSecond.value_or(WebCore::FullSpeedFramesPerSecond); 296 m_displayProperties.set(pageID, WTFMove(properties)); 289 297 290 298 if (affectsCurrentGesture) … … 320 328 return; 321 329 322 if (displayID != this->displayID()) 330 auto displayProperties = this->displayProperties(m_currentGesture.pageIdentifier); 331 if (!displayProperties || displayID != displayProperties->displayID) 323 332 return; 324 333 … … 371 380 WebCore::FloatSize unacceleratedDelta = initialUnacceleratedDelta; 372 381 373 float physicalCurveMultiplier = idealCurveFrameRate / m_currentGesture.accelerationCurve->frameRate(); 382 // Tail deltas will be dispatched at the screen refresh rate, not the momentum 383 // dispatch rate, so we need to scale from 60Hz into screen refresh rate. 384 float tailCurveMultiplier = static_cast<float>(idealCurveFrameRate) / m_currentGesture.displayNominalFrameRate; 374 385 bool inTail = false; 375 386 WebCore::FloatSize tailCarry; … … 386 397 387 398 if (inTail) { 388 auto tailDelta = acceleratedDelta * physicalCurveMultiplier;399 auto tailDelta = acceleratedDelta * tailCurveMultiplier; 389 400 auto deltaWithCarry = tailDelta + tailCarry; 390 401 auto quantizedDelta = roundedIntSize(deltaWithCarry); -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/MomentumEventDispatcher.h
r286701 r286991 43 43 namespace WebCore { 44 44 struct DisplayUpdate; 45 using FramesPerSecond = unsigned; 45 46 using PlatformDisplayID = uint32_t; 46 47 } … … 63 64 void displayWasRefreshed(WebCore::PlatformDisplayID, const WebCore::DisplayUpdate&); 64 65 65 void pageScreenDidChange(WebCore::PageIdentifier, WebCore::PlatformDisplayID );66 void pageScreenDidChange(WebCore::PageIdentifier, WebCore::PlatformDisplayID, std::optional<unsigned> nominalFramesPerSecond); 66 67 67 68 private: … … 74 75 void stopDisplayLink(); 75 76 76 WebCore::PlatformDisplayID displayID() const; 77 struct DisplayProperties { 78 WebCore::PlatformDisplayID displayID; 79 WebCore::FramesPerSecond nominalFrameRate; 80 }; 81 std::optional<DisplayProperties> displayProperties(WebCore::PageIdentifier) const; 77 82 78 83 void dispatchSyntheticMomentumEvent(WebWheelEvent::Phase, WebCore::FloatSize delta); … … 138 143 unsigned currentTailDeltaIndex { 0 }; 139 144 145 WebCore::FramesPerSecond displayNominalFrameRate { 0 }; 146 140 147 #if ENABLE(MOMENTUM_EVENT_DISPATCHER_TEMPORARY_LOGGING) 141 148 WebCore::FloatSize accumulatedEventOffset; … … 149 156 150 157 DisplayLinkObserverID m_observerID; 151 HashMap<WebCore::PageIdentifier, WebCore::PlatformDisplayID> m_displayIDs; 158 159 HashMap<WebCore::PageIdentifier, DisplayProperties> m_displayProperties; 152 160 HashMap<WebCore::PageIdentifier, std::optional<ScrollingAccelerationCurve>> m_accelerationCurves; 153 161 EventDispatcher& m_dispatcher;
Note:
See TracChangeset
for help on using the changeset viewer.