Author Topic: BASS for Android  (Read 479146 times)

liuhen1001

  • Posts: 2
Re: BASS for Android
« Reply #1475 on: 12 Nov '18 - 08:35 »
   signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

_ZNK7android16SortedVectorImpl13_indexOrderOfEPKvPj

 #00  pc 00000000000101f2  /system/lib/libutils.so (_ZNK7android16SortedVectorImpl13_indexOrderOfEPKvPj+23)
  #01  pc 000000000001a34b  /system/lib/libstagefright_foundation.so
  #02  pc 000000000001a60d  /system/lib/libstagefright_foundation.so (_ZNK7android8MetaData8findDataEjPjPPKvS1_+28)
  #03  pc 000000000001a5b1  /system/lib/libstagefright_foundation.so (_ZN7android8MetaData11findCStringEjPPKc+24)
  #04  pc 00000000001037cf  /system/lib/libstagefright.so (_ZNK7android16NuMediaExtractor14getTrackFormatEjPNS_2spINS_8AMessageEEEj+190)
  #05  pc 0000000000028783  /system/lib/libmedia_jni.so (_ZNK7android15JMediaExtractor14getTrackFormatEjPP8_jobject+26)
  #06  pc 0000000000028c8d  /system/lib/libmedia_jni.so
  #07  pc 0000000001b38391  /system/framework/arm/boot-framework.oat (android.media.MediaExtractor.getTrackFormatNative+84)
  #08  pc 0000000001b3908f  /system/framework/arm/boot-framework.oat (android.media.MediaExtractor.getTrackFormat+74)
  #09  pc 00000000000a94c1  /system/lib/libart.so (art_quick_invoke_stub_internal+64)
  #10  pc 0000000000403e39  /system/lib/libart.so (art_quick_invoke_stub+232)
  #11  pc 00000000000b0795  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+136)
  #12  pc 0000000000314799  /system/lib/libart.so (_ZN3artL18InvokeWithArgArrayERKNS_33ScopedObjectAccessAlreadyRunnableEPNS_9ArtMethodEPNS_8ArgArrayEPNS_6JValueEPKc+56)
  #13  pc 0000000000315749  /system/lib/libart.so (_ZN3art35InvokeVirtualOrInterfaceWithVarArgsERKNS_33ScopedObjectAccessAlreadyRunnableEP8_jobjectP10_jmethodIDSt9__va_list+256)
  #14  pc 0000000000265487  /system/lib/libart.so (_ZN3art3JNI17CallObjectMethodVEP7_JNIEnvP8_jobjectP10_jmethodIDSt9__va_list+442)

   

Ian @ un4seen

  • Administrator
  • Posts: 21370
Re: BASS for Android
« Reply #1476 on: 12 Nov '18 - 13:40 »
The crash appears to have been in a MediaExtractor.getTrackFormat call. Is that the full call stack? There is no mention of BASS in it, but BASS's Android codec support does involve a MediaExtractor.getTrackFormat call, so that could be the call, or perhaps you are calling MediaExtractor.getTrackFormat yourself? In either case, please identify the file that the crash is happening with, and upload it to have a look at here:

   ftp.un4seen.com/incoming/

liuhen1001

  • Posts: 2
Re: BASS for Android
« Reply #1477 on: 13 Nov '18 - 01:53 »
This crash happened 67 times on Android7.0,it feedback from GooglePlay,  and I don't get that file. There are two other crashes:
1、signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) libbass.so
backtrace:
  #00  pc 000000000000bade  /lib/arm/libbass.so
  #01  pc 0000000000027f05  /lib/arm/libbass.so (BASS_ChannelGetData+844)
  #02  pc 000000000002817f  /lib/arm/libbass.so (Java_com_un4seen_bass_BASS_BASS_1ChannelGetData+46)
  #03  pc 0000000000074391  /oat/arm/base.odex
Android 7.0   18   29.0%
Android 7.1   15   24.2%
Android 8.1   12   19.4%
Android 6.0   9   14.5%
Android 8.0   8   12.9%

3、signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) libbass.so
backtrace:
  #00  pc 0000000000018790 /lib/arm/libbass.so
  #01  pc 00000000fffffffd  <unknown>
