Skip to content

fix: ios record on simulator - #158

Merged
riderodd merged 2 commits into
mainfrom
fix/ios-record-on-sim
Sep 12, 2025
Merged

fix: ios record on simulator#158
riderodd merged 2 commits into
mainfrom
fix/ios-record-on-sim

Conversation

@riderodd

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings September 12, 2025 15:33
@riderodd
riderodd merged commit f2b1496 into main Sep 12, 2025
7 checks passed
@riderodd
riderodd deleted the fix/ios-record-on-sim branch September 12, 2025 15:33

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 PR fixes iOS simulator recording issues by implementing a retry mechanism for audio tap installation, addressing format availability timing problems that commonly occur on iOS simulators.

  • Refactored the audio tap installation to use a retry-based approach with proper error handling
  • Added new instance variables to track retry state and prevent concurrent tap installations
  • Moved audio engine startup to occur before tap installation to ensure proper format availability

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
package.json Version bump from 2.1.5 to 2.1.6
ios/Vosk.mm Major refactoring of tap installation logic with retry mechanism and improved error handling
CHANGELOG.md Added changelog entry for version 2.1.6 with multiple fixes and features

Comment thread ios/Vosk.mm
int dataLen = (int)(frames * sizeof(int16_t));
accepted = vosk_recognizer_accept_waveform(recognizer, (const char *)pcm16.data(), (int32_t)dataLen);
} else { return; }
const char *cstr = NULL; BOOL isFinal = NO; if (accepted) { cstr = vosk_recognizer_result(recognizer); isFinal = YES; } else { cstr = vosk_recognizer_partial_result(recognizer); }

Copilot AI Sep 12, 2025

Copy link

Choose a reason for hiding this comment

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

These lines contain extremely long single-line statements that are difficult to read and maintain. The original multi-line formatting should be preserved for better code readability and debugging.

Suggested change
const char *cstr = NULL; BOOL isFinal = NO; if (accepted) { cstr = vosk_recognizer_result(recognizer); isFinal = YES; } else { cstr = vosk_recognizer_partial_result(recognizer); }
const char *cstr = NULL;
BOOL isFinal = NO;
if (accepted) {
cstr = vosk_recognizer_result(recognizer);
isFinal = YES;
} else {
cstr = vosk_recognizer_partial_result(recognizer);
}

Copilot uses AI. Check for mistakes.
Comment thread ios/Vosk.mm
} else { return; }
const char *cstr = NULL; BOOL isFinal = NO; if (accepted) { cstr = vosk_recognizer_result(recognizer); isFinal = YES; } else { cstr = vosk_recognizer_partial_result(recognizer); }
NSString *json = cstr ? [NSString stringWithUTF8String:cstr] : nil;
dispatch_async(dispatch_get_main_queue(), ^{ if (!json) return; NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *parsed = data ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : nil; if (![parsed isKindOfClass:[NSDictionary class]]) { if (isFinal) { [self emitOnResult:json]; } else { [self emitOnPartialResult:json]; } return; } NSString *text = parsed[@"text"]; NSString *partial = parsed[@"partial"]; if (isFinal) { if (text.length > 0) { [self emitOnResult:text]; } self->_lastPartial = nil; } else { if (partial.length > 0 && (!self->_lastPartial || ![self->_lastPartial isEqualToString:partial])) { [self emitOnPartialResult:partial]; } self->_lastPartial = partial ?: self->_lastPartial; } });

Copilot AI Sep 12, 2025

Copy link

Choose a reason for hiding this comment

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

These lines contain extremely long single-line statements that are difficult to read and maintain. The original multi-line formatting should be preserved for better code readability and debugging.

Suggested change
dispatch_async(dispatch_get_main_queue(), ^{ if (!json) return; NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *parsed = data ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : nil; if (![parsed isKindOfClass:[NSDictionary class]]) { if (isFinal) { [self emitOnResult:json]; } else { [self emitOnPartialResult:json]; } return; } NSString *text = parsed[@"text"]; NSString *partial = parsed[@"partial"]; if (isFinal) { if (text.length > 0) { [self emitOnResult:text]; } self->_lastPartial = nil; } else { if (partial.length > 0 && (!self->_lastPartial || ![self->_lastPartial isEqualToString:partial])) { [self emitOnPartialResult:partial]; } self->_lastPartial = partial ?: self->_lastPartial; } });
dispatch_async(dispatch_get_main_queue(), ^{
if (!json) return;
NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *parsed = data ? [NSJSONSerialization JSONObjectWithData:data options:0 error:nil] : nil;
if (![parsed isKindOfClass:[NSDictionary class]]) {
if (isFinal) {
[self emitOnResult:json];
} else {
[self emitOnPartialResult:json];
}
return;
}
NSString *text = parsed[@"text"];
NSString *partial = parsed[@"partial"];
if (isFinal) {
if (text.length > 0) {
[self emitOnResult:text];
}
self->_lastPartial = nil;
} else {
if (partial.length > 0 && (!self->_lastPartial || ![self->_lastPartial isEqualToString:partial])) {
[self emitOnPartialResult:partial];
}
self->_lastPartial = partial ?: self->_lastPartial;
}
});

Copilot uses AI. Check for mistakes.
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