aleksey-saenko / MusicRecognizer

An Android application for music recognition that uses AudD and ACRCloud services to perform song identification.
GNU General Public License v3.0
316 stars 8 forks source link

Instantly crashes #12

Closed 585381 closed 7 months ago

585381 commented 8 months ago

When pressing tap to rec it closes with no notification. Last version would stay open but didn't detect any songs, from the most popular artists

aleksey-saenko commented 8 months ago

Please provide the app version number and source, for example "v1.0.1 from f-droid". It would also be helpful to provide the phone model and firmware information (at least Android version). It's quite difficult to understand the reasons for the failure with such limited information. I'll consider how to make troubleshooting easier, but for now, you need to check how the app records audio on your device. To do this, turn off the internet and launch recognition. The app will save the recording to the queue, and you can listen it. Please let me know what you hear. Is the recording around 10 seconds in length? How is the quality? If there is no any sound, for Android 12 and higher, it's useful to check that microphone access is not restricted in the notification drawer. In general, you need to ensure that the microphone on the device is functioning properly.

Akruidenberg commented 8 months ago

Same for me. Version 1.0.1 from fdroid. Lineageos 20, oneplus 6

DehGit commented 8 months ago

Same for me. V 1.0.1 from F-Droid. When online tapping "recognize" causes app to crash instantly. When offline it records without crashing and saves it in the recognition queue where it can be played back correctly. When online again it tries to recognize the queued recording without crashing. Same behavior with or without API token. However: with (correct!) API token set it says "wrong API token". Without a token it recognizes the song correctly. Pixel 4a, Android 13

ltguillaume commented 8 months ago

Here's a logcat dump using v1.0.1 F-Droid on Android 11.

I can confirm the fact that - as mentioned by @DehGit - the recording will work fine if there is no internet connection. Note that for me recognizing while connected worked exactly 1 time after install, then it failed every single time, also after clearing the app data.

