Android Question [libart.so] art::ConditionVariable::WaitHoldingLocks(art::Thread*)

Hello team,

i am using firebase messaging and i am seeing that i have a lot of ANRs in google play console shown as below:

  • Broadcast of Intent { act=com.google.android.c2dm.intent.RECEIVE cmp=.../com.google.firebase.iid.FirebaseInstanceIdReceiver }
Thread
"Signal Catcher" tid=6 Runnable
Show lessexpand_less
#00 pc 0x0000000000536054 /apex/com.android.art/lib64/libart.so (art:umpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, BacktraceMap*, char const*, art::ArtMethod*, void*, bool)+128)
#01 pc 0x00000000006ef5e4 /apex/com.android.art/lib64/libart.so (art:?umpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap*, bool) const+236)
#02 pc 0x00000000006fce70 /apex/com.android.art/lib64/libart.so (art:umpCheckpoint::Run(art::Thread*)+208)
#03 pc 0x00000000003619dc /apex/com.android.art/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+440)
#04 pc 0x00000000006fb610 /apex/com.android.art/lib64/libart.so (art::ThreadList:ump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool)+280)
#05 pc 0x00000000006fb004 /apex/com.android.art/lib64/libart.so (art::ThreadList:umpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+292)
#06 pc 0x00000000006d4154 /apex/com.android.art/lib64/libart.so (art::Runtime:umpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+184)
#07 pc 0x00000000006e0174 /apex/com.android.art/lib64/libart.so (art::SignalCatcher::HandleSigQuit()+468)
#08 pc 0x000000000056fe8c /apex/com.android.art/lib64/libart.so (art::SignalCatcher::Run(void*)+264)
#09 pc 0x00000000000f5298 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#10 pc 0x000000000008ebdc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)
content_copy

Thread
"perfetto_hprof_listener" tid=7 Native
Show lessexpand_less
#00 pc 0x00000000000e05a8 /apex/com.android.runtime/lib64/bionic/libc.so (read+8)
#01 pc 0x000000000001d840 /apex/com.android.art/lib64/libperfetto_hprof.so (void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, ArtPlugin_Initialize::$_34> >(void*)+260)
#02 pc 0x00000000000f5298 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#03 pc 0x000000000008ebdc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)
content_copy

Thread
"Jit thread pool worker thread 0" tid=8 Native
Show lessexpand_less
#00 pc 0x0000000000089630 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32)
#01 pc 0x000000000047a430 /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+140)
#02 pc 0x000000000047a2c8 /apex/com.android.art/lib64/libart.so (art::ThreadPool::GetTask(art::Thread*)+120)
#03 pc 0x0000000000615604 /apex/com.android.art/lib64/libart.so (art::ThreadPoolWorker::Run()+72)
#04 pc 0x0000000000615524 /apex/com.android.art/lib64/libart.so (art::ThreadPoolWorker::Callback(void*)+160)
#05 pc 0x00000000000f5298 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#06 pc 0x000000000008ebdc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)
content_copy

Thread
"HeapTaskDaemon" tid=9 Waiting
Show lessexpand_less
#00 pc 0x0000000000089630 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32)
#01 pc 0x000000000047a430 /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+140)
#02 pc 0x000000000046a93c /apex/com.android.art/lib64/libart.so (art::gc::TaskProcessor::GetTask(art::Thread*)+736)
#03 pc 0x000000000046a610 /apex/com.android.art/lib64/libart.so (art::gc::TaskProcessor::RunAllTasks(art::Thread*)+32)
at dalvik.system.VMRuntime.runHeapTasks (Native method)
at java.lang.Daemons$HeapTaskDaemon.runInternal (Daemons.java:609)
at java.lang.Daemons$Daemon.run (Daemons.java:140)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"FinalizerDaemon" tid=10 Waiting
Show lessexpand_less
at java.lang.Object.wait (Native method)
at java.lang.Object.wait (Object.java:442)
at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:203)
at java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:224)
at java.lang.Daemons$FinalizerDaemon.runInternal (Daemons.java:300)
at java.lang.Daemons$Daemon.run (Daemons.java:140)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"ReferenceQueueDaemon" tid=11 Waiting
Show lessexpand_less
at java.lang.Object.wait (Native method)
at java.lang.Object.wait (Object.java:442)
at java.lang.Object.wait (Object.java:568)
at java.lang.Daemons$ReferenceQueueDaemon.runInternal (Daemons.java:232)
at java.lang.Daemons$Daemon.run (Daemons.java:140)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"FinalizerWatchdogDaemon" tid=12 Timed Waiting
Show lessexpand_less
at java.lang.Thread.sleep (Native method)
at java.lang.Thread.sleep (Thread.java:450)
at java.lang.Thread.sleep (Thread.java:355)
at java.lang.Daemons$FinalizerWatchdogDaemon.sleepForNanos (Daemons.java:438)
at java.lang.Daemons$FinalizerWatchdogDaemon.waitForProgress (Daemons.java:480)
at java.lang.Daemons$FinalizerWatchdogDaemon.runInternal (Daemons.java:369)
at java.lang.Daemons$Daemon.run (Daemons.java:140)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"binder:11851_1" tid=13 Native
Show lessexpand_less
#00 pc 0x00000000000e088c /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+12)
#01 pc 0x000000000009765c /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+160)
#02 pc 0x000000000005c2a0 /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+284)
#03 pc 0x000000000005c594 /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+28)
#04 pc 0x000000000005cee0 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+72)
#05 pc 0x000000000008d128 /system/lib64/libbinder.so (android:oolThread::threadLoop()+448)
#06 pc 0x0000000000013418 /system/lib64/libutils.so (android:?:_threadLoop(void*)+424)
#07 pc 0x00000000000ce7e8 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+144)
#08 pc 0x00000000000f5298 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#09 pc 0x000000000008ebdc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)
content_copy

