android-openslmediaplayer
android-openslmediaplayer copied to clipboard
Device compatibility
I'm having quite a few issues with crashes in the library, only seems to be affecting cheaper brand phones like Azumi, Gionee etc. Its widespread though. All the errors are the same.
If I use the standard player its fine but using hybrid always gets this error. Any idea what is causing it? Is there any clean way to fall back to the standard player if hybrid doesn't work?
OS Version: 4.2.2 Device: Azumi A35S com.h6ah4i.android.media.opensl.OpenSLMediaPlayer.parseResultAndThrowException(SourceFile:1027) at com.h6ah4i.android.media.opensl.OpenSLMediaPlayer.prepare(SourceFile:221) at com.muziko.mediaplayer.MuzikoPlayer.prepare(SourceFile:184) at com.muziko.MyApplication.loadQueue(SourceFile:1042) at com.muziko.receivers.MediaMountedReceiver.onReceive(SourceFile:34) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2550) at android.app.ActivityThread.access$1500(ActivityThread.java:162) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1440) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5392) at java.lang.reflect.Method.invokeNative(Method.java) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(NativeStart.java)
Hi. Thanks for the issue report. I guess that would be a memory allocation failure somewhere in the native layer, because Azumi A35S has only 512 MiB RAM.
P.S. I just bought an Asus Z200 (Android 4.4, 512 MiB RAM), so I'll take it a look at it on this weekend ;)
@blocke79 First, I want to evaluate my Z200 whether it can reproduce the same issue. Does Muziko Music Player v1.0.21 crash due to this failure? If not, could you sent me an APK file which can reproduce it?
Great. I've sent you an email with a link to an APK with the issue.
Seems to be devices with lower memory. Had a crash on a Samsung Galaxy J7. They have 1.5Gb but it only has 25% free at the time.
@blocke79 Hi. I am trying to reproduce this issue today, but unfortunately I have not able to reproduce it yet on my Z200. Do you know any other conditions about it?
Also I want to know...
- Media file format (MP3, M4A, OGG, FLAC, WAV, ...)
- Sampling rate
- Number of channels
P.S. I found several issues on Muziko Media Player v1.0.20 while debugging.
1. NullPointerException
The app crashed due to NullPointerException. I met this only twice, so I am not sure how to reproduce it.
E/AndroidRuntime(11909): FATAL EXCEPTION: main
E/AndroidRuntime(11909): Process: com.muziko, PID: 11909
E/AndroidRuntime(11909): java.lang.RuntimeException: Unable to start service com.muziko.service.SongService@42231b90 with Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.muziko/.activities.splash.LoaderActivity bnds=[357,458][459,608] }: java.lang.NullPointerException
E/AndroidRuntime(11909): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2885)
E/AndroidRuntime(11909): at android.app.ActivityThread.access$2100(ActivityThread.java:151)
E/AndroidRuntime(11909): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1418)
E/AndroidRuntime(11909): at android.os.Handler.dispatchMessage(Handler.java:110)
E/AndroidRuntime(11909): at android.os.Looper.loop(Looper.java:193)
E/AndroidRuntime(11909): at android.app.ActivityThread.main(ActivityThread.java:5299)
E/AndroidRuntime(11909): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11909): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(11909): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
E/AndroidRuntime(11909): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
E/AndroidRuntime(11909): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(11909): Caused by: java.lang.NullPointerException
E/AndroidRuntime(11909): at com.muziko.service.SongService.cancelNotification(SourceFile:1636)
E/AndroidRuntime(11909): at com.muziko.service.SongService.onTaskRemoved(SourceFile:240)
E/AndroidRuntime(11909): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2870)
E/AndroidRuntime(11909): ... 10 more
2. Context leaks
I found that Activity instances are not garage collected properly. It causes huge amount of memory leaks and triggers OOM killer.
It can be quickly checked by the following command.
adb shell dumpsys meminfo com.muziko
Here is the output right after the player app launched.
Applications Memory Usage (kB):
Uptime: 38984419 Realtime: 71289210
** MEMINFO in pid 12469 [com.muziko] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 11060 10266 245
Dalvik Heap 4932 4680 0 2640 12096 8873 3223
Dalvik Other 2935 2680 0 1104
Stack 152 152 0 8
Ashmem 260 0 0 0
Other dev 6 0 4 0
.so mmap 5223 1100 3560 2528
.apk mmap 559 0 264 0
.dex mmap 6908 112 5520 188
Other mmap 74 4 48 0
Unknown 8507 8492 0 620
TOTAL 29556 17220 9396 7088 23156 19139 3468
Objects
Views: 51 ViewRootImpl: 1
AppContexts: 6 Activities: 2
Assets: 5 AssetManagers: 5
Local Binders: 16 Proxy Binders: 24
Death Recipients: 0
OpenSSL Sockets: 2
SQL
MEMORY_USED: 0
PAGECACHE_OVERFLOW: 0 MALLOC_SIZE: 0
Asset Allocations
zip:/data/app/com.muziko-1.apk:/assets/Fonts/Roboto-Regular.ttf: 123K
After repeating the following operation 10 times;
- Open Now Playing screen (click the bottom sheet)
- Tap BACK key
Applications Memory Usage (kB):
Uptime: 39173571 Realtime: 71478362
** MEMINFO in pid 12469 [com.muziko] **
Pss Private Private Swapped Heap Heap Heap
Total Dirty Clean Dirty Size Alloc Free
------ ------ ------ ------ ------ ------ ------
Native Heap 0 0 0 0 22936 19411 272
Dalvik Heap 23026 22796 0 2636 28440 27435 1005
Dalvik Other 4993 4704 0 808
Stack 556 556 0 8
Ashmem 1012 752 0 0
Other dev 10 0 8 0
.so mmap 13123 1532 5624 1320
.jar mmap 4 0 0 0
.apk mmap 696 0 344 0
.ttf mmap 345 0 264 0
.dex mmap 9044 204 6048 136
Other mmap 659 4 76 0
Unknown 23718 23676 0 188
TOTAL 77186 54224 12364 5096 51376 46846 1277
Objects
Views: 762 ViewRootImpl: 5
AppContexts: 16 Activities: 12
Assets: 5 AssetManagers: 5
Local Binders: 53 Proxy Binders: 40
Death Recipients: 0
OpenSSL Sockets: 2
SQL
MEMORY_USED: 91
PAGECACHE_OVERFLOW: 16 MALLOC_SIZE: 62
DATABASES
pgsz dbsz Lookaside(b) cache Dbname
4 16 59 1/25/2 /data/data/com.muziko/databases/evernote_jobs.db
Asset Allocations
zip:/data/app/com.muziko-1.apk:/assets/Fonts/Roboto-Regular.ttf: 123K
Summary of the important metric changes:
| metrics | before | after |
|---|---|---|
AppContexts |
6 | 16 |
Native Heap |
11 MiB | 23 MiB |
Dalvik Heap |
12 MiB | 28 MiB |
@blocke79 Hi. Any updates on this?
Hi,
Sorry about the delay. I'm trying to get the user who has the crash with Muziko to try the sample application and see if it still occurs.
Will let you know how that goes.
I wonder this issue has gone in the latest v0.7.2. Because I made some fixes/improvements after the v0.7.0 release.
Support various sample rates of source media file
- Support 176.4 k and 192 kHz media playback (v0.7.2; d7b00c7f67a911f168d85db880017550b539126a)
- Support 11.025 k, 12 k, 22.05 k and 24 kHz media playback (v0.7.1; a6fba9c5af7d25ca39ca8f9a23cadbd0c8023dd6)
I guess IllegalStateException("Internal error") was caused when trying to play unsupported sample rate media files.
Better error handling of prepare() method
- Improve error handling of
prepare()method not just raiseOSLMP_RESULT_INTERNAL_ERROR(v0.7.2; 9546996b30c2812e0ba1ea55b9f3fc3816a2486d)
Since v0.7.2, prepare() method may raises several type of exceptions other than IllegalStateException("Internal error"). Here is the method which dispatches exceptions according to internal error code;
private static void parseResultAndThrowException(int result) throws IOException {
switch (result) {
case Internal.RESULT_SUCCESS:
break;
case Internal.RESULT_ERROR:
throw new IllegalStateException("General error");
case Internal.RESULT_INVALID_HANDLE:
throw new IllegalStateException("Invalid handle");
case Internal.RESULT_ILLEGAL_STATE:
throw new IllegalStateException("Method is called in unexpected state");
case Internal.RESULT_ILLEGAL_ARGUMENT:
throw new IllegalArgumentException("Illegal argument error occurred in native layer");
case Internal.RESULT_INTERNAL_ERROR:
throw new IllegalStateException("Internal error");
case Internal.RESULT_MEMORY_ALLOCATION_FAILED:
throw new IllegalStateException("Failed to allocate memory in native layer");
case Internal.RESULT_RESOURCE_ALLOCATION_FAILED:
throw new IllegalStateException("Failed to allocate resources in native layer");
case Internal.RESULT_CONTENT_NOT_FOUND:
throw new IOException("Content not found");
case Internal.RESULT_CONTENT_UNSUPPORTED:
throw new IOException("Unsupported content");
case Internal.RESULT_IO_ERROR:
throw new IOException("I/O error");
case Internal.RESULT_PERMISSION_DENIED:
throw new IOException("Permission denied");
case Internal.RESULT_TIMED_OUT:
throw new IllegalStateException("Timed out");
case Internal.RESULT_CONTROL_LOST:
throw new UnsupportedOperationException("Control lost");
case Internal.RESULT_IN_ERROR_STATE:
/* don't throw any exceptions */
break;
case Internal.RESULT_DEAD_OBJECT:
throw new IllegalStateException("Dead object");
default:
throw new IllegalStateException(
"Unexpected error (0x" + Integer.toHexString(result) + ")");
}
}
Ok thanks. I'll create a new sample package based on the latest release and get the users to try that one.