I/MediaProvider( 1654): Deleted 1 items on external_primary due to com.android.shell
W/ServiceManager(  495): Permission failure: android.permission.CAPTURE_AUDIO_OUTPUT from uid=10050 pid=7490
D/PermissionCache(  495): checking android.permission.CAPTURE_AUDIO_OUTPUT for uid=10050 => denied (350 us)
W/ServiceManager(  495): Permission failure: android.permission.CAPTURE_AUDIO_HOTWORD from uid=10050 pid=7490
D/PermissionCache(  495): checking android.permission.CAPTURE_AUDIO_HOTWORD for uid=10050 => denied (335 us)
D/audio_hw_primary(  495): adev_open_input_stream: enter: sample_rate(48000) channel_mask(0x10) devices(0x80000004)        stream_handle(0xb224e000) io_handle(38) source(1)
I/AudioFlinger(  495): AudioFlinger's thread 0xb0a0f000 tid=7610 ready to run
D/audio_hw_primary(  495): in_standby: enter: stream (0xb224e000) usecase(9: audio-record)
D/audio_hw_primary(  495): in_standby: enter: stream (0xb224e000) usecase(9: audio-record)
I/chatty  (  837): uid=1000(system) Binder:837_8 expire 1 line
I/chatty  (  837): uid=1000(system) Binder:837_8 expire 1 line
I/system_server(  837): oneway function results will be dropped but finished with status OK and parcel size 4
D/CCodec  ( 7490): allocate(c2.android.aac.encoder)
D/audio_hw_primary(  495): in_set_parameters: enter: kvpairs=bottom=;input_source=1;routing=-2147483644
I/system_server(  837): oneway function results will be dropped but finished with status OK and parcel size 4
I/system_server(  837): oneway function results will be dropped but finished with status OK and parcel size 4
I/Codec2Client( 7490): Available Codec2 services: "software"
I/SoundTriggerMiddlewareLogging(  837): setCaptureState[this=com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl@32aa062, caller=1041/495](true)
E/FMQ     (  495): grantorIdx must be less than 3
I/chatty  (  495): uid=1041(audioserver) /system/bin/audioserver identical 2 lines
E/FMQ     (  495): grantorIdx must be less than 3
D/audio_hw_primary(  495): start_input_stream: enter: stream(0xb224e000)usecase(9: audio-record)
D/audio_hw_primary(  495): select_devices: out_snd_device(0: ) in_snd_device(35: rec-main-mic)
D/hardware_info(  495): hw_info_append_hw_type : device_name = rec-main-mic
I/msm8974_platform(  495): platform_send_audio_calibration: sending audio calibration for snd_device(35) acdb_id(4)
D/ACDB-LOADER(  495): ACDB -> send_audio_cal, acdb_id = 4, path =  1
D/ACDB-LOADER(  495): ACDB -> send_adm_topology
D/ACDB-LOADER(  495): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER(  495): ACDB -> send_asm_topology
D/ACDB-LOADER(  495): ACDB -> ACDB_CMD_GET_AUDPROC_STREAM_TOPOLOGY_ID
D/ACDB-LOADER(  495): ACDB -> send_audtable
D/ACDB-LOADER(  495): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/audioserver(  495): ACDBFILE_MGR:Read the devices count as zero, please check the acdb file
D/ACDB-LOADER(  495): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER(  495): ACDB -> send_audvoltable
D/ACDB-LOADER(  495): ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_STEP_TABLE
D/audioserver(  495): ACDBFILE_MGR:Read the devices count as zero, please check the acdb file
D/audioserver(  495): Failed to fetch the lookup information of the device 00000004 
E/ACDB-LOADER(  495): Error: ACDB AudProc vol returned = -19
D/ACDB-LOADER(  495): ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
D/ACDB-LOADER(  495): ACDB -> AUDIO_SET_AFE_CAL
D/audio_route(  495): Apply path: rec-main-mic
V/C2Store (  618): in init
V/C2Store (  618): loading dll
D/audio_route(  495): Apply path: audio-record
D/audio_hw_primary(  495): select_devices: done
I/CCodec  ( 7490): Created component [c2.android.aac.encoder]
D/CCodecConfig( 7490): read media type: audio/mp4a-latm
D/ReflectedParamUpdater( 7490): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater( 7490): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater( 7490): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater( 7490): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater( 7490): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater( 7490): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater( 7490): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig( 7490): query failed after returning 9 values (BAD_INDEX)
D/CCodecConfig( 7490): c2 config diff is Dict {
D/CCodecConfig( 7490):   c2::u32 coded.bitrate.value = 64000
D/CCodecConfig( 7490):   c2::u32 coded.pl.level = 0
D/CCodecConfig( 7490):   c2::u32 coded.pl.profile = 8192
D/CCodecConfig( 7490):   c2::u32 coding.aac-sbr-mode.value = 3
D/CCodecConfig( 7490):   c2::u32 input.buffers.max-size.value = 2048
D/CCodecConfig( 7490):   c2::u32 input.delay.value = 0
D/CCodecConfig( 7490):   string input.media-type.value = "audio/raw"
D/CCodecConfig( 7490):   string output.media-type.value = "audio/mp4a-latm"
D/CCodecConfig( 7490):   c2::u32 raw.channel-count.value = 1
D/CCodecConfig( 7490):   c2::u32 raw.sample-rate.value = 44100
D/CCodecConfig( 7490): }
D/MediaCodec( 7490): flushMediametrics
D/CCodec  ( 7490): [c2.android.aac.encoder] buffers are bound to CCodec for this session
D/CCodecConfig( 7490): no c2 equivalents for aac-profile
D/CCodecConfig( 7490): no c2 equivalents for flags
D/CCodecConfig( 7490): no c2 equivalents for encoder
D/CCodecConfig( 7490): c2 config diff is   c2::u32 coded.bitrate.value = 163840
D/CCodecConfig( 7490):   c2::u32 raw.sample-rate.value = 48000
W/Codec2Client( 7490): query -- param skipped: index = 1107298332.
D/CCodec  ( 7490): client requested max input size 1920, which is smaller than what component recommended (2048); overriding with component recommendation.
W/CCodec  ( 7490): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec  ( 7490): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  ( 7490):   int32_t aac-sbr-mode = 3
D/CCodec  ( 7490):   int32_t channel-count = 1
D/CCodec  ( 7490):   int32_t max-input-size = 2048
D/CCodec  ( 7490):   string mime = "audio/raw"
D/CCodec  ( 7490):   int32_t sample-rate = 48000
D/CCodec  ( 7490): } and output: AMessage(what = 0x00000000) = {
D/CCodec  ( 7490):   int32_t aac-sbr-mode = 3
D/CCodec  ( 7490):   int32_t bitrate = 163840
D/CCodec  ( 7490):   int32_t channel-count = 1
D/CCodec  ( 7490):   int32_t level = 0
D/CCodec  ( 7490):   int32_t max-bitrate = 163840
D/CCodec  ( 7490):   string mime = "audio/mp4a-latm"
D/CCodec  ( 7490):   int32_t profile = 2
D/CCodec  ( 7490):   int32_t sample-rate = 48000
D/CCodec  ( 7490): }
I/MediaCodec( 7490): MediaCodec will operate in async mode
W/Codec2Client( 7490): query -- param skipped: index = 1342179345.
W/Codec2Client( 7490): query -- param skipped: index = 2415921170.
E/FMQ     ( 7490): grantorIdx must be less than 3
E/FMQ     ( 7490): grantorIdx must be less than 3
D/CCodecBufferChannel( 7490): [c2.android.aac.encoder#578] Created input block pool with allocatorID 16 => poolID 17 - OK (0)
E/FMQ     (  618): grantorIdx must be less than 3
E/FMQ     (  618): grantorIdx must be less than 3
D/BufferPoolAccessor2.0(  608): bufferpool2 0xa7e0de18 : 0(0 size) total buffers - 0(0 size) used buffers - 93/101 (recycle/alloc) - 8/198 (fetch/transfer)
D/BufferPoolAccessor2.0(  608): Destruction - bufferpool2 0xa7e0de18 cached: 0/0M, 0/0% in use; allocs: 101, 92% recycled; transfers: 198, 96% unfetched
I/CCodecBufferChannel( 7490): [c2.android.aac.encoder#578] Created output block pool with allocatorID 16 => poolID 29 - OK
D/BufferPoolAccessor2.0(  608): bufferpool2 0xa7e0e458 : 0(0 size) total buffers - 0(0 size) used buffers - 0/5 (recycle/alloc) - 2/4 (fetch/transfer)
D/BufferPoolAccessor2.0(  608): Destruction - bufferpool2 0xa7e0e458 cached: 0/0M, 0/0% in use; allocs: 5, 0% recycled; transfers: 4, 50% unfetched
D/CCodecBufferChannel( 7490): [c2.android.aac.encoder#578] Configured output block pool ids 29 => OK
E/ion     ( 7490): ioctl c0044901 failed with code -1: Invalid argument
D/SimpleC2Component(  618): Using output block pool with poolID 29 => got 29 - 0
E/FMQ     ( 7490): grantorIdx must be less than 3
E/FMQ     (  618): grantorIdx must be less than 3
E/FMQ     (  618): grantorIdx must be less than 3
E/FMQ     ( 7490): grantorIdx must be less than 3
D/CCodecBuffers( 7490): [c2.android.aac.encoder#578:Output[N]] popFromStashAndRegister: output format changed to AMessage(what = 0x00000000) = {
D/CCodecBuffers( 7490):   int32_t aac-sbr-mode = 3
D/CCodecBuffers( 7490):   int32_t bitrate = 163840
D/CCodecBuffers( 7490):   int32_t channel-count = 1
D/CCodecBuffers( 7490):   int32_t level = 0
D/CCodecBuffers( 7490):   int32_t max-bitrate = 163840
D/CCodecBuffers( 7490):   string mime = "audio/mp4a-latm"
D/CCodecBuffers( 7490):   int32_t profile = 2
D/CCodecBuffers( 7490):   int32_t sample-rate = 48000
D/CCodecBuffers( 7490):   Buffer csd-0 = {
D/CCodecBuffers( 7490):     00000000:  11 88                                             ..
D/CCodecBuffers( 7490):   }
D/CCodecBuffers( 7490): }
D/CCodecBuffers( 7490): [c2.android.aac.encoder#578:Output[N]] popFromStashAndRegister: output format changed to AMessage(what = 0x00000000) = {
D/CCodecBuffers( 7490):   int32_t aac-sbr-mode = 3
D/CCodecBuffers( 7490):   int32_t bitrate = 163840
D/CCodecBuffers( 7490):   int32_t channel-count = 1
D/CCodecBuffers( 7490):   int32_t level = 0
D/CCodecBuffers( 7490):   int32_t max-bitrate = 163840
D/CCodecBuffers( 7490):   string mime = "audio/mp4a-latm"
D/CCodecBuffers( 7490):   int32_t profile = 2
D/CCodecBuffers( 7490):   int32_t sample-rate = 48000
D/CCodecBuffers( 7490):   Buffer csd-0 = {
D/CCodecBuffers( 7490):     00000000:  11 88                                             ..
D/CCodecBuffers( 7490):   }
D/CCodecBuffers( 7490): }
D/CCodecBuffers( 7490): [c2.android.aac.encoder#578:Output[N]] popFromStashAndRegister: output format changed to AMessage(what = 0x00000000) = {
D/CCodecBuffers( 7490):   int32_t aac-sbr-mode = 3
D/CCodecBuffers( 7490):   int32_t bitrate = 163840
D/CCodecBuffers( 7490):   int32_t channel-count = 1
D/CCodecBuffers( 7490):   int32_t level = 0
D/CCodecBuffers( 7490):   int32_t max-bitrate = 163840
D/CCodecBuffers( 7490):   string mime = "audio/mp4a-latm"
D/CCodecBuffers( 7490):   int32_t profile = 2
D/CCodecBuffers( 7490):   int32_t sample-rate = 48000
D/CCodecBuffers( 7490):   Buffer csd-0 = {
D/CCodecBuffers( 7490):     00000000:  11 88                                             ..
D/CCodecBuffers( 7490):   }
D/CCodecBuffers( 7490): }
--------- beginning of crash
E/AndroidRuntime( 7490): FATAL EXCEPTION: e9.z Dispatcher
E/AndroidRuntime( 7490): Process: com.mrsep.musicrecognizer, PID: 7490
E/AndroidRuntime( 7490): java.lang.IllegalStateException: Unbalanced enter/exit
E/AndroidRuntime( 7490):    at r9.d.i(Unknown Source:126)
E/AndroidRuntime( 7490):    at r9.c.M(Unknown Source:19)
E/AndroidRuntime( 7490):    at r9.b0.a(Unknown Source:49)
E/AndroidRuntime( 7490):    at r9.b0.w(Unknown Source:38)
E/AndroidRuntime( 7490):    at k9.h.f(Unknown Source:24)
E/AndroidRuntime( 7490):    at i9.e.d(Unknown Source:2)
E/AndroidRuntime( 7490):    at j9.b.a(Unknown Source:283)
E/AndroidRuntime( 7490):    at j9.f.b(Unknown Source:134)
E/AndroidRuntime( 7490):    at i9.a.a(Unknown Source:101)
E/AndroidRuntime( 7490):    at j9.f.b(Unknown Source:134)
E/AndroidRuntime( 7490):    at g9.b.a(Unknown Source:121)
E/AndroidRuntime( 7490):    at j9.f.b(Unknown Source:134)
E/AndroidRuntime( 7490):    at j9.a.a(Unknown Source:150)
E/AndroidRuntime( 7490):    at j9.f.b(Unknown Source:134)
E/AndroidRuntime( 7490):    at j9.g.a(Unknown Source:153)
E/AndroidRuntime( 7490):    at j9.f.b(Unknown Source:134)
E/AndroidRuntime( 7490):    at i9.j.g(Unknown Source:95)
E/AndroidRuntime( 7490):    at i9.g.run(Unknown Source:37)
E/AndroidRuntime( 7490):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime( 7490):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime( 7490):    at java.lang.Thread.run(Thread.java:923)
I/DropBoxManagerService(  837): add tag=data_app_crash isTagEnabled=true flags=0x2
W/ActivityTaskManager(  837):   Force finishing activity com.mrsep.musicrecognizer/.presentation.MainActivity
aleksey-saenko commented 8 months ago

@ltguillaume Thanks for providing the logs. In your case, the issue is the same as #6 . A bug fix will be included in v1.1.0, which should appear on F-Droid in the next few days. As I suspect this bug has caused crashes for others as well.

@DehGit Yes, I can confirm that the app stops working with the proper token. I suspect that this was caused by the protection system of the AudD service (see #13 ). The app should have some identifier to help differentiate it from malicious behavior. I hope that in future releases starting from v1.1.1, it will start to work fine.

ltguillaume commented 8 months ago

Thanks! I was still wondering about the following lines in the dump, though:

W/ServiceManager(  495): Permission failure: android.permission.CAPTURE_AUDIO_OUTPUT from uid=10050 pid=7490
D/PermissionCache(  495): checking android.permission.CAPTURE_AUDIO_OUTPUT for uid=10050 => denied (350 us)
W/ServiceManager(  495): Permission failure: android.permission.CAPTURE_AUDIO_HOTWORD from uid=10050 pid=7490
D/PermissionCache(  495): checking android.permission.CAPTURE_AUDIO_HOTWORD for uid=10050 => denied (335 us)

What is the reason for this?

aleksey-saenko commented 8 months ago

@ltguillaume ServiceManager, for some reasons, indicates that the permissions android.permission.CAPTURE_AUDIO_OUTPUT and android.permission.CAPTURE_AUDIO_HOTWORD are denied for this app. However, these permissions are only allowed for system apps and are not accessible to regular third-party applications. Audile never asks for these permissions (they are not even declared in the manifest), as android.permission.RECORD_AUDIO is sufficient for audio recording. You can ignore these messages, they do not affect the application's functionality.

ltguillaume commented 8 months ago

Thanks for the comprehensive answer, much appreciated!

aleksey-saenko commented 7 months ago

The bug fix was added in version 1.1.0, see #6 .