pocketsphinx-android-demo icon indicating copy to clipboard operation
pocketsphinx-android-demo copied to clipboard

Library crashes on Samsung gt i9195 - Galaxy Mini (Android 6.0.1)

Open willblaschko opened this issue 8 years ago • 6 comments

Crash below, it looks like it's failing to properly grab the external files dir.

Non-fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
       at android.app.ContextImpl.getExternalFilesDir(ContextImpl.java:468)
       at android.content.ContextWrapper.getExternalFilesDir(ContextWrapper.java:219)
       at edu.cmu.pocketsphinx.Assets.<init>(Assets.java:95)
       at com.willblaschko.android.alexalistens.MainActivity$SettingsFragment$6.doInBackground(MainActivity.java:253)
       at com.willblaschko.android.alexalistens.MainActivity$SettingsFragment$6.doInBackground(MainActivity.java:245)
       at android.os.AsyncTask$2.call(AsyncTask.java:295)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at java.lang.Thread.run(Thread.java:818)

willblaschko avatar May 26 '16 06:05 willblaschko

This stems from the Android sources and isn't the project's bug - we, obviously, can't check for every single possible bug that Android developers introduce.

mbait avatar May 26 '16 21:05 mbait

Nor am I requesting such a thing, I was wondering if there's something different that can be done in the Assets() init, if not, I'll just wrap it with a try/catch. Mostly I just wanted to let your team know about the crash (since I don't know how often you get bug reports).

willblaschko avatar May 26 '16 21:05 willblaschko

Sure, thanks for the feedback! Probably it's worth to check why that happens, because Android docs say nothing about possible absence of the external storage. Also, if it doesn't exist it doesn't make sense to call to Assets because it basically unpacks models files on the external storage, and if the storage doesn't exist, there's nothing to unpack.

mbait avatar May 26 '16 21:05 mbait

Agreed. So based on the documentation I see: "Shared storage may not always be available, since removable media can be ejected by the user. Media state can be checked using getExternalStorageState(File)." Perhaps this is what causes that out of bounds exception?

willblaschko avatar May 26 '16 21:05 willblaschko

I've only seen this crash happen to one user on one device, so who knows what modded firmware they are using. If you want to address this particular issue, it's probably low priority.

willblaschko avatar May 26 '16 21:05 willblaschko

According to this code https://github.com/cmusphinx/pocketsphinx-android/blob/master/src/main/java/edu/cmu/pocketsphinx/Assets.java#L95 getExternalStorageDir probably used to return null in case of failure. We can issue a quick patch that fixes the issue by examining the output of getExternalStorageState.

On Thu, May 26, 2016 at 2:31 PM, Will Blaschko [email protected] wrote:

I've only seen this crash happen to one user on one device, so who knows what modded firmware they are using. If you want to address this particular issue, it's probably low priority.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/cmusphinx/pocketsphinx-android-demo/issues/19#issuecomment-222000817

Sincerely, Alexander

mbait avatar May 26 '16 21:05 mbait