Thread
"binder:11851_2" tid=14 Native
Show lessexpand_less
#00 pc 0x00000000000e088c /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+12)
#01 pc 0x000000000009765c /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+160)
#02 pc 0x000000000005c2a0 /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+284)
#03 pc 0x000000000005c594 /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+28)
#04 pc 0x000000000005cee0 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+72)
#05 pc 0x000000000008d128 /system/lib64/libbinder.so (android:oolThread::threadLoop()+448)
#06 pc 0x0000000000013418 /system/lib64/libutils.so (android:?:_threadLoop(void*)+424)
#07 pc 0x00000000000ce7e8 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+144)
#08 pc 0x00000000000f5298 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#09 pc 0x000000000008ebdc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)
content_copy

Thread
"binder:11851_3" tid=15 Native
Show lessexpand_less
#00 pc 0x00000000000e088c /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+12)
#01 pc 0x000000000009765c /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+160)
#02 pc 0x000000000005c2a0 /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+284)
#03 pc 0x000000000005c594 /system/lib64/libbinder.so (android::IPCThreadState::getAndExecuteCommand()+28)
#04 pc 0x000000000005cee0 /system/lib64/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+72)
#05 pc 0x000000000008d128 /system/lib64/libbinder.so (android:oolThread::threadLoop()+448)
#06 pc 0x0000000000013418 /system/lib64/libutils.so (android:?:_threadLoop(void*)+424)
#07 pc 0x00000000000ce7e8 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+144)
#08 pc 0x00000000000f5298 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#09 pc 0x000000000008ebdc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)
content_copy

Thread
"Profile Saver" tid=16 Native
Show lessexpand_less
#00 pc 0x0000000000089630 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32)
#01 pc 0x000000000047a430 /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+140)
#02 pc 0x000000000053f0e8 /apex/com.android.art/lib64/libart.so (art:rofileSaver::Run()+372)
#03 pc 0x0000000000534934 /apex/com.android.art/lib64/libart.so (art:rofileSaver::RunProfileSaverThread(void*)+148)
#04 pc 0x00000000000f5298 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208)
#05 pc 0x000000000008ebdc /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68)
content_copy

Thread
"queued-work-looper-data" tid=17 Waiting
Show lessexpand_less
at jdk.internal.misc.Unsafe.park (Native method)
at java.util.concurrent.locks.LockSupport.park (LockSupport.java:194)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2081)
at java.util.concurrent.LinkedBlockingQueue.take (LinkedBlockingQueue.java:433)
at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1063)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1123)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"ScionFrontendApi" tid=19 Timed Waiting
Show lessexpand_less
at jdk.internal.misc.Unsafe.park (Native method)
at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:234)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2123)
at java.util.concurrent.LinkedBlockingQueue.poll (LinkedBlockingQueue.java:458)
at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1062)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1123)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"pool-7-thread-1" tid=20 Timed Waiting
Show lessexpand_less
at jdk.internal.misc.Unsafe.park (Native method)
at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:234)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2123)
at java.util.concurrent.LinkedBlockingQueue.poll (LinkedBlockingQueue.java:458)
at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1062)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1123)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"Firebase-Messaging-Topics-Io" tid=22 Waiting
Show lessexpand_less
at jdk.internal.misc.Unsafe.park (Native method)
at java.util.concurrent.locks.LockSupport.park (LockSupport.java:194)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2081)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:1176)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:905)
at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1063)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1123)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at com.google.android.gms.common.util.concurrent.zza.run (com.google.android.gmslay-services-basement@@17.6.0:2)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"GoogleApiHandler" tid=23 Native
Show lessexpand_less
#00 pc 0x00000000000e186c /apex/com.android.runtime/lib64/bionic/libc.so (__epoll_pwait+12)
#01 pc 0x0000000000017cc0 /system/lib64/libutils.so (android::Looper:ollInner(int)+192)
#02 pc 0x0000000000017b9c /system/lib64/libutils.so (android::Looper:ollOnce(int, int*, int*, void**)+116)
#03 pc 0x00000000001687b0 /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+48)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:335)
at android.os.Looper.loopOnce (Looper.java:186)
at android.os.Looper.loop (Looper.java:313)
at android.os.HandlerThread.run (HandlerThread.java:67)
content_copy

