Fix audio permission handling on iOS startup - #163
Merged
Conversation
…unloaded properly
Contributor
There was a problem hiding this comment.
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 |
riderodd
disabled auto-merge
November 17, 2025 20:45
Contributor
There was a problem hiding this comment.
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];
riderodd
enabled auto-merge (squash)
November 17, 2025 20:51
riderodd
disabled auto-merge
November 17, 2025 20:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-voskdependency version.