speechutils
speechutils copied to clipboard
ArrayIndexOutOfBounds in AbstractAudioRecorder.java
Library crashes when we try to call isPausing() on AudioRecorder
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=1120000; index=1120000 at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.getRms(AbstractAudioRecorder.java:342) at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.getPauseScore(AbstractAudioRecorder.java:252) at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.isPausing(AbstractAudioRecorder.java:220)
I've seen this too. Specifically with newer OS's like Nexus 6P OS: 7.0. My Samsung Galaxy s5 OS 6.0.1 doesn't have this problem. I really like using this library so hopefully its resolved soon. :)
If possible, can you provide more details? Under which conditions does this error occur? Is it easy to reproduce? Which extension of AbstractAudioRecorder are you using (RawAudioRecorder or EncodedAudioRecorder)?
Unfortunately i received a crash report via crashlytics from another user's device (Nexus 6p OS 7.0). So i'll have to wait until tomorrow before i can get my hands on that type of phone for a more detailed report. I'm using AbstractAudioRecorder RawAudioRecorder
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: src.length=2560 srcPos=0 dst.length=1120000 dstPos=87040 length=-1
at java.lang.System.arraycopy(System.java)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.read(AbstractAudioRecorder.java:143)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.recorderLoop(AbstractAudioRecorder.java:321)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder$1.run(AbstractAudioRecorder.java:287)
#0. Crashed: Thread-18: 0 0 0x0000000000000000
at java.lang.System.arraycopy(System.java)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.read(AbstractAudioRecorder.java:143)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.recorderLoop(AbstractAudioRecorder.java:321)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder$1.run(AbstractAudioRecorder.java:287)
I'm using willblashko's AlexaAndroid application https://github.com/willblaschko/AlexaAndroid (within my own application) but tracked the error to this library (although may very well be an error in the AlexaAndroid app)
I've only seen this with OS 7.+, I have a Samsung Galaxy s5 OS 6.0.1 which works fine. The general behavior is that the user speaks into the microphone, stops speaking into the microphone, and followed by a crash. A way to reproduce it is by downloading this application https://play.google.com/store/apps/details?id=com.willblaschko.android.alexavoicelibrary (or clone from git repo above), pressing the microphone button, speaking, finish speaking, and then every now and then it will crash. the report i received suggested that the error originates from the AbstractAudioRecorder class, if you would like i can send the full report via direct message. thanks for getting back so quickly, i'll be able to try more devices with your library directly tomorrow to hopefully narrow this down
10-12 11:19:44.194 15450-20577/com.stefan.project E/AndroidRuntime: FATAL EXCEPTION: Thread-23
Process: com.stefan.project, PID: 15450
java.lang.ArrayIndexOutOfBoundsException: src.length=2560 srcPos=0 dst.length=1120000 dstPos=66560 length=-1
at java.lang.System.arraycopy(Native Method)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.read(AbstractAudioRecorder.java:143)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder.recorderLoop(AbstractAudioRecorder.java:321)
at ee.ioc.phon.android.speechutils.AbstractAudioRecorder$1.run(AbstractAudioRecorder.java:287)
So using nexus 6p OS7.0, i get this error when the microphone stops recording
I could reproduce it now with Kõnele 1.5.20 (which uses speechutils) running on Nexus 5X / Android v7.0. (I did update all the gradle/SDK/buildtools/etc. dependencies first, not sure if this is relevant.) It seems that the problem was that AudioRecord-JNI sometimes returned Error -4 which was not anticipated by speechutils (which is obviously a bug). I guess it started doing that in Android v7.
It should be fixed in a278b8a03cfecc5c51750c545f8b6280da8c3188
Thanks for reporting!
This fixed the issue I was seeing in Android v7, thanks!
I was able to reproduce this again, in the new version. Is it the final iteration of += 2 in the for loop that's throwing the the ArrayIndexOutOfBoundsException?
OK, reopening. The iteration in getRms
does look too complicated and should be refactored anyway.
In case you have any more details on under which conditions this happens, please let me know.
` while (recorder != null && !recorder.isPausing()) { if (recorder != null) { if (sink != null && recorder != null) { sink.write(recorder.consumeRecording()); }
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}`
This is the context withing which the isPausing() is called.
sink is a BufferedSink from okhttp