fix(export, native, ui): resolve critical data integrity and resource management bugs in PR #122

- Implement comprehensive solo/mute export pipeline in audioEncoder.ts
- Fix duplicate caption IDs by adding chunk-specific indices in handlers.ts
- Prioritize native monitor selection by bounds in monitor_utils.cpp
- Fix alignment for blur annotations extending beyond canvas boundaries
- Resolve timeline selection desync and sidebar visibility for blur annotations
- Fix memory leaks in audio waveform generation with AudioContext cleanup
This commit is contained in:
Mahdy Arief
2026-03-28 06:09:50 +07:00
parent 1bb8eeebfa
commit d5ab86ea44
9 changed files with 82 additions and 54 deletions
+7 -1
View File
@@ -13,12 +13,12 @@ export async function generateWaveform(audioPath: string, samples = 200): Promis
return waveformCache.get(cacheKey)!;
}
const audioContext = new (window.AudioContext || (window as any).webkitAudioContext)();
try {
const response = await fetch(toFileUrl(audioPath));
const arrayBuffer = await response.arrayBuffer();
// Use an offline audio context to decode the data
const audioContext = new (window.AudioContext || (window as any).webkitAudioContext)();
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
const channelData = audioBuffer.getChannelData(0); // Use the first channel
@@ -40,5 +40,11 @@ export async function generateWaveform(audioPath: string, samples = 200): Promis
} catch (error) {
console.error('Failed to generate waveform:', error);
return new Array(samples).fill(0);
} finally {
try {
await audioContext.close();
} catch (e) {
// ignore close errors
}
}
}