Android 8.0   52   100.0%

Ian @ un4seen

  • Administrator
  • Posts: 21370
Re: BASS for Android
« Reply #1478 on: 14 Nov '18 - 14:49 »
The first crash is in a BASS_ChannelGetData call. Please post all of the BASS_ChannelGetData calls in your app, to see what parameters you are using. Also confirm what BASS version was used when the crashes happened. From the offsets in your call stacks, it looks like it isn't the latest version (from the package in the 1st post). If that is the case, please try upgrading to the latest and see if the crashes still happen then (and post the new call stacks).

Nicholas

  • Posts: 5
Re: BASS for Android
« Reply #1479 on: 6 Dec '18 - 11:25 »
We've seen a few ANRs come in from Google Play recently that suggest BASS_Pause (which we call when our native activity receives APP_CMD_LOST_FOCUS) is hanging:

  #00  pc 0000000000018e54  /system/lib/libc.so (syscall+28)
  #01  pc 0000000000048fc1  /system/lib/libc.so (_ZL33__pthread_mutex_lock_with_timeoutP24pthread_mutex_internal_tbPK8timespec+516)
  #02  pc 0000000000012ccb  /lib/arm/libbass.so (?)
  #03  pc 000000000001c1cd  /lib/arm/libbass.so (?)
  #04  pc 00000000000277a1  /lib/arm/libbass.so (BASS_Pause+10)
 
None of the other threads showed anything with BASS in their call stacks, so I'm not sure what's going on with that mutex lock.

This was with BASS version 0x204 0D1D.

Should we be doing something different on APP_CMD_LOST_FOCUS instead of trying to pause?  Thanks!

kenumir

  • Posts: 15
Re: BASS for Android
« Reply #1480 on: 6 Dec '18 - 13:51 »
Last time in automatic beta test in play store we have this error:

Code: [Select]
Build fingerprint: 'google/sailfish/sailfish:8.0.0/OPR3.170623.013/4397526:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 12005, tid: 24105, name: BassPlayer Star  >>> <my.app.package> <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'indirect_reference_table.cc:56] JNI ERROR (app bug): attempt to remove stale Global 0x39 (should be 0x36)'
    x0   0000000000000000  x1   0000000000005e29  x2   0000000000000006  x3   0000000000000008
    x4   00000075b75a9000  x5   00000075b75a9000  x6   00000075b75a9000  x7   0000000000000000
    x8   0000000000000083  x9   46d6a3be34fea054  x10  0000000000000000  x11  0000000000000001
    x12  ffffffffffffffff  x13  ffffffffa3fd43d2  x14  0000000006b576a8  x15  000000003b9aca00
    x16  00000075b501d2f8  x17  00000075b4fbf5d0  x18  0000000000000020  x19  0000000000002ee5
    x20  0000000000005e29  x21  000000000000000b  x22  00000075878c6a39  x23  0000000000000039
    x24  0000000000000000  x25  000000000000000c  x26  0000000000000004  x27  0000000000000025
    x28  0000000000000003  x29  00000075878c69a0  x30  00000075b4f73994
    sp   00000075878c6960  pc   00000075b4fbf5d8  pstate 0000000060000000
backtrace:
    #00 pc 00000000000695d8  /system/lib64/libc.so (tgkill+8)
    #01 pc 000000000001d990  /system/lib64/libc.so (abort+88)
    #02 pc 000000000043689c  /system/lib64/libart.so (_ZN3art7Runtime5AbortEPKc+528)
    #03 pc 0000000000436fac  /system/lib64/libart.so (_ZN3art7Runtime7AborterEPKc+24)
    #04 pc 00000000005215a0  /system/lib64/libart.so (_ZN7android4base10LogMessageD1Ev+900)
    #05 pc 000000000024ab94  /system/lib64/libart.so (_ZN3art22IndirectReferenceTable17AbortIfNoCheckJNIERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE+292)
    #06 pc 000000000024bea4  /system/lib64/libart.so (_ZN3art22IndirectReferenceTable6RemoveENS_15IRTSegmentStateEPv+2124)
    #07 pc 00000000002d5c88  /system/lib64/libart.so (_ZN3art9JavaVMExt15DeleteGlobalRefEPNS_6ThreadEP8_jobject+88)
    #08 pc 00000000000101f8  /data/app/<my.app.package>-EfWPIj7o0W6puJkcllzVFg==/lib/arm64/libbass.so
    #09 pc 000000000001937c  /data/app/<my.app.package>-EfWPIj7o0W6puJkcllzVFg==/lib/arm64/libbass.so
    #10 pc 0000000000034968  /data/app/<my.app.package>-EfWPIj7o0W6puJkcllzVFg==/lib/arm64/libbass.so (BASS_Init+1896)
    #11 pc 0000000000034a24  /data/app/<my.app.package>-EfWPIj7o0W6puJkcllzVFg==/lib/arm64/libbass.so (Java_com_un4seen_bass_BASS_BASS_1Init+28)
    #12 pc 000000000019eb18  /data/app/<my.app.package>-EfWPIj7o0W6puJkcllzVFg==/oat/arm64/base.odex (offset 0x7a000)

