fix string building for onNewSegments and getTextSegments#297
fix string building for onNewSegments and getTextSegments#297jiangts wants to merge 1 commit intomybigday:mainfrom
onNewSegments and getTextSegments#297Conversation
|
Thanks for this, I've been debugging this for the past week. |
|
Thanks for the PR! It would be helpful if you could provide a valid test file. Also, note that we will replace all native iOS/Android implementations with RNWhisperJSI in the future, that still decode text segments as utf8. |
|
Can confirm this bug is still present in Root cause: the struct rnwhisper_segments_callback_data *user_data = new rnwhisper_segments_callback_data();
user_data->onNewSegments = [onNewSegments copy];
user_data->tdrzEnable = options[@"tdrzEnable"] && [options[@"tdrzEnable"] boolValue];
user_data->total_n_new = 0;
params.new_segment_callback_user_data = user_data;
// after fullTranscribe returns:
if (params.new_segment_callback_user_data) {
delete (struct rnwhisper_segments_callback_data *)params.new_segment_callback_user_data;
params.new_segment_callback_user_data = nullptr;
}The JFK sample audio from the whisper.rn example app reliably reproduces the crash and could serve as the test file requested above. |
This PR fixes crashes in the iOS implementation
onNewSegments. Tested on0.4.3tag.Key Changes
Improved string handling:
NSStringconcatenation with aNSMutableStringbuilder.nil.onNewSegments callback
@autoreleasepoolto reduce memory pressure inside callback loops.rnwhisper_segments_callback_dataallocation to the heap.isHeapAllocatedflag andcleanup_callback_datahelper to prevent leaks and use-after-free.getTextSegments
resultandsegmentsare always consistent and non-nil.Why
nilvalues into dictionaries.