Title: [285165] trunk/Source/WebKit
Revision
285165
Author
simon.fra...@apple.com
Date
2021-11-02 10:09:53 -0700 (Tue, 02 Nov 2021)

Log Message

Revert the wheel event coalescing added in r277587
https://bugs.webkit.org/show_bug.cgi?id=232602
<rdar://84908023>

Reviewed by Wenson Hsieh.

This wheel event coalescing was added to allow the tail end of momentum scrolls on
120Hz devices to fall back to 60fps for power reasons. However, the OS does this for
us, so we don't need to do our own coalescing.

* Shared/WebWheelEventCoalescer.cpp:
(WebKit::WebWheelEventCoalescer::shouldDispatchEvent):
(WebKit::WebWheelEventCoalescer::isMomentumPhaseEvent): Deleted.
* Shared/WebWheelEventCoalescer.h:
(WebKit::WebWheelEventCoalescer::shouldCoalesceEventsDuringDeceleration const): Deleted.
(WebKit::WebWheelEventCoalescer::setShouldCoalesceEventsDuringDeceleration): Deleted.
(): Deleted.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::wheelEventCoalescer):
(WebKit::WebPageProxy::windowScreenDidChange):
(WebKit::WebPageProxy::shouldCoalesceWheelEventsDuringDeceleration const): Deleted.
* UIProcess/WebPageProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (285164 => 285165)


--- trunk/Source/WebKit/ChangeLog	2021-11-02 17:01:52 UTC (rev 285164)
+++ trunk/Source/WebKit/ChangeLog	2021-11-02 17:09:53 UTC (rev 285165)
@@ -1,3 +1,28 @@
+2021-11-02  Simon Fraser  <simon.fra...@apple.com>
+
+        Revert the wheel event coalescing added in r277587
+        https://bugs.webkit.org/show_bug.cgi?id=232602
+        <rdar://84908023>
+
+        Reviewed by Wenson Hsieh.
+
+        This wheel event coalescing was added to allow the tail end of momentum scrolls on
+        120Hz devices to fall back to 60fps for power reasons. However, the OS does this for
+        us, so we don't need to do our own coalescing.
+
+        * Shared/WebWheelEventCoalescer.cpp:
+        (WebKit::WebWheelEventCoalescer::shouldDispatchEvent):
+        (WebKit::WebWheelEventCoalescer::isMomentumPhaseEvent): Deleted.
+        * Shared/WebWheelEventCoalescer.h:
+        (WebKit::WebWheelEventCoalescer::shouldCoalesceEventsDuringDeceleration const): Deleted.
+        (WebKit::WebWheelEventCoalescer::setShouldCoalesceEventsDuringDeceleration): Deleted.
+        (): Deleted.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::wheelEventCoalescer):
+        (WebKit::WebPageProxy::windowScreenDidChange):
+        (WebKit::WebPageProxy::shouldCoalesceWheelEventsDuringDeceleration const): Deleted.
+        * UIProcess/WebPageProxy.h:
+
 2021-11-02  Patrick Angle  <pan...@apple.com>
 
         WebDriver: [Cocoa] support `acceptInsecureCerts` capability

Modified: trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp (285164 => 285165)


--- trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp	2021-11-02 17:01:52 UTC (rev 285164)
+++ trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp	2021-11-02 17:09:53 UTC (rev 285165)
@@ -29,7 +29,6 @@
 #include "Logging.h"
 #include "NativeWebWheelEvent.h"
 #include "WebEventConversion.h"
-#include <WebCore/AnimationFrameRate.h>
 #include <wtf/text/TextStream.h>
 
 namespace WebKit {
@@ -87,11 +86,6 @@
 #endif
 }
 
