title: Core Haptics not playing in iOS 15 with certain AVAudioSession configurations
body: <p>I'm using <a href="https://developer.apple.com/documentation/corehaptics" rel="nofollow noreferrer">Core Haptics</a> to play a custom &quot;heart beat&quot; pattern, while simultaneously playing music using AVAudioPlayer. Specifically, I'm creating a simple <code>CHHapticPattern</code>, then creating a <code>CHHapticEngine</code> to play that pattern.</p>
  <p>The custom haptics play just fine on an iPhone running iOS 14, but completely stopped working in iOS 15.0+. The haptic engine doesn't throw any errors in iOS 15, it just fails silently. Standard haptic feedback such as <code>UIImpactFeedbackGenerator</code> work just fine; it's just the custom haptics that fail.</p>
  <p>After lots of debugging and seeing no obvious reasons why Core Haptics should suddenly stop working, I eventually discovered the culprit is that I have an <code>AVAudioSession</code> configured as follows:</p>
  <pre><code>     // Setup AVAudioSession
          do {
              
              try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: [.duckOthers]) // &lt;-- This conflicts with Core Haptics on iOS 15, but not iOS 14
              try AVAudioSession.sharedInstance().setActive(true)
              
          } catch {
              print(&quot;Error activating AVAudioSession: \(error)&quot;)
          }
  </code></pre>
  <p>If I remove the <code>.duckOthers</code> option (e.g., replace with <code>.mixWithOthers</code>), then the custom haptic pattern plays successfully in iOS 15 (and 14).</p>
  <p>While I can live with using <code>.mixWithOthers</code> instead of <code>.duckOthers</code>, I can't see any obvious rationale why <code>.duckOthers</code> should conflict with Core Haptics, and suddenly start conflicting with it only in iOS 15.0+. Any ideas why? Otherwise I will file a bug report with Apple.</p>
  <p>Here is a link to a stripped down, demo project demonstrating the issue. If you run it on iOS 15 on an iPhone that supports haptics (iPhone 8 or later), the custom haptic pattern doesn't play, but it plays just fine on iOS 14:  <a href="https://github.com/WayneYHuang/Core-Haptics-iOS-15-Bug" rel="nofollow noreferrer">link to project</a></p>