No Vibration Feedback
Issue: Device doesn’t vibrate when calling trigger()
Check browser support
Check browser support
Diagnosis:Solution:
- Verify
WebHaptics.isSupportedreturnstrue - iOS browsers never support vibration (see Browser Support)
- Desktop browsers may support the API but lack hardware
Verify secure context
Verify secure context
Diagnosis:Solution:
- Use HTTPS in production
- Localhost works without HTTPS in development
- The Vibration API is blocked on
http://pages (except localhost)
Ensure user interaction
Ensure user interaction
Problem: Calling
trigger() on page load or from async code without user gesture.Solution:Some browsers require vibration to be triggered within a user gesture context. Always call
trigger() synchronously in event handlers when possible.Check device settings
Check device settings
User-level issues:
- Device is in silent/vibrate-off mode
- Battery saver mode may disable vibration
- Accessibility settings might override haptics
- Do Not Disturb mode can suppress vibration
Intensity Not Working
Issue: All vibrations feel the same strength
Understand PWM limitations
Understand PWM limitations
How it works:
WebHaptics uses 20ms on/off cycles to simulate intensity:
- Intensity 1.0: Continuous vibration
- Intensity 0.5: 10ms on, 10ms off (50% duty cycle)
- Intensity 0.25: 5ms on, 15ms off (25% duty cycle)
- Hardware inertia: Vibration motors take time to spin up/down
- Perception threshold: Below ~30% intensity, pulses may feel identical
- Device quality: Cheap motors lack responsiveness
Test with debug mode
Test with debug mode
Diagnosis:Debug mode produces audio feedback with pitch variations:
- Higher intensity = higher pitch click sound
- Listen for pitch changes to verify intensity is being processed
Try longer durations
Try longer durations
Problem: Short vibrations don’t show intensity differences.Solution: Use 200ms+ durations to make PWM patterns perceptible:
Check intensity clamping
Check intensity clamping
Code reference: index.ts:96-99Intensity is clamped to [0, 1]:Values outside this range are silently corrected:
intensity: 2.0→1.0intensity: -0.5→0.0
Intensity is a decimal between 0.0 and 1.0, not a percentage (0-100).
Debug Mode Issues
Issue: Debug overlay not appearing
Enable showSwitch option
Enable showSwitch option
Problem: Label is hidden by default.Solution:Without
showSwitch: true, the debug label exists in the DOM but is hidden (display: none).Check DOM availability
Check DOM availability
Problem: Creating instance in SSR/Node.js environment.Solution:The library checks for
document internally (index.ts:410), but won’t crash. Debug features simply won’t activate.Verify trigger calls
Verify trigger calls
Problem: Debug mode enabled but no feedback on trigger.Diagnosis:If no output: Check for JavaScript errors in console. The
trigger method might be failing silently.Issue: No audio in debug mode
Audio context suspended
Audio context suspended
Problem: Browsers suspend AudioContext until user interaction.Solution: First trigger must be in event handler:See
ensureAudio() method (index.ts:379-406) for audio initialization logic.Browser compatibility
Browser compatibility
Issue: AudioContext not supported.Check:Support: All modern browsers support AudioContext, but very old browsers (IE11) do not. Debug audio will be skipped silently.
Pattern Not Working
Issue: Custom patterns don’t trigger
Validate pattern format
Validate pattern format
Common mistakes:Validation code: index.ts:174-187Invalid patterns log a warning and abort:
Check duration limits
Check duration limits
Max duration: 1000ms per vibration phase (MAX_PHASE_MS constant, index.ts:11)Vibrations exceeding 1000ms are silently clamped (index.ts:175).
Preset not found
Preset not found
Issue: Unknown preset name.Console warning:Solution: Use valid preset names (
click, success, error, warning, notification) or define custom patterns. See available presets in the patterns file.Instance Management
Issue: Multiple instances causing conflicts
Overlapping triggers
Overlapping triggers
Problem: Creating multiple WebHaptics instances and triggering simultaneously.Behavior:
- Each instance has its own debug overlay (incremental IDs)
navigator.vibrate()calls from different instances overwrite each other- Last call wins
Memory leaks
Memory leaks
Problem: Creating instances without cleanup.Solution: Call The
destroy() when done:destroy() method (index.ts:230-244):- Cancels active patterns
- Removes debug overlay
- Closes AudioContext
- Clears references
Performance Issues
Issue: Lag or dropped vibrations
Too many rapid triggers
Too many rapid triggers
Problem: Calling The
trigger() faster than patterns complete.Solution: Wait for completion:trigger() method returns a Promise that resolves when the pattern completes.Complex patterns on slow devices
Complex patterns on slow devices
Problem: PWM modulation creates long arrays for low intensities.Example: 1000ms at 0.1 intensity generates 50 on/off segments:Solution:
- Use shorter durations with delays for rhythm instead of one long vibration
- Avoid very low intensities (<0.2) on long durations
- Consider intensity >= 0.5 for smoother performance
Getting Help
If issues persist after troubleshooting:- Enable debug mode and check console for warnings
- Test on multiple devices to isolate hardware vs. software issues
- Check browser console for errors or security warnings
- Review source code for implementation details (especially index.ts:60-82 for PWM, index.ts:155-156 for support detection)
- Report bugs with:
- Browser and version
- Device model
- Code snippet to reproduce
- Console output
For browser-specific issues, test in debug mode first. The visual/audio feedback helps isolate whether the library is processing triggers correctly even if haptics don’t work.