-bool WebWheelEventCoalescer::isMomentumPhaseEvent(const WebWheelEvent& event)
-{
-    return event.phase() == WebWheelEvent::Phase::PhaseNone && event.momentumPhase() == WebWheelEvent::Phase::PhaseChanged;
-}
-
 bool WebWheelEventCoalescer::shouldDispatchEventNow(const WebWheelEvent& event) const
 {
 #if PLATFORM(GTK)
@@ -141,26 +135,10 @@
 
 bool WebWheelEventCoalescer::shouldDispatchEvent(const NativeWebWheelEvent& event)
 {
-    LOG_WITH_STREAM(WheelEvents, stream << "WebWheelEventCoalescer::shouldDispatchEvent " << event << " (" << m_wheelEventQueue.size() << " events in the queue, " << m_eventsBeingProcessed.size() << " event sequences being processed, coalesce during decleration " << m_shouldCoalesceEventsDuringDeceleration << ")");
+    LOG_WITH_STREAM(WheelEvents, stream << "WebWheelEventCoalescer::shouldDispatchEvent " << event << " (" << m_wheelEventQueue.size() << " events in the queue, " << m_eventsBeingProcessed.size() << " event sequences being processed)");
 
     m_wheelEventQueue.append(event);
 
-    auto lastEventInterval = event.timestamp() - m_lastEventTime;
-    m_lastEventTime = event.timestamp();
-
-    if (isMomentumPhaseEvent(event) && shouldCoalesceEventsDuringDeceleration() && lastEventInterval) {
-        constexpr double momentumVelocityEventFrequencyReductionThreashold = 320.0; // Points per second.
-        auto instantaneousVelocity = std::max(std::abs(event.delta().width()), std::abs(event.delta().height())) / lastEventInterval.seconds();
-
-        constexpr auto maxCoalescingInterval = WebCore::FullSpeedAnimationInterval;
-        auto lastDispatchedEventInterval = event.timestamp() - m_lastDispatchedEventTime;
-
-        if (instantaneousVelocity < momentumVelocityEventFrequencyReductionThreashold && lastDispatchedEventInterval < maxCoalescingInterval) {
-            LOG_WITH_STREAM(WheelEvents, stream << " coalesced event that came within " << lastDispatchedEventInterval.milliseconds() << " of previous dispatch");
-            return false;
-        }
-    }
-
     if (!m_eventsBeingProcessed.isEmpty()) {
         if (!shouldDispatchEventNow(m_wheelEventQueue.last())) {
             LOG_WITH_STREAM(WheelEvents, stream << "WebWheelEventCoalescer::shouldDispatchEvent -  " << m_wheelEventQueue.size() << " events queued; not dispatching");
@@ -170,7 +148,6 @@
         // FIXME: This logic is confusing, and possibly not necessary.
     }
 
-    m_lastDispatchedEventTime = event.timestamp();
     return true;
 }
 

Modified: trunk/Source/WebKit/Shared/WebWheelEventCoalescer.h (285164 => 285165)


--- trunk/Source/WebKit/Shared/WebWheelEventCoalescer.h	2021-11-02 17:01:52 UTC (rev 285164)
+++ trunk/Source/WebKit/Shared/WebWheelEventCoalescer.h	2021-11-02 17:09:53 UTC (rev 285165)
@@ -28,7 +28,6 @@
 #include "NativeWebWheelEvent.h"
 #include <wtf/Deque.h>
 #include <wtf/FastMalloc.h>
-#include <wtf/WallTime.h>
 
 namespace WebKit {
 
@@ -43,9 +42,6 @@
 
     bool hasEventsBeingProcessed() const { return !m_eventsBeingProcessed.isEmpty(); }
     
-    bool shouldCoalesceEventsDuringDeceleration() const { return m_shouldCoalesceEventsDuringDeceleration; }
-    void setShouldCoalesceEventsDuringDeceleration(bool shouldCoalsce) { m_shouldCoalesceEventsDuringDeceleration = shouldCoalsce; }
-
     void clear();
 
 private:
@@ -54,16 +50,10 @@
     static bool canCoalesce(const WebWheelEvent&, const WebWheelEvent&);
     static WebWheelEvent coalesce(const WebWheelEvent&, const WebWheelEvent&);
 
-    static bool isMomentumPhaseEvent(const WebWheelEvent&);
-
     bool shouldDispatchEventNow(const WebWheelEvent&) const;
 
     Deque<NativeWebWheelEvent, 2> m_wheelEventQueue;
     Deque<std::unique_ptr<CoalescedEventSequence>> m_eventsBeingProcessed;
-
-    WallTime m_lastEventTime;
-    WallTime m_lastDispatchedEventTime;
-    bool m_shouldCoalesceEventsDuringDeceleration { false };
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (285164 => 285165)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-02 17:01:52 UTC (rev 285164)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-02 17:09:53 UTC (rev 285165)
@@ -2946,27 +2946,12 @@
 
 WebWheelEventCoalescer& WebPageProxy::wheelEventCoalescer()
 {
-    if (!m_wheelEventCoalescer) {
+    if (!m_wheelEventCoalescer)
         m_wheelEventCoalescer = makeUnique<WebWheelEventCoalescer>();
-        m_wheelEventCoalescer->setShouldCoalesceEventsDuringDeceleration(shouldCoalesceWheelEventsDuringDeceleration());
-    }
 
     return *m_wheelEventCoalescer;
 }
 
-bool WebPageProxy::shouldCoalesceWheelEventsDuringDeceleration() const
-{
-#if HAVE(CVDISPLAYLINK)
-    if (!m_displayID)
-        return false;
-
-    auto framesPerSecond = m_process->processPool().nominalFramesPerSecondForDisplay(*m_displayID);
-    return framesPerSecond > WebCore::FullSpeedFramesPerSecond;
-#else
-    return false;
-#endif
-}
-
 bool WebPageProxy::hasQueuedKeyEvent() const
 {
     return !m_keyEventQueue.isEmpty();
@@ -3948,9 +3933,6 @@
 {
     m_displayID = displayID;
 
-    if (m_wheelEventCoalescer)
-        m_wheelEventCoalescer->setShouldCoalesceEventsDuringDeceleration(shouldCoalesceWheelEventsDuringDeceleration());
-
     if (!hasRunningProcess())
         return;
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (285164 => 285165)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-02 17:01:52 UTC (rev 285164)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-02 17:09:53 UTC (rev 285165)
@@ -2387,7 +2387,6 @@
     void sendWheelEvent(const WebWheelEvent&);
 
     WebWheelEventCoalescer& wheelEventCoalescer();
-    bool shouldCoalesceWheelEventsDuringDeceleration() const;
 
 #if HAVE(CVDISPLAYLINK)
     void wheelEventHysteresisUpdated(PAL::HysteresisState);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to