Android Question ANR error: xxxx.main._load_sound Input dispatching timed out, after migrating to Android 12 SDK 31

PhilN

Member
Licensed User
Longtime User
I am using B4A ver 12.2. The SDK is set to C:\Android\platforms\android-33\android.jar. The minimum SDK Version is 16 and the target SDK Version is 31. The app is published on Google Play but I have deactivated it to resolve this issue.

I have migrated my Compass GM app from Android 11 (SDK 30) to Android 12 (SDK 31). There are many of the same errors from various users on Google Play:

gyromagnetic.compass.main._load_sound
Input dispatching timed out

There have been 479 occurrences of this error with 220 affected users in 3 days. About 2/3 of these users are on Android 12 (SDK 31), while 1/3 are on Android 11 (SDK 30) and then some on Android 10 (SDK 29) and some on Android 13 (SDK 33). This is my mistake. I should have tested it properly. I do, however, have a Samsung A51 running Android 12 and the app works fine without any errors. One user wrote that he gets a black screen and then it says App not responding after updating the app on Google Play Store.

The weird thing is that it was working fine on Android SDK 30 but not on Android SDK 31. Now the error appears across various versions of Android such as 10, 11, 12 and 13 and on various devices.

I do not know how to fix this. I did look for similar occurrences but to no avail.
 

PhilN

Member
Licensed User
Longtime User
Hi Erel. Thank you for responding. Here is more detail of the Thread "main" tid=1 Native...

#00 pc 0x0000000000085c6c /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
#01 pc 0x000000000008a3d8 /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, timespec const*)+144)
#02 pc 0x00000000000ebdc0 /apex/com.android.runtime/lib64/bionic/libc.so (pthread_cond_wait+80)
#03 pc 0x000000000005697c /system/lib64/libc++.so (std::__1::condition_variable::wait(std::__1::unique_lock<std::__1::mutex>&)+20)
#04 pc 0x000000000000adc4 /system/lib64/libsoundpool.so (android::soundpool::SoundDecoder::loadSound(int)+92)
#05 pc 0x000000000000c618 /system/lib64/libsoundpool.so (android::soundpool::SoundManager::load(int, long, long, int)+536)
at android.media.SoundPool._load (Native method)
at android.media.SoundPool.load (SoundPool.java:256)
at anywheresoftware.b4a.audio.SoundPoolWrapper.Load (SoundPoolWrapper.java:38)
at gyromagnetic.compass.main._load_sound (main.java:2824)
at gyromagnetic.compass.main$ResumableSub_Activity_Create.resume (main.java:960)
at gyromagnetic.compass.main._activity_create (main.java:722)
at java.lang.reflect.Method.invoke (Native method)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:221)
at gyromagnetic.compass.main.afterFirstLayout (main.java:105)
at gyromagnetic.compass.main.access$000 (main.java:17)
at gyromagnetic.compass.main$WaitForLayout.run (main.java:83)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loopOnce (Looper.java:211)
at android.os.Looper.loop (Looper.java:300)
at android.app.ActivityThread.main (ActivityThread.java:8279)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:576)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1074)
 
Upvote 0

PhilN

Member
Licensed User
Longtime User
Thank you for your advice. I can try MediaPlayer. I must however say that I only load short sounds for button presses. So the sounds are short about 0.3 at most. I am using SounPool at the moment from the Audio library. Below is some of my code.

Sound code used in my app:
Sub Process_Globals
    Dim sounds As SoundPool
    Dim RXId2,RXId3,RXId4 As Int
    Dim p As Phone 'so as to be able to change the volume level from 0-15
    Dim SoundOn As Boolean = True 'by default turn sound on
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ' initialise sound
    sounds.Initialize(4) 'added extra streams incase two or more sounds are played simultaneously (20/8/2022)
    RXId2 = Load_Sound("ErrorBeep.mp3") 'used when no more WPs can be selected with left or right arrows   
    RXId3 = Load_Sound("Tick03.mp3")    'used for WP gesture
    RXId4 = Load_Sound("woerrroep.mp3")    'used for waypoint increment
End Sub

Sub Load_Sound(fileName As String) As Int
    Dim loadIndex As Int = 0
    For i = 0 To 1000 'this will try harder to load the file with greater success according to canalrun on the B4A forum
        loadIndex = sounds.Load(File.DirAssets, fileName)    'used when no more WPs can be selected with left or right arrows
        If RXId2 > 0 Then Exit 'stop trying to load it
    Next       
    Return loadIndex 'returns 0 if it fails to load
End Sub

Sub btnLeftArrow_Click
    If SoundOn Then
        If RXId4 > 0 Then sounds.Play(RXId4, 0.07, 0.07, 1, 0, 1)' play woerrroep sound (only play sound if loaded or > 0)
    End If
End Sub

Sub PlayErrorBeep 'used by other routines
    If SoundOn Then
        If RXId2 > 0 Then sounds.Play(RXId2, 0.07, 0.07, 1, 0, 1) 'only play sound if loaded or > 0
    End If
End Sub
 
Upvote 0
Top