debug: true prevents first haptic trigger on iOS Safari
Description
When using createWebHaptics({ debug: true }), the first haptic trigger doesn't work on iOS Safari. The second and all subsequent triggers work fine.
Steps to Reproduce
- Initialize:
const haptics = createWebHaptics({ debug: true });
- Trigger on click:
haptics.trigger([{ duration: 50 }]);
- Tap button after page load
Expected Behavior
Haptic fires on first tap
Actual Behavior
First tap has no haptic, second tap works
Workaround
Use debug: false - then first tap works correctly.
Root Cause
iOS Safari requires audio elements to be "unlocked" within a direct user interaction event. The debug logging appears to introduce enough delay that iOS considers the haptic trigger too late, causing it to be rejected on the first interaction. The second tap works because the audio element is already unlocked.
debug: trueprevents first haptic trigger on iOS SafariDescription
When using
createWebHaptics({ debug: true }), the first haptic trigger doesn't work on iOS Safari. The second and all subsequent triggers work fine.Steps to Reproduce
const haptics = createWebHaptics({ debug: true });haptics.trigger([{ duration: 50 }]);Expected Behavior
Haptic fires on first tap
Actual Behavior
First tap has no haptic, second tap works
Workaround
Use
debug: false- then first tap works correctly.Root Cause
iOS Safari requires audio elements to be "unlocked" within a direct user interaction event. The debug logging appears to introduce enough delay that iOS considers the haptic trigger too late, causing it to be rejected on the first interaction. The second tap works because the audio element is already unlocked.