No more extra info :/

Ian @ un4seen

  • Administrator
  • Posts: 21370
Re: BASS for Android
« Reply #1481 on: 6 Dec '18 - 16:29 »
We've seen a few ANRs come in from Google Play recently that suggest BASS_Pause (which we call when our native activity receives APP_CMD_LOST_FOCUS) is hanging:

  #00  pc 0000000000018e54  /system/lib/libc.so (syscall+28)
  #01  pc 0000000000048fc1  /system/lib/libc.so (_ZL33__pthread_mutex_lock_with_timeoutP24pthread_mutex_internal_tbPK8timespec+516)
  #02  pc 0000000000012ccb  /lib/arm/libbass.so (?)
  #03  pc 000000000001c1cd  /lib/arm/libbass.so (?)
  #04  pc 00000000000277a1  /lib/arm/libbass.so (BASS_Pause+10)
 
None of the other threads showed anything with BASS in their call stacks, so I'm not sure what's going on with that mutex lock.

This was with BASS version 0x204 0D1D.

Should we be doing something different on APP_CMD_LOST_FOCUS instead of trying to pause?  Thanks!

BASS appears to be waiting for the OpenSLES callback function (which generates the data to play) to exit before stopping the device, but you should see another thread with BASS in the call stack then. In fact, I would expect there to be at least a couple of threads with BASS somewhere in the call stack, ie. the threads it created. Are you sure there are none?

Are you able to reproduce the problem yourself? That would make it easier to debug (I could send you a debug BASS version). If all else fails, you could switch to AudioTrack output (via BASS_DEVICE_AUDIOTRACK flag), which doesn't involve the same wait in BASS_Pause.

Last time in automatic beta test in play store we have this error:

Code: [Select]
Build fingerprint: 'google/sailfish/sailfish:8.0.0/OPR3.170623.013/4397526:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 12005, tid: 24105, name: BassPlayer Star  >>> <my.app.package> <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'indirect_reference_table.cc:56] JNI ERROR (app bug): attempt to remove stale Global 0x39 (should be 0x36)'
...

I see what's happened there. AudioTrack output initialization failed and BASS_Init mistakenly treated the local AudioTrack reference as global when deleting it. Here's an update for you to try:

   www.un4seen.com/stuff/bass-android-test.zip

Let me know if you still get the problem happening with that.

Nicholas

  • Posts: 5
Re: BASS for Android
« Reply #1482 on: 7 Dec '18 - 00:41 »
... I would expect there to be at least a couple of threads with BASS somewhere in the call stack, ie. the threads it created. Are you sure there are none?

This may be due to Google Play's imperfect debugging machinery.  About half the threads in these online crash listings simply report "not attached" and don't give any stack info at all.

We haven't seen it in-house yet, although from the statistics it appears to be our new #1 ANR since adding BASS to our app.  (One of our reasons for adding BASS support was the lower latency, so I'd be hesitant to switch things over to AudioTrack.)

APP_CMD_LOST_FOCUS is sent when the app is being transitioned to the background.  The ANR comes in 20+ seconds after the app has been brought back to the foreground.  I wonder if the lifetime management of the OpenSL thread isn't handled differently by different manufacturers/models and it's being suspended internally before we get a chance to call BASS_Pause.

