Skip to content

Conversation

GorkaMinus
Copy link

Fix: Prevent iOS app freeze by reusing CHHapticEngine instance

This PR addresses an issue where calling Haptics.vibrate() rapidly (e.g., from a fast-scrolling picker in my case) causes the app to hang or crash on iOS. The problem stems from creating a new CHHapticEngine instance on each call, which leads to excessive thread creation and eventual system overload.

Solution

  • Reuses a single CHHapticEngine instance across multiple vibration calls.
  • Ensures the engine is only created and started when necessary.
  • Handles engine lifecycle and failure states gracefully.

This fix improves performance and stability, especially in high-frequency vibration scenarios.

Related Issue #1960

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant