Search code examples
iosswifthaptic-feedbackuifeedbackgenerator

AVHapticPlayer async call finishWithCompletionHandler: (type=3) did not get a reply after 30 seconds


Problem

I am using Haptic Feedback in my app for when the user moves some tiles. When the tiles are moved very quickly, causing the haptic feedback to trigger quickly, I get this warning in the console after 30 seconds:

enter image description here

2019-01-20 17:29:04.658240+0000 Loopover[17824:4937487] [Feedback] AVHapticPlayer async call finishWithCompletionHandler: (type=3) did not get a reply after 30 seconds (notified of 0 mediaserverd death(s) in this time)

How is the Haptic Feedback triggered?

I am triggering the Haptic Feedback using UIImpactFeedbackGenerator as shown:

UIImpactFeedbackGenerator(style: .light).impactOccurred()

What does this mean?

Is this warning something I should be worried about? If I move the tiles normally, no problems occur.

What should I do, if anything?


Solution

  • Is this warning something I should be worried about? What should I do, if anything?

    I guess no, and none. In Apple's doc about UIFeedbackGenerator https://developer.apple.com/documentation/uikit/uifeedbackgenerator, they say you should "Trust the system" about that.

    Talking about methods like impactOccurred():

    Note that calling these methods does not play haptics directly. Instead, it informs the system of the event. The system then determines whether to play the haptics based on the device, the application’s state, the amount of battery power remaining, and other factors.

    Haptic feedback is currently played only:

    • On a device with a supported Taptic Engine

    • When the app is running in the foreground

    • When the System Haptics setting is enabled

    And about the "Trust the system":

    As a general rule, trust the system to determine whether it should play feedback. Don't check the device type or app state to conditionally trigger feedback. After you’ve decided how you want to use feedback, always trigger it when the appropriate events occur. The system ignores any requests that it cannot fulfill.

    I hope this helps!