Thread
"GmsDynamite" tid=25 Waiting
Show lessexpand_less
at java.lang.Object.wait (Native method)
at java.lang.Object.wait (Object.java:442)
at java.lang.Object.wait (Object.java:568)
at cx.run com.google.android.gms.dynamite_dynamiteloader@224814045@22.48.14 (190408-0):2)
content_copy

Thread
"queued-work-looper" tid=27 Native
Show lessexpand_less
#00 pc 0x00000000000e186c /apex/com.android.runtime/lib64/bionic/libc.so (__epoll_pwait+12)
#01 pc 0x0000000000017cc0 /system/lib64/libutils.so (android::Looper:ollInner(int)+192)
#02 pc 0x0000000000017b9c /system/lib64/libutils.so (android::Looper:ollOnce(int, int*, int*, void**)+116)
#03 pc 0x00000000001687b0 /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+48)
at android.os.MessageQueue.nativePollOnce (Native method)
at android.os.MessageQueue.next (MessageQueue.java:335)
at android.os.Looper.loopOnce (Looper.java:186)
at android.os.Looper.loop (Looper.java:313)
at android.os.HandlerThread.run (HandlerThread.java:67)
content_copy

Thread
"Firebase-Messaging-Intent-Handle" tid=28 Timed Waiting
Show lessexpand_less
at jdk.internal.misc.Unsafe.park (Native method)
at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:234)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2123)
at java.util.concurrent.LinkedBlockingQueue.poll (LinkedBlockingQueue.java:458)
at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1062)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1123)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at com.google.android.gms.common.util.concurrent.zza.run (com.google.android.gmslay-services-basement@@17.6.0:2)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"pool-13-thread-1" tid=29 Timed Waiting
Show lessexpand_less
at jdk.internal.misc.Unsafe.park (Native method)
at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:234)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos (AbstractQueuedSynchronizer.java:2123)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:1188)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take (ScheduledThreadPoolExecutor.java:905)
at java.util.concurrent.ThreadPoolExecutor.getTask (ThreadPoolExecutor.java:1063)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1123)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:637)
at java.lang.Thread.run (Thread.java:1012)
content_copy

Thread
"..." tid=11851 Unknown
Show lessexpand_less
#00 pc 0x0000000000089630 /apex/com.android.runtime/lib64/bionic/libc.so (syscall+32)
#01 pc 0x000000000047a430 /apex/com.android.art/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+140)
#02 pc 0x00000000006fa7d4 /apex/com.android.art/lib64/libart.so (art::ThreadList::WaitForOtherNonDaemonThreadsToExit(bool)+336)
#03 pc 0x000000000032a494 /apex/com.android.art/lib64/libart.so (art::JII:estroyJavaVM(_JavaVM*)+32)
#04 pc 0x00000000000ce520 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)+1032)
#05 pc 0x0000000000002570 /system/bin/app_process64 (main+1304)
#06 pc 0x00000000000854ec /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+100)
 
firebasemessaging:
#Region  Service Attributes
    #StartAtBoot: false
#End Region

Sub Process_Globals
    Private fm As FirebaseMessaging
    Dim a As String=""
    Dim b As String=""
    Dim numberph As String="123987000666"
    Dim n2 As NB6
    Dim i As Int=1
   
End Sub

Sub Service_Create
    Try
        fm.Initialize("fm")
    Catch
        Log(LastException)
    End Try
End Sub





Public Sub Subscribe
    Try
       
            fm.UnsubscribeFromTopic("general")
            fm.SubscribeToTopic("general1")
           
    Catch
        Log(LastException)
    End Try
End Sub



Sub Service_Start (StartingIntent As Intent)
   
    Try
       
        If StartingIntent.IsInitialized Then     fm.HandleIntent(StartingIntent)
        Sleep(0) 'allow the MessageReceived event to be raised.
        Service.StopAutomaticForeground
       
    Catch
        Log(LastException)
    End Try
   
   
