cinder92 / react-native-get-music-files

React Native package to get music files from local and sd for iOS and Android
MIT License
130 stars 64 forks source link

App Crashes on devices with versions below Marshmallow #27

Closed GermanMontejo closed 6 years ago

GermanMontejo commented 6 years ago

Hi @cinder92 . We experienced an app crash on Android Kitkat (API 19) inside the method: getAll().

We couldn't get the specific line on the stacktrace but we noticed that the error happens inside the new Thread() block. We have managed to bypass the issue by removing the block of code inside the new Thread() block and just let the ContentResolver be executed in the Main Thread.

https://github.com/cinder92/react-native-get-music-files/blob/bd9c9b445a10d311b26bae7207aa2b3b9b501e9c/android/src/main/java/com/reactlibrary/RNReactNativeGetMusicFilesModule.java#L124

When we did that, the App crash ceased to exist. Do you know why this happens? Also, I'm not sure about this, but is it safe to execute a ContentResolver inside a background thread? I think this causes the app crash. Note: We couldn't get the specific line (stacktrace) because the block was inside a thread. We noticed this error showing up though:

E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present

What do you think about this issue?

cinder92 commented 6 years ago

Hello, thanks for submitting issues, yes, it's better to run that code in a separated thread for get info of songs faster and prevent to block UI, I will test on device with KitKat, and check what's happening when I have time

cinder92 commented 6 years ago

fixed on 2.1