audio_waveforms icon indicating copy to clipboard operation
audio_waveforms copied to clipboard

Looks like extractWaveformData in WaveformExtractionController gets stuck when using await

Open MorningStarJ opened this issue 6 months ago • 1 comments

Describe the bug The callbacks onCurrentExtractedWaveformData and onExtractionProgress are working as expected, but when using await on extractWaveformData(), it neither throws an error nor returns — it just gets stuck To Reproduce

final waveformExtraction = WaveformExtractionController();
  final style = PlayerWaveStyle(waveThickness: 0.5, spacing: 1);
  final samples = style.getSamplesForWidth(5 * duration * 2);
  try {
    waveformExtraction.onCurrentExtractedWaveformData.listen((data) {
      debugLog("data: $data");
    }); // Provides latest data while extracting the waveforms.
    waveformExtraction.onExtractionProgress.listen((progress) {
      debugLog("progress: $progress");
    }); // Provides progress of the waveform extractions.

    final waveformData = await waveformExtraction.extractWaveformData(
      path: path,
      noOfSamples: samples,
    );
    debugLog("waveformData: $waveformData");
  } catch (e, stackTrace) {
    debugLog("error: $e");
    debugLog("stackTrace: $stackTrace");
  }

Expected behavior Make sure extractWaveformData returns correctly after finishing

Smartphone (please complete the following information):

  • Device: [iPhone 16 Pro]
  • OS: [iOS18.4]
  • audio_waveforms branch: main
  • Flutter version 3.29.2 on channel stable
  • Dart version 3.7.2

MorningStarJ avatar Jun 03 '25 11:06 MorningStarJ

Hello, new version available when with this issue fixed?

gunatitsolutions avatar Jun 14 '25 05:06 gunatitsolutions

The extracting waveform is asynchronous process and it handled via call back in native so it looks like the result is never getting back to flutter because function's scope is over.

ujas-m-simformsolutions avatar Jul 20 '25 17:07 ujas-m-simformsolutions

@gunatitsolutions

Hello, new version available when with this issue fixed?

We can not estimate timeline but you can use onCurrentExtractedWaveformData in combination with onExtractionProgress as workaround for now

ujas-m-simformsolutions avatar Jul 20 '25 17:07 ujas-m-simformsolutions

That method takes too long. How can we get wavedata quickly? video

inamhusain avatar Aug 13 '25 07:08 inamhusain

+1

mrafieefard avatar Nov 06 '25 12:11 mrafieefard

That method takes too long. How can we get wavedata quickly? video

@inamhusain Since waveform extraction happens on device, it depends on platform, size of the audio file, and how powerful device is. In general ios should be faster than android.

ujas-m-simformsolutions avatar Nov 11 '25 11:11 ujas-m-simformsolutions