Without the BASS_Pause -- at least on our in-house devices -- the OS eventually interrupts the stream on its own, but there is first a lingering, repeating sound that lasts for a second or two that I'm guessing is the sample buffer running low.

kenumir

  • Posts: 15
Re: BASS for Android
« Reply #1483 on: 7 Dec '18 - 07:32 »

Last time in automatic beta test in play store we have this error:

Code: [Select]
Build fingerprint: 'google/sailfish/sailfish:8.0.0/OPR3.170623.013/4397526:user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 12005, tid: 24105, name: BassPlayer Star  >>> <my.app.package> <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'indirect_reference_table.cc:56] JNI ERROR (app bug): attempt to remove stale Global 0x39 (should be 0x36)'
...

I see what's happened there. AudioTrack output initialization failed and BASS_Init mistakenly treated the local AudioTrack reference as global when deleting it. Here's an update for you to try:

   www.un4seen.com/stuff/bass-android-test.zip

Let me know if you still get the problem happening with that.

It happened once on google play automatic tests, on my devices never occurred. It will be difficult to reproduce.

kenumir

  • Posts: 15
Re: BASS for Android
« Reply #1484 on: 7 Dec '18 - 08:40 »
Another from android vitals console:
Code: [Select]
  #00  pc 000000000001c9da  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so
  #01  pc 000000000001e1c9  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so
  #02  pc 0000000000020307  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so (BASS_StreamFree+52)
  #03  pc 0000000000020317  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so (Java_com_un4seen_bass_BASS_BASS_1StreamFree+4)
  #04  pc 000000000004176b  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/oat/arm/base.odex

Android 8.1, no more extra info :(

Ian @ un4seen

  • Administrator
  • Posts: 21370
Re: BASS for Android
« Reply #1485 on: 7 Dec '18 - 15:15 »
... I would expect there to be at least a couple of threads with BASS somewhere in the call stack, ie. the threads it created. Are you sure there are none?

This may be due to Google Play's imperfect debugging machinery.  About half the threads in these online crash listings simply report "not attached" and don't give any stack info at all.

We haven't seen it in-house yet, although from the statistics it appears to be our new #1 ANR since adding BASS to our app.  (One of our reasons for adding BASS support was the lower latency, so I'd be hesitant to switch things over to AudioTrack.)

APP_CMD_LOST_FOCUS is sent when the app is being transitioned to the background.  The ANR comes in 20+ seconds after the app has been brought back to the foreground.  I wonder if the lifetime management of the OpenSL thread isn't handled differently by different manufacturers/models and it's being suspended internally before we get a chance to call BASS_Pause.

Without the BASS_Pause -- at least on our in-house devices -- the OS eventually interrupts the stream on its own, but there is first a lingering, repeating sound that lasts for a second or two that I'm guessing is the sample buffer running low.

BASS won't repeat buffered data, so if that's what's heard then that may be an OS or device issue (buffered data being repeated by one of them). Perhaps audio handling threads are being suspended, as you say. What Android version(s) is the problem happening on? Does the stuttering also happen when using AudioTrack output?

I'm not sure the wait in BASS_Pause is absolutely necessary. At worst, I guess there could be a little stutter heard when pausing without it if the OpenSLES callback function happens to be generating data at the time. Here's an update with it removed for you to try:

   www.un4seen.com/stuff/bass-android-test.zip

Let me know whether that helps.

Another from android vitals console:
Code: [Select]
  #00  pc 000000000001c9da  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so
  #01  pc 000000000001e1c9  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so
  #02  pc 0000000000020307  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so (BASS_StreamFree+52)
  #03  pc 0000000000020317  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so (Java_com_un4seen_bass_BASS_BASS_1StreamFree+4)
  #04  pc 000000000004176b  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/oat/arm/base.odex

