cmusphinx / pocketsphinx-android-demo

This is a demonstration for Pocketsphinx on Android
http://cmusphinx.sourceforge.net/wiki/tutorialandroid
BSD 2-Clause "Simplified" License
547 stars 364 forks source link

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

Open willblaschko opened 8 years ago

willblaschko commented 8 years ago

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)
mbait commented 8 years ago

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.

willblaschko commented 8 years ago

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).

mbait commented 8 years ago

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.

willblaschko commented 8 years ago

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 commented 8 years ago

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.

mbait commented 8 years ago

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 notifications@github.com 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