[webkit-changes] [WebKit/WebKit] 0a7a48: [macOS] Send playEffect() twice to Gamepad.actuato...

Basuke Suzuki noreply at github.com
Thu Nov 7 09:50:34 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0a7a483a4ef388c2597b6488f1f46e2b248e75f5
      https://github.com/WebKit/WebKit/commit/0a7a483a4ef388c2597b6488f1f46e2b248e75f5
  Author: Basuke Suzuki <basuke at apple.com>
  Date:   2024-11-07 (Thu, 07 Nov 2024)

  Changed paths:
    M Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.h
    M Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.mm
    M Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEngines.h
    M Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEngines.mm

  Log Message:
  -----------
  [macOS] Send playEffect() twice to Gamepad.actuator and it cannot stop with reset()
https://bugs.webkit.org/show_bug.cgi?id=279094
rdar://126589062

Reviewed by Chris Dumez.

When sending playEffect() to Gamepad.actuator more than once, the reset() cannot stop the gamepad from vibrating.

The root cause of the issue is requesting a completionHandler invocation to wrong effect object.
Say two sequential playEffect requests is coming.

1. The effect object of request 1 is stored in m_currentDualRumbleEffect and referenced by currentEffect in playEffect() method.
2. In second playEffect(), currentEffect is stopped  before start playing second one. This is in main thread.
3. Notification for stopPlaying is called for first request {*) in CoreHaptics thread.
4. currentEffect is replaced with new effect.
5. Notification arrived in main thread and try to invoke completionHandler targeting to second request. This is wrong because the notification is for first request.

Move the play logic from GameControllerHapticEngines to GameControllerHapticEffect to avoid this confusion.

* Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.h:
* Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEffect.mm:
(WebCore::GameControllerHapticEffect::create):
(WebCore::GameControllerHapticEffect::GameControllerHapticEffect):
(WebCore::GameControllerHapticEffect::~GameControllerHapticEffect):
(WebCore::GameControllerHapticEffect::start):
(WebCore::GameControllerHapticEffect::ensureStarted):
(WebCore::GameControllerHapticEffect::startEngine):
(WebCore::GameControllerHapticEffect::registerNotification):
(WebCore::GameControllerHapticEffect::stop):
(WebCore::GameControllerHapticEffect::leftEffectFinishedPlaying): Deleted.
(WebCore::GameControllerHapticEffect::rightEffectFinishedPlaying): Deleted.
* Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEngines.h:
* Source/WebCore/platform/gamepad/cocoa/GameControllerHapticEngines.mm:
(WebCore::GameControllerHapticEngines::create):
(WebCore::GameControllerHapticEngines::playEffect):
(WebCore::GameControllerHapticEngines::ensureStarted): Deleted.

Canonical link: https://commits.webkit.org/286286@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list