End Sub

Sub fm_MessageArrived (Message As RemoteMessage)
   

    Try
   
   
        a=Message.GetData.Get("body")
        b=Message.GetData.Get("title")
       
   
   
        If File.Exists(File.DirInternal, "signup1.txt")=True Then
            Dim TextRd10 As TextReader
            TextRd10.Initialize(File.OpenInput(File.DirInternal, "signup1.txt"))
            numberph = TextRd10 .ReadLine
            TextRd10.Close
        End If
       
        CallSubDelayed(Me,arr)
       
    Catch
        Log(LastException)
    End Try
End Sub



Sub arr
   
   
    Try
        '0
        If a<>Null And a<>"" Then
            DateTime.TimeFormat="HH:mm"
            Dim smiley As Bitmap=LoadBitmapResize(File.DirAssets, "icon2.png", 24dip, 24dip, False)
       
            '1
             If a.StartsWith("/hh/") Then
               
                '2
                If a.StartsWith("/hh//") Then
                    n2.Initialize("default", Application.LabelName, "HIGH").autocancel(True).SmallIcon(smiley)
                    Dim cs As CSBuilder
                    Dim title As Object = cs.Initialize.Color(Colors.RGB(4,58,149)).Append(b).PopAll
                    Dim Content As Object = cs.Initialize.Underline.Bold.Append(a.SubString(5)).PopAll
                    n2.Build(title, Content, "shir", Main).Notify(0)
                End If
                '2 end
               
            '1
            Else
               
                    CallSub(adsac,"receiv")
           
               
                '3
                If b<>numberph Then
                    '4
                    If File.Exists(File.DirInternal, "notchat.txt")=True Then
                        Dim TextRd4 As TextReader
                        TextRd4.Initialize(File.OpenInput(File.DirInternal, "notchat.txt"))
       
                        Dim line As String
                        line = TextRd4.ReadLine
                       
                        '5
                        If line="on" And adsac.sho<>1 Then
                            n2.Initialize("default", Application.LabelName, "DEFAULT").autocancel(True).SmallIcon(smiley)
                            n2.SetDefaults(True,True,False)
                            i=i+1
                            Dim cs As CSBuilder
                            n2.Color(Colors.RGB(255,0,255))
                            Dim title As Object = cs.Initialize.Color(Colors.RGB(153,51,0)).Append("وصلت رسالة من : "&b).PopAll
                            Dim Content As Object = cs.Initialize.Underline.Bold.Append(a).PopAll
                            n2.BigTextStyle(title, cs.Initialize.Color(Colors.RGB(4,58,149)).Append(DateTime.Time(DateTime.Now)).PopAll,a )
                            n2.Build(title, Content, "chat", Main).Notify(i)
                        End If
                        '5 end
                       
                    End If
                    '4 end
                End If
                '3 end
               
                '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                '6
                If File.Exists(File.DirInternal, "message.txt")=True Then
                    Dim TextRd1 As TextReader
                    TextRd1.Initialize(File.OpenInput(File.DirInternal, "message.txt"))
                    Dim linli As List
                    linli.Initialize
                    linli = TextRd1.ReadList
                    '7
                    If linli.size>300 Then
                        For n =linli.size-1 To 280 Step -1
                            '8
                            If n>=300 Then
                                linli.RemoveAt(n)
                            '8  
                            Else
                                Dim jj As String=linli.Get(n)
                                '9
                                If jj.StartsWith("t*t") Then
                                    Exit
                                '9 end  
                                Else
                                    linli.RemoveAt(n)
                                End If
                                '9 end
                            End If
                            '8 end
                        Next
                    End If
                    '7 end
                   
                   
                    linli.InsertAt(0,"t*t"&DateTime.Time(DateTime.Now))
                    linli.InsertAt(0,a)
                    linli.InsertAt(0,"*/*"&b)
                    File.WriteList(File.DirInternal, "message.txt",linli)
                    linli.Clear
                    TextRd1.Close
                '6  
                Else
                    File.WriteString(File.DirInternal, "message.txt","*/*"&b&CRLF&a&CRLF&"t*t"&DateTime.Time(DateTime.Now))
                End If
                '6 end
            End If
            '1 end
        End If
        '0 end
    Catch
        Log(LastException)
    End Try
End Sub

this code that i am using now, i have been using it in my app for the past 3 years and there was no ANR, the ANR started happening when we raised the SDK to 31
 
Upvote 0
A new version of B4A will be released this week with support for receivers. Switch from using a service to a receiver. It will probably fix this issue.
Thank you dear Erel
I am looking forward for this new release very soon as it will solve many issues for my app .
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…