Skip to content

Fix audio permission handling on iOS startup - #163

Merged
riderodd merged 3 commits into
mainfrom
fix/ios-permissions-mic
Nov 17, 2025
Merged

Fix audio permission handling on iOS startup#163
riderodd merged 3 commits into
mainfrom
fix/ios-permissions-mic

Conversation

@riderodd

Copy link
Copy Markdown
Owner

Implement lazy initialization for the audio engine to prevent the microphone permission prompt at startup. Ensure proper unloading of the model and reset relevant flags for restarting. Update the react-native-vosk dependency version.

Copilot AI review requested due to automatic review settings November 17, 2025 20:40
@riderodd
riderodd enabled auto-merge (squash) November 17, 2025 20:41
@riderodd riderodd self-assigned this Nov 17, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements lazy initialization for the audio engine components to prevent triggering the microphone permission prompt when the module loads. The changes also improve error handling and state management for restart scenarios.

  • Moved audio engine initialization from module init to the start method
  • Added proper flag reset in error paths to allow restart after failures
  • Improved cleanup in stopInternalWithoutEvents with defensive nil checks
  • Updated package version to 2.1.6

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
ios/Vosk.mm Implements lazy initialization of AVAudioEngine and related components, moves initialization from init() to start() method, adds _isStarting flag resets in error paths, improves state reset in unload and stopInternalWithoutEvents
example/ios/Podfile.lock Updates react-native-vosk dependency from 2.1.5 to 2.1.6, reflects checksums and CocoaPods version changes

Comment thread ios/Vosk.mm Outdated
@riderodd
riderodd disabled auto-merge November 17, 2025 20:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

ios/Vosk.mm:175

  • _formatInput is initialized inside the permission callback but is set to nil during lazy initialization. This means _formatInput will only be set after the first successful start. However, the code accesses _formatInput without checking if it's nil after lazy initialization. Consider initializing _formatInput along with _inputNode in the lazy initialization block (lines 102-104) to ensure it's always available when the audio engine is initialized.
  self->_formatInput = [self->_inputNode inputFormatForBus:0];

Comment thread CHANGELOG.md
@riderodd
riderodd enabled auto-merge (squash) November 17, 2025 20:51
@riderodd
riderodd disabled auto-merge November 17, 2025 20:51
@riderodd
riderodd merged commit 970d3d5 into main Nov 17, 2025
14 checks passed
@riderodd
riderodd deleted the fix/ios-permissions-mic branch November 17, 2025 20:55
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.

2 participants