When measuring Safari's button-to-photon latency with html5gamepad.com, I noticed that Safari has roughly double the latency of Chrome for wired USB gamepads (108ms vs 56ms). I investigated this a bit and found this code in HIDGamepadProvider which I believe accounts for the difference: https://github.com/WebKit/webkit/blob/950143da027e80924b4bb86defa8a3f21fd3fb1e/Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp#L39 50ms is enormous latency for a gamepad - gaming mice charge a premium in order to deliver ~10ms latency savings. Could this delay be reduced or eliminated? The rationale around this code isn't entirely clear to me: // This isActive check is necessary as we want to delay input notifications from the time of the first input, // and not push the notification out on every subsequent input. if (!m_inputNotificationTimer.isActive()) m_inputNotificationTimer.startOneShot(inputNotificationDelay);
<rdar://problem/70315838>
Definitely room for improvement here.
Note also that GameControllerGamepadProvider also has a 16ms notification delay: https://github.com/WebKit/webkit/blob/950143da027e80924b4bb86defa8a3f21fd3fb1e/Source/WebCore/platform/gamepad/cocoa/GameControllerGamepadProvider.mm#L45 Could anyone comment on the intent behind these delays?
Created attachment 432706 [details] Patch
Committed r279480 (239333@main): <https://commits.webkit.org/239333@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 432706 [details].