⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285165 in webkit


Ignore:
Timestamp:
Nov 2, 2021, 10:09:53 AM (5 years ago)
Author:
Simon Fraser
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:
Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r285164 r285165  
     12021-11-02  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Revert the wheel event coalescing added in r277587
     4        https://bugs.webkit.org/show_bug.cgi?id=232602
     5        <rdar://84908023>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        This wheel event coalescing was added to allow the tail end of momentum scrolls on
     10        120Hz devices to fall back to 60fps for power reasons. However, the OS does this for
     11        us, so we don't need to do our own coalescing.
     12
     13        * Shared/WebWheelEventCoalescer.cpp:
     14        (WebKit::WebWheelEventCoalescer::shouldDispatchEvent):
     15        (WebKit::WebWheelEventCoalescer::isMomentumPhaseEvent): Deleted.
     16        * Shared/WebWheelEventCoalescer.h:
     17        (WebKit::WebWheelEventCoalescer::shouldCoalesceEventsDuringDeceleration const): Deleted.
     18        (WebKit::WebWheelEventCoalescer::setShouldCoalesceEventsDuringDeceleration): Deleted.
     19        (): Deleted.
     20        * UIProcess/WebPageProxy.cpp:
     21        (WebKit::WebPageProxy::wheelEventCoalescer):
     22        (WebKit::WebPageProxy::windowScreenDidChange):
     23        (WebKit::WebPageProxy::shouldCoalesceWheelEventsDuringDeceleration const): Deleted.
     24        * UIProcess/WebPageProxy.h:
     25
    1262021-11-02  Patrick Angle  <pangle@apple.com>
    227
  • trunk/Source/WebKit/Shared/WebWheelEventCoalescer.cpp

    r278253 r285165  
    3030#include "NativeWebWheelEvent.h"
    3131#include "WebEventConversion.h"
    32 #include <WebCore/AnimationFrameRate.h>
    3332#include <wtf/text/TextStream.h>
    3433
    … …  
    8887}
    8988
    90 bool WebWheelEventCoalescer::isMomentumPhaseEvent(const WebWheelEvent& event)
    91 {
    92     return event.phase() == WebWheelEvent::Phase::PhaseNone && event.momentumPhase() == WebWheelEvent::Phase::PhaseChanged;
    93 }
    94 
    9589bool WebWheelEventCoalescer::shouldDispatchEventNow(const WebWheelEvent& event) const
    9690{
    … …  
    142136bool WebWheelEventCoalescer::shouldDispatchEvent(const NativeWebWheelEvent& event)
    143137{
    144     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 << ")");
     138    LOG_WITH_STREAM(WheelEvents, stream << "WebWheelEventCoalescer::shouldDispatchEvent " << event << " (" << m_wheelEventQueue.size() << " events in the queue, " << m_eventsBeingProcessed.size() << " event sequences being processed)");
    145139
    146140    m_wheelEventQueue.append(event);
    147 
    148     auto lastEventInterval = event.timestamp() - m_lastEventTime;
    149     m_lastEventTime = event.timestamp();
    150 
    151     if (isMomentumPhaseEvent(event) && shouldCoalesceEventsDuringDeceleration() && lastEventInterval) {
    152         constexpr double momentumVelocityEventFrequencyReductionThreashold = 320.0; // Points per second.
    153         auto instantaneousVelocity = std::max(std::abs(event.delta().width()), std::abs(event.delta().height())) / lastEventInterval.seconds();
    154 
    155         constexpr auto maxCoalescingInterval = WebCore::FullSpeedAnimationInterval;
    156         auto lastDispatchedEventInterval = event.timestamp() - m_lastDispatchedEventTime;
    157 
    158         if (instantaneousVelocity < momentumVelocityEventFrequencyReductionThreashold && lastDispatchedEventInterval < maxCoalescingInterval) {
    159             LOG_WITH_STREAM(WheelEvents, stream << " coalesced event that came within " << lastDispatchedEventInterval.milliseconds() << " of previous dispatch");
    160             return false;
    161         }
    162     }
    163141
    164142    if (!m_eventsBeingProcessed.isEmpty()) {
    … …  
    171149    }
    172150
    173     m_lastDispatchedEventTime = event.timestamp();
    174151    return true;
    175152}
  • trunk/Source/WebKit/Shared/WebWheelEventCoalescer.h

    r278253 r285165  
    2929#include <wtf/Deque.h>
    3030#include <wtf/FastMalloc.h>
    31 #include <wtf/WallTime.h>
    3231
    3332namespace WebKit {
    … …  
    4443    bool hasEventsBeingProcessed() const { return !m_eventsBeingProcessed.isEmpty(); }
    4544   
    46     bool shouldCoalesceEventsDuringDeceleration() const { return m_shouldCoalesceEventsDuringDeceleration; }
    47     void setShouldCoalesceEventsDuringDeceleration(bool shouldCoalsce) { m_shouldCoalesceEventsDuringDeceleration = shouldCoalsce; }
    48 
    4945    void clear();
    5046
    … …  
    5551    static WebWheelEvent coalesce(const WebWheelEvent&, const WebWheelEvent&);
    5652
    57     static bool isMomentumPhaseEvent(const WebWheelEvent&);
    58 
    5953    bool shouldDispatchEventNow(const WebWheelEvent&) const;
    6054
    6155    Deque<NativeWebWheelEvent, 2> m_wheelEventQueue;
    6256    Deque<std::unique_ptr<CoalescedEventSequence>> m_eventsBeingProcessed;
    63 
    64     WallTime m_lastEventTime;
    65     WallTime m_lastDispatchedEventTime;
    66     bool m_shouldCoalesceEventsDuringDeceleration { false };
    6757};
    6858
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r285159 r285165  
    29472947WebWheelEventCoalescer& WebPageProxy::wheelEventCoalescer()
    29482948{
    2949     if (!m_wheelEventCoalescer) {
     2949    if (!m_wheelEventCoalescer)
    29502950        m_wheelEventCoalescer = makeUnique<WebWheelEventCoalescer>();
    2951         m_wheelEventCoalescer->setShouldCoalesceEventsDuringDeceleration(shouldCoalesceWheelEventsDuringDeceleration());
    2952     }
    29532951
    29542952    return *m_wheelEventCoalescer;
    2955 }
    2956 
    2957 bool WebPageProxy::shouldCoalesceWheelEventsDuringDeceleration() const
    2958 {
    2959 #if HAVE(CVDISPLAYLINK)
    2960     if (!m_displayID)
    2961         return false;
    2962 
    2963     auto framesPerSecond = m_process->processPool().nominalFramesPerSecondForDisplay(*m_displayID);
    2964     return framesPerSecond > WebCore::FullSpeedFramesPerSecond;
    2965 #else
    2966     return false;
    2967 #endif
    29682953}
    29692954
    … …  
    39483933{
    39493934    m_displayID = displayID;
    3950 
    3951     if (m_wheelEventCoalescer)
    3952         m_wheelEventCoalescer->setShouldCoalesceEventsDuringDeceleration(shouldCoalesceWheelEventsDuringDeceleration());
    39533935
    39543936    if (!hasRunningProcess())
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r285047 r285165  
    23882388
    23892389    WebWheelEventCoalescer& wheelEventCoalescer();
    2390     bool shouldCoalesceWheelEventsDuringDeceleration() const;
    23912390
    23922391#if HAVE(CVDISPLAYLINK)
Note: See TracChangeset for help on using the changeset viewer.