Android 8.1, no more extra info :(

BASS_StreamFree appears to have crashed there when it tried to call an add-on to release its resources (the stream was apparently using an add-on). Perhaps the add-on had been unloaded. Are you dynamically loading and unloading add-ons but not using BASS_PluginLoad/Free to do that?

kenumir

  • Posts: 15
Re: BASS for Android
« Reply #1486 on: 7 Dec '18 - 20:11 »
Quote
I'm not sure the wait in BASS_Pause is absolutely necessary. At worst, I guess there could be a little stutter heard when pausing without it if the OpenSLES callback function happens to be generating data at the time. Here's an update with it removed for you to try:

   www.un4seen.com/stuff/bass-android-test.zip

Let me know whether that helps.

Another from android vitals console:
Code: [Select]
  #00  pc 000000000001c9da  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so
  #01  pc 000000000001e1c9  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so
  #02  pc 0000000000020307  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so (BASS_StreamFree+52)
  #03  pc 0000000000020317  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/lib/arm/libbass.so (Java_com_un4seen_bass_BASS_BASS_1StreamFree+4)
  #04  pc 000000000004176b  /data/app/<my.app.package>-ypAxkzdS7RR5b90g6ayLTw==/oat/arm/base.odex

Android 8.1, no more extra info :(

BASS_StreamFree appears to have crashed there when it tried to call an add-on to release its resources (the stream was apparently using an add-on). Perhaps the add-on had been unloaded. Are you dynamically loading and unloading add-ons but not using BASS_PluginLoad/Free to do that?

Nope. Plugins load only with BASS_PluginLoad/Free(0) methods.

Ian @ un4seen

  • Administrator
  • Posts: 21370
Re: BASS for Android
« Reply #1487 on: 10 Dec '18 - 14:59 »
Are you creating any streams using an add-on's specific function instead of the plugin system, eg. BASS_FLAC_StreamCreateFile instead of BASS_StreamCreateFile? If so, those streams won't be freed automatically by BASS_PluginFree and will need to be freed with BASS_StreamFree (or BASS_Free) first. There is generally no need to unload plugins at all, so perhaps you could just remove the BASS_PluginFree calls and see if the problem still happens then?

kenumir

  • Posts: 15
Re: BASS for Android
« Reply #1488 on: 11 Dec '18 - 08:01 »
Are you creating any streams using an add-on's specific function instead of the plugin system, eg. BASS_FLAC_StreamCreateFile instead of BASS_StreamCreateFile? If so, those streams won't be freed automatically by BASS_PluginFree and will need to be freed with BASS_StreamFree (or BASS_Free) first. There is generally no need to unload plugins at all, so perhaps you could just remove the BASS_PluginFree calls and see if the problem still happens then?

I use only BASS_StreamCreateFileUser method.
Ok, remove BASS_PluginFree and we will see.

Thanks

Ian @ un4seen

  • Administrator
  • Posts: 21370
Re: BASS for Android
« Reply #1489 on: 11 Dec '18 - 17:11 »
For greater convenience, Android Studio projects for the examples have been added to the BASS package in the 1st post. The "mp3-free" BASS version has also been removed due to the MP3 patents having expired and the standard BASS version's MP3 decoder using less CPU/battery.

Alpinador

  • Posts: 1
Re: BASS for Android
« Reply #1490 on: 12 Dec '18 - 11:24 »
Hello Ian !!! great work with bass..... i use for my home projects and practices programming

The thing now is im trying get running in Android Mobile phone using Rad Studio C++ Builder 10.2 environment and i added the bass.so packet to project but i dont know what more do with headers...... can you bring some light to this???

Ian @ un4seen

  • Administrator
  • Posts: 21370
Re: BASS for Android
« Reply #1491 on: 12 Dec '18 - 15:51 »
If you're creating your app in C++, you should use the BASS.H header in your code. That header is the same on all platforms, so you can can take it from one of the Win32/OSX/Linux BASS packages.

Nicholas

  • Posts: 5
Re: BASS for Android
« Reply #1492 on: 13 Dec '18 - 00:33 »
I'm not sure the wait in BASS_Pause is absolutely necessary. At worst, I guess there could be a little stutter heard when pausing without it...
As for the stutter: we haven't experienced it or heard from any users about it yet.  So that's good news.

Even better: after a few days with that test version in the wild, it seems that without the lock in BASS_Pause, that species of ANR (that we were seeing dozens of times per day before) appears to be completely gone! ;D  Thanks so much for the quick reply with that test version.  It's hard to believe how responsive you guys are!