Mobile Safari: possible to get 240Hz Apple Pencil input in Javascript?

Is it possible to get 240Hz Apple Pencil events in Javascript? I know that with UIKit you have to poke at coalesced events to get this sort of sampling frequency, but it appears that Safari (and Mobile Safari) do not support the new PointerEvents.getCoalescedEvents() API (https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/getCoalescedEvents).

Anyone know of another way to get high-frequency 240Hz Apple Pencil events (e.g. as touchmove or pointermove events)?

Post not yet marked as solved Up vote post of snickell Down vote post of snickell
814 views

Replies

Before getCoalescedEvents and pointerrawupdate get supported, just listen pointermove event, you can get 240Hz report rate, or 120Hz report rate if Low Power Mode is on, from Apple Pencil, tested on iPad Pro 12.9 2nd Gen, iPadOS 17.0.1

Some other tips:

  1. To make pointerdown event to be triggered consistantly, go to Settings / Apple Pencil, disable ”Scribble“
  2. To enable 120fps fresh rate, go to Settings / Safari, disable feature “Prefer Page Rendering Updates near 60fps”, also ensure Low Power Mode to be off.
  3. To reduce canvas rendering latency, pass option {desynchronized: true} when invoking canvas.getContext

The above is all true, but pointer events are dropped on slow animation frames. I'm not aware of a way - other than getCoalescedEvents - to get them. And it's still not implemented :'(