<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anton Mazur</title>
    <description>The latest articles on DEV Community by Anton Mazur (@anton_mazur_610b21e650796).</description>
    <link>https://dev.to/anton_mazur_610b21e650796</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4250708%2F27b262f9-88b8-4120-8852-36546c0d183d.jpg</url>
      <title>DEV Community: Anton Mazur</title>
      <link>https://dev.to/anton_mazur_610b21e650796</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anton_mazur_610b21e650796"/>
    <language>en</language>
    <item>
      <title>How I measured mouse-wheel smoothing on macOS with Swift and AppKit</title>
      <dc:creator>Anton Mazur</dc:creator>
      <pubDate>Tue, 24 Nov 2026 01:28:40 +0000</pubDate>
      <link>https://dev.to/anton_mazur_610b21e650796/how-i-measured-mouse-wheel-smoothing-on-macos-with-swift-and-appkit-2g1d</link>
      <guid>https://dev.to/anton_mazur_610b21e650796/how-i-measured-mouse-wheel-smoothing-on-macos-with-swift-and-appkit-2g1d</guid>
      <description>&lt;p&gt;I maintain SmoothWheel, an open-source macOS wheel utility. I wanted to answer a narrow question: could I make the last few points of a scroll arrive more steadily while retaining a quick start and reversal?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;AI assistance was used to draft and edit this article. The measurements come from the project’s replay harness.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure packets after the real motion code
&lt;/h2&gt;

&lt;p&gt;The production coordinator routes input, then passes a wheel event to a stream that applies the motion model on each frame tick. The stream emits Quartz scroll packets. Trackpad input and marked synthetic events pass through. The smoother keeps independent state for each wheel axis and discards the old direction’s residual on reversal.&lt;/p&gt;

&lt;p&gt;The replay drives the same Swift event stream with a virtual clock and captures its output before anything is posted to the system. No event tap or target app is needed for this part of the test. The production code still does the rounding and allocates real Quartz events. This catches gaps that a test of floating-point positions alone would miss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Match distance and vary the clock phase
&lt;/h2&gt;

&lt;p&gt;In the November 24 single-notch replay, SmoothWheel and Mos 4.2.1 each emitted exactly 90 pt in the Quartz point field. I adjusted the Mos input gain to match delivered distance and kept each engine’s default smoothing duration. Input arrival was shifted across four offsets at each simulated refresh rate. A moving packet means the active axis emitted a nonzero point delta.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Median across four offsets&lt;/th&gt;
&lt;th&gt;SmoothWheel (Nov 24 build)&lt;/th&gt;
&lt;th&gt;Mos 4.2.1&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;First moving packet, 120 Hz&lt;/td&gt;
&lt;td&gt;6.3 ms&lt;/td&gt;
&lt;td&gt;12.5 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Largest gap in final 10%, 60 Hz&lt;/td&gt;
&lt;td&gt;16.7 ms&lt;/td&gt;
&lt;td&gt;16.7 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Largest gap in final 10%, 120 Hz&lt;/td&gt;
&lt;td&gt;16.7 ms&lt;/td&gt;
&lt;td&gt;8.3 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The reversal fixture issued a second input in the opposite direction 50 ms after the first. At 120 Hz, SmoothWheel’s first opposite packet arrived after a median 4.2 ms with zero old-direction points after the reversal input. That fixture measures response to reversal, separately from the single-notch stop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the last few points are different
&lt;/h2&gt;

&lt;p&gt;A trajectory can look smooth in floating-point math and still post a visibly uneven sequence. Near the end, a frame may advance the continuous trajectory by a fraction of a point. The integer point field then stays at zero until enough movement accumulates. In the initial 120 Hz replay, the largest landing gap spanned three simulated ticks.&lt;/p&gt;

&lt;p&gt;Emitting one point on every tick would close those gaps, but four points would take about 67 ms at 60 Hz and 33 ms at 120 Hz. That would change the speed of the stop when the display changes.&lt;/p&gt;

&lt;p&gt;We kept the existing onset and joined an elapsed-time braking curve at the current position and speed. The curve reaches zero velocity at the endpoint. Each tick samples that trajectory and emits the difference from the rounded position already delivered. In 16 production-coordinator stop replays spanning both directions, both rates, and four clock offsets, the maximum gap after 90% travel was 16.7 ms. Every stop still delivered exactly 90 pt in its intended direction.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the replay leaves out
&lt;/h2&gt;

&lt;p&gt;Quartz packet timing tells me when the app emitted motion. It cannot tell me when WindowServer delivered it, how Chrome consumed it, or whether the user saw a steadier stop. That part needs a paired test with a physical wheel, the same target app and zoom, and the same display settings.&lt;/p&gt;

&lt;p&gt;The general lesson for input tools is to measure exact travel, first response, reverse response, and late packet gaps separately. A single smoothness score would have hidden the precise property I needed to change.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/AntonMazur/SmoothWheel/blob/v0.4.0/Sources/ScrollEvents/ScrollEventStream.swift" rel="noopener noreferrer"&gt;Released stream source&lt;/a&gt; · &lt;a href="https://github.com/AntonMazur/SmoothWheel/blob/v0.4.0/Sources/ScrollCore/ScrollSmoother.swift" rel="noopener noreferrer"&gt;Released smoother source&lt;/a&gt;&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>softwaredevelopment</category>
      <category>swift</category>
    </item>
  </channel>
</rss>
