Android Question Are ANR related to callsub functions ?

hookshy

Well-Known Member
Licensed User
Just thought that inproper use of callsub might cause the app to wait for a value .... if there is a commun mistake about using this function
callsub , callsub2 or callsubdelayed please share
 

hookshy

Well-Known Member
Licensed User
I am trying to find out why my app is faceing this AnR issue all the time

Q : if I call a fuction that it was supposed to return a value and the stack is empty ... the program may wait for that returned value and trigger an ANR ?
 

hookshy

Well-Known Member
Licensed User
my logs recently does not work on huawey ascend and one of my tablets... I can not open emulator as well so I can not check any logs for the moment will try to fix this ...then catch the ANR
 

hookshy

Well-Known Member
Licensed User
Here is one of my ANR code unfortunately I do not understand a thing here can anyone give me a clue

B4X:
----- pid 25478 at 2015-03-25 22:37:06 -----
Cmd line: com.hsw.voice_lite

JNI: CheckJNI is off; workarounds are off; pins=0; globals=312

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)

"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x418f3f00 self=0x418e2760
| sysTid=25478 nice=0 sched=0/0 cgrp=apps handle=1074626900
| state=S schedstat=( 1430308611 324581878 2300 ) utm=129 stm=14 core=0
#00 pc 00021268 /system/lib/libc.so (epoll_wait+12)
#01 pc 0001063f /system/lib/libutils.so (android::Looper::pollInner(int)+98)
#02 pc 00010869 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92)
#03 pc 0006b3b9 /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
#04 pc 0002064c /system/lib/libdvm.so (dvmPlatformInvoke+112)
#05 pc 00051307 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#06 pc 00029ae0 /system/lib/libdvm.so
#07 pc 00030f6c /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#08 pc 0002e604 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#09 pc 00063ad9 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+392)
#10 pc 0006bb2f /system/lib/libdvm.so
#11 pc 00029ae0 /system/lib/libdvm.so
#12 pc 00030f6c /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#13 pc 0002e604 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#14 pc 000637f5 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
#15 pc 0004cec7 /system/lib/libdvm.so
#16 pc 0004df73 /system/lib/libandroid_runtime.so
#17 pc 0004ed3b /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+386)
#18 pc 0000105b /system/bin/app_process
#19 pc 0000e2eb /system/lib/libc.so (__libc_init+50)
#20 pc 00000d7c /system/bin/app_process
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:138)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:5336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)
at dalvik.system.NativeStart.main(Native Method)

"AsyncTask #5" prio=5 tid=14 WAIT
| group="main" sCount=1 dsCount=0 obj=0x4207a5c0 self=0x765f8ea8
| sysTid=25498 nice=0 sched=0/0 cgrp=apps handle=1986129120
| state=S schedstat=( 1960831 4209429 28 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x4207a718> (a java.lang.VMThread) held by tid=14 (AsyncTask #5)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

"AsyncTask #4" prio=5 tid=13 WAIT
| group="main" sCount=1 dsCount=0 obj=0x420775f0 self=0x765f8a50
| sysTid=25497 nice=0 sched=0/0 cgrp=apps handle=1986132312
| state=S schedstat=( 5355367 3918490 42 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x42077790> (a java.lang.VMThread) held by tid=13 (AsyncTask #4)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

"AsyncTask #3" prio=5 tid=12 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42076440 self=0x765f7d48
| sysTid=25496 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1986131256
| state=S schedstat=( 4395624 3195107 31 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42076560> (a java.lang.VMThread) held by tid=12 (AsyncTask #3)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)

"AsyncTask #2" prio=5 tid=11 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42072578 self=0x765f78f0
| sysTid=25495 nice=0 sched=0/0 cgrp=apps handle=1986130200
| state=S schedstat=( 3974583 1682449 42 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x420726f0> (a java.lang.VMThread) held by tid=11 (AsyncTask #2)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
 

hookshy

Well-Known Member
Licensed User
Here is a code that I susspect to be the cause of ANR ....
It may be possible that reading contacts list to last long enough for the OS to execute
last line ...saveing to disk ? and this to cause the ANR

How can I prevent ...this ...I tried to remove contact reading and no ANR was triggered ...
but I am not 100% sure
B4X:
ct_list=ct.GetAll(True,False)
    File.WriteList(File.DirInternal,"ct_list.txt",ct_list)


Seccond track would be ...
do events
p.SetScreenOrientation(1)

This I found in activity resume
 
Last edited:

hookshy

Well-Known Member
Licensed User
I have turned off contacts syncronising and the ANR is still there ... I am still working on free up some unused code lines

If there is an example of forced generated ANR code it would great to see it ...
 
Top