audio_waveforms
audio_waveforms copied to clipboard
[Android] Crash when decoding .wav file
Describe the bug Title
To Reproduce Use .wav file in audio player
Additional context
E AndroidRuntime: java.lang.IllegalArgumentException
E AndroidRuntime: at android.media.MediaExtractor.readSampleData(Native Method)
E AndroidRuntime: at com.simform.audio_waveforms.WaveformExtractor$startDecode$1$1.onInputBufferAvailable(WaveformExtractor.kt:70)
E AndroidRuntime: at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1824)
E AndroidRuntime: at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1752)
E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:226)
E AndroidRuntime: at android.os.Looper.loop(Looper.java:313)
E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8775)
E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Hey @tneotia, I tried with a sample wav file and it works fine for me. At the point, you are getting error is where native extractor reads sample data. And I guess it is getting some invalid value for your file. So can you please try using some different .wav file.
Hi @ujas-m-simformsolutions here is a sample wav file to reproduce the crash:
https://cdn.discordapp.com/attachments/1079174293981765772/1082707191800279170/VoiceMessage_5.wav
This is playable just fine on my computer, within Discord itself, and thru the Android media player so I don't think there should be any invalid values
Hey @tneotia, I tried your shared wav file and it does crash the app. So I tried increasing the buffer size in native side and it works fine for me. I then tried a bigger file(2.5 MB, yours was only 35 KB) and it works with or without increased buffer size. So can you share how your files are being created so that I try on some other files too.
This file was given to me by a user, I don't really have much details on how it is created apart from it being a voicemail left on a Cisco email. For the user, any voicemail they receive on the email is able to crash the app, so I guess it is something on how Cisco generates the file.
https://thenetworkingcorner.wordpress.com/2011/11/22/delivering-voicemail-to-email-as-attachments-with-cisco-unity-connection-8-5/
Is there a downside to increase the buffer size by default? Which will fix this problem.
I think we have to find a solution where it automatically finds optimal amount of buffer required to decode the audio. And to answer your question increasing buffer size might consume more RAM.
Maybe allow the developer to set buffer size to use in parameters in Dart?
....