Android ANR 分析
首先贴一下trace 文件
Process: com.oppo.reader
PID: 20358
Time: 2933175644_1545041895232
Flags: 0x38d83e44
Package: com.oppo.reader v62301 (6.2.3.20181030)
PID: 20358
Foreground: Yes
Activity: com.oppo.reader/com.zhangyue.iReader.read.ui.Activity_BookBrowser_TXT
Subject: Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 2. Wait queue head age: 8825.0ms.)
Build: OPPO/PBFM00/PBFM00:8.1.0/OPM1.171019.026/1541766248:user/release-keys
CPU usage from 0ms to 6451ms later (2018-12-17 18:18:08.726 to 2018-12-17 18:18:15.177):
100% 20358/com.oppo.reader: 97% user + 3.5% kernel / faults: 4111 minor 3 major
39% 1895/system_server: 27% user + 11% kernel / faults: 3126 minor 26 major
0.2% 1167/media.codec: 0.2% user + 0% kernel / faults: 4081 minor
4% 17827/com.android.systemui: 3.2% user + 0.7% kernel / faults: 1640 minor 224 major
3.7% 2835/com.android.phone: 3.2% user + 0.4% kernel / faults: 434 minor
3.4% 687/surfaceflinger: 2.4% user + 0.9% kernel / faults: 454 minor
2.4% 11552/kworker/u16:8: 0% user + 2.4% kernel
0% 1155/media.extractor: 0% user + 0% kernel / faults: 2832 minor
1.2% 654/android.hardware.graphics.composer@2.1-service: 0.7% user + 0.4% kernel / faults: 11 minor
1.2% 17450/com.coloros.floatassistant:float: 1% user + 0.1% kernel / faults: 146 minor
1% 451/logd: 0% user + 1% kernel / faults: 10 minor
0% 3789/com.coloros.appmanager: 0% user + 0% kernel / faults: 270 minor
0.9% 21424/klogd: 0.3% user + 0.6% kernel / faults: 1 minor
0.7% 659/android.hardware.sensors@1.0-service: 0.1% user + 0.6% kernel
0.7% 10558/kworker/u16:0: 0% user + 0.7% kernel
0% 17711/com.oppo.gestureservice: 0% user + 0% kernel / faults: 407 minor
0% 17730/com.color.eyeprotect: 0% user + 0% kernel / faults: 592 minor
0% 17754/com.oppo.resmonitor: 0% user + 0% kernel / faults: 597 minor 5 major
0.7% 21425/xkit_10: 0.7% user + 0% kernel
0.6% 86/kcompactd0: 0% user + 0.6% kernel
0.6% 11551/kworker/u16:7: 0% user + 0.6% kernel
0.6% 21426/xkit_10: 0.3% user + 0.3% kernel / faults: 6 minor
0.4% 329/mmc-cmdqd/0: 0% user + 0.4% kernel
0.4% 424/ueventd: 0.1% user + 0.3% kernel
0.4% 452/servicemanager: 0.3% user + 0.1% kernel
0.4% 14513/irq/280-touchpa: 0% user + 0.4% kernel
0.3% 1//init: 0% user + 0.3% kernel / faults: 19 minor
0.3% 138/kswapd0: 0% user + 0.3% kernel
0.3% 245/kgsl_worker_thr: 0% user + 0.3% kernel
0.3% 3492/neo: 0.3% user + 0% kernel
0.3% 14491/mdss_fb0: 0% user + 0.3% kernel
0.3% 17688/com.coloros.exserviceui: 0.1% user + 0.1% kernel / faults: 9 minor 1 major
0.1% 7/rcu_preempt: 0% user + 0.1% kernel
0.1% 21/rcuop/1: 0% user + 0.1% kernel
0% 423/kworker/0:1H: 0% user + 0% kernel
0.1% 658/android.hardware.power@1.0-service: 0.1% user + 0% kernel
0.1% 740/sensors.qcom: 0.1% user + 0% kernel / faults: 3 minor
0.1% 1030/kworker/10:0: 0% user + 0.1% kernel
0.1% 1134/cameraserver: 0% user + 0.1% kernel / faults: 26 minor
0% 1136/drmserver: 0% user + 0% kernel / faults: 91 minor 3 major
0% 1154/mediadrmserver: 0% user + 0% kernel / faults: 181 minor 59 major
0% 1159/mediaserver: 0% user + 0% kernel / faults: 34 minor
0.1% 1168/rild: 0% user + 0.1% kernel / faults: 2 minor
0% 1170/zygote64: 0% user + 0% kernel / faults: 25 minor
0.1% 1177/zygote: 0% user + 0.1% kernel / faults: 16 minor
0% 1223/tombstoned: 0% user + 0% kernel
0.1% 1261/imsdatadaemon: 0% user + 0.1% kernel
0.1% 1330/rild: 0.1% user + 0% kernel
0.1% 12333/com.tencent.mobileqq:MSF: 0.1% user + 0% kernel / faults: 45 minor 99 major
0.1% 12352/com.tencent.mobileqq: 0% user + 0.1% kernel / faults: 45 minor 113 major
0.1% 13204/com.tencent.mm: 0.1% user + 0% kernel / faults: 22 minor 69 major
0.1% 13717/com.tencent.mm:tools: 0.1% user + 0% kernel / faults: 179 minor 322 major
0.1% 14509/logcat: 0.1% user + 0% kernel
0.1% 14782/kworker/3:3: 0% user + 0.1% kernel
0.1% 19348/com.android.browser: 0.1% user + 0% kernel / faults: 77 minor 129 major
0.1% 19469/logcat: 0% user + 0.1% kernel
0.1% 19738/kworker/1:2: 0% user + 0.1% kernel
0.1% 20519/kworker/2:3: 0% user + 0.1% kernel
0.1% 20821/kworker/0:1: 0% user + 0.1% kernel
0.1% 20849/diag_mdlog: 0% user + 0.1% kernel
0.1% 21334/cat: 0% user + 0.1% kernel
0.1% 21428/logcat: 0% user + 0.1% kernel
26% TOTAL: 20% user + 4.6% kernel + 0.5% iowait + 0.3% irq + 0.1% softirq
----- pid 20358 at 2018-12-17 18:18:09 -----
Cmd line: com.oppo.reader
Build fingerprint: 'OPPO/PBFM00/PBFM00:8.1.0/OPM1.171019.026/1541766248:user/release-keys'
ABI: 'arm'
Build type: optimized
Zygote loaded classes=5110 post zygote classes=3166
Intern table: 52731 strong; 145 weak
JNI: CheckJNI is off; globals=727 (plus 79 weak)
Libraries: /data/app/com.oppo.reader-NTuEuWlogpCo1aD9HtyDhQ==/lib/arm/libUiControl.so /data/app/com.oppo.reader-NTuEuWlogpCo1aD9HtyDhQ==/lib/arm/libtingReader.so /system/app/WebViewGoogleNX/WebViewGoogleNX.apk!/lib/armeabi-v7a/libwebviewchromium.so /system/lib/libandroid.so /system/lib/libcompiler_rt.so /system/lib/libjavacrypto.so /system/lib/libjnigraphics.so /system/lib/libmedia_jni.so /system/lib/libqti_performance.so /system/lib/libsoundpool.so /system/lib/libwebviewchromium_loader.so /system/lib/libwebviewchromium_plat_support.so libjavacore.so libopenjdk.so (14)
Heap: 24% free, 16MB/22MB; 262809 objects
Dumping cumulative Gc timings
Start Dumping histograms for 8 iterations for concurrent copying
ProcessMarkStack: Sum: 430.463ms 99% C.I. 12.291ms-126.080ms Avg: 53.807ms Max: 127.672ms
ScanImmuneSpaces: Sum: 94.022ms 99% C.I. 8.543ms-24.656ms Avg: 11.752ms Max: 25.146ms
VisitConcurrentRoots: Sum: 44.525ms 99% C.I. 4.612ms-8.508ms Avg: 5.565ms Max: 8.527ms
SweepLargeObjects: Sum: 26.256ms 99% C.I. 1.062ms-8.484ms Avg: 3.282ms Max: 8.507ms
ClearFromSpace: Sum: 13.381ms 99% C.I. 0.359ms-3.134ms Avg: 1.672ms Max: 3.145ms
GrayAllDirtyImmuneObjects: Sum: 11.950ms 99% C.I. 0.352ms-8.112ms Avg: 1.493ms Max: 8.351ms
FlipOtherThreads: Sum: 10.679ms 99% C.I. 0.956ms-2.934ms Avg: 1.334ms Max: 2.969ms
MarkZygoteLargeObjects: Sum: 7.665ms 99% C.I. 45us-6824us Avg: 958.125us Max: 7023us
EnqueueFinalizerReferences: Sum: 5.876ms 99% C.I. 95us-2168us Avg: 734.500us Max: 2168us
ProcessReferences: Sum: 5.800ms 99% C.I. 4us-1463us Avg: 362.500us Max: 1463us
InitializePhase: Sum: 5.308ms 99% C.I. 220us-3006us Avg: 663.500us Max: 3061us
ForwardSoftReferences: Sum: 4.183ms 99% C.I. 14us-800us Avg: 522.875us Max: 800us
SweepSystemWeaks: Sum: 4.176ms 99% C.I. 306us-1172us Avg: 522us Max: 1190us
RecordFree: Sum: 1.808ms 99% C.I. 145us-671us Avg: 226us Max: 671us
VisitNonThreadRoots: Sum: 1.565ms 99% C.I. 154us-286us Avg: 195.625us Max: 286us
MarkingPhase: Sum: 1.317ms 99% C.I. 32us-916us Avg: 164.625us Max: 948us
ThreadListFlip: Sum: 781us 99% C.I. 57us-239us Avg: 97.625us Max: 239us
EmptyRBMarkBitStack: Sum: 727us 99% C.I. 13us-282us Avg: 90.875us Max: 282us
MarkStackAsLive: Sum: 433us 99% C.I. 37us-73us Avg: 54.125us Max: 73us
(Paused)GrayAllNewlyDirtyImmuneObjects: Sum: 430us 99% C.I. 39us-124us Avg: 53.750us Max: 124us
ReclaimPhase: Sum: 241us 99% C.I. 17us-78us Avg: 30.125us Max: 78us
ResumeOtherThreads: Sum: 232us 99% C.I. 6us-145us Avg: 29us Max: 145us
ResumeRunnableThreads: Sum: 215us 99% C.I. 13us-50us Avg: 26.875us Max: 50us
ClearRegionSpaceCards: Sum: 198us 99% C.I. 10us-61us Avg: 24.750us Max: 61us
SweepAllocSpace: Sum: 147us 99% C.I. 6us-32us Avg: 18.375us Max: 32us
SwapBitmaps: Sum: 124us 99% C.I. 11us-20us Avg: 15.500us Max: 20us
(Paused)SetFromSpace: Sum: 105us 99% C.I. 3us-42us Avg: 13.125us Max: 42us
(Paused)ClearCards: Sum: 79us 99% C.I. 250ns-7000ns Avg: 395ns Max: 7000ns
Sweep: Sum: 71us 99% C.I. 6us-11us Avg: 8.875us Max: 11us
(Paused)FlipCallback: Sum: 57us 99% C.I. 4us-19us Avg: 7.125us Max: 19us
FlipThreadRoots: Sum: 35us 99% C.I. 3us-9us Avg: 4.375us Max: 9us
UnBindBitmaps: Sum: 16us 99% C.I. 2us-2us Avg: 2us Max: 2us
Done Dumping histograms
concurrent copying paused: Sum: 1.499ms 99% C.I. 133us-458us Avg: 187.375us Max: 458us
concurrent copying total time: 672.865ms mean time: 84.108ms
concurrent copying freed: 558166 objects with total size 84MB
concurrent copying throughput: 830604/s / 125MB/s
Cumulative bytes moved 12844720
Cumulative objects moved 272799
Total time spent in GC: 672.865ms
Mean GC size throughput: 65MB/s
Mean GC object throughput: 827833 objects/s
Total number of allocations 819829
Total bytes allocated 60MB
Total bytes freed 44MB
Free memory 5MB
Free memory until GC 5MB
Free memory until OOME 495MB
Total memory 22MB
Max memory 512MB
Zygote space size 780KB
Total mutator paused time: 1.499ms
Total time waiting for GC to complete: 34.535us
Total GC count: 8
Total GC time: 672.865ms
Total blocking GC count: 0
Total blocking GC time: 0
Histogram of GC count per 10000 ms: 0:8,1:3,4:1
Histogram of blocking GC count per 10000 ms: 0:12
Registered native bytes allocated: 23662650
/data/app/com.oppo.reader-NTuEuWlogpCo1aD9HtyDhQ==/oat/arm/base.odex: quicken
/system/app/WebViewGoogleNX/oat/arm/WebViewGoogleNX.odex: quicken
/data/app/com.oppo.reader-NTuEuWlogpCo1aD9HtyDhQ==/oat/arm/base.odex: quicken
Current JIT code cache size: 144KB
Current JIT data cache size: 107KB
Current JIT capacity: 512KB
Current number of JIT code cache entries: 124
Total number of JIT compilations: 147
Total number of JIT compilations for on stack replacement: 4
Total number of JIT code cache collections: 4
Memory used for stack maps: Avg: 565B Max: 6KB Min: 24B
Memory used for compiled code: Avg: 1277B Max: 9KB Min: 2B
Memory used for profiling info: Avg: 268B Max: 3KB Min: 16B
Start Dumping histograms for 151 iterations for JIT timings
Compiling: Sum: 873.725ms 99% C.I. 0.149ms-48.568ms Avg: 5.943ms Max: 56.411ms
TrimMaps: Sum: 12.710ms 99% C.I. 8us-689.750us Avg: 86.462us Max: 772us
Code cache collection: Sum: 5.165ms 99% C.I. 0.877ms-2.372ms Avg: 1.291ms Max: 2.395ms
Done Dumping histograms
Memory used for compilation: Avg: 231KB Max: 2MB Min: 15KB
ProfileSaver total_bytes_written=0
ProfileSaver total_number_of_writes=0
ProfileSaver total_number_of_code_cache_queries=2
ProfileSaver total_number_of_skipped_writes=2
ProfileSaver total_number_of_failed_writes=0
ProfileSaver total_ms_of_sleep=101716
ProfileSaver total_ms_of_work=60
ProfileSaver max_number_profile_entries_cached=0
ProfileSaver total_number_of_hot_spikes=2
ProfileSaver total_number_of_wake_ups=4
Number of JIT inline cache deoptimizations: 2
suspend all histogram: Sum: 1.234ms 99% C.I. 9us-160.399us Avg: 31.641us Max: 169us
DALVIK THREADS (70):
"Signal Catcher" daemon prio=5 tid=3 Runnable
| group="system" sCount=0 dsCount=0 flags=0 obj=0x13500280 self=0xe6c0fc00
| sysTid=20364 nice=0 cgrp=default sched=0/0 handle=0xdcbfe970
| state=R schedstat=( 27239057 2910573 19 ) utm=2 stm=0 core=0 HZ=100
| stack=0xdcb04000-0xdcb06000 stackSize=1006KB
| held mutexes= "mutator lock"(shared held)
native: #00 pc 002e8b57 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, int, BacktraceMap*, char const*, art::ArtMethod*, void*)+130)
native: #01 pc 0037b7f9 /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+204)
native: #02 pc 00377d2b /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool, BacktraceMap*, bool) const+34)
native: #03 pc 0038f8fb /system/lib/libart.so (art::DumpCheckpoint::Run(art::Thread*)+698)
native: #04 pc 0038947d /system/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure*, art::Closure*)+320)
native: #05 pc 00388f7b /system/lib/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, bool)+530)
native: #06 pc 00388c9b /system/lib/libart.so (art::ThreadList::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char>>&)+626)
native: #07 pc 003652d3 /system/lib/libart.so (art::Runtime::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char>>&)+122)
native: #08 pc 0036d9b3 /system/lib/libart.so (art::SignalCatcher::HandleSigQuit()+1282)
native: #09 pc 0036c91b /system/lib/libart.so (art::SignalCatcher::Run(void*)+330)
native: #10 pc 000473f3 /system/lib/libc.so (__pthread_start(void*)+22)
native: #11 pc 0001afb1 /system/lib/libc.so (__start_thread+32)
(no managed stack frames)
"main" prio=5 tid=1 Blocked
| group="main" sCount=1 dsCount=0 flags=1 obj=0x71ebca68 self=0xe6c0f000
| sysTid=20358 nice=-10 cgrp=default sched=0/0 handle=0xea9254a4
| state=S schedstat=( 2882074832 469149273 2373 ) utm=241 stm=47 core=1 HZ=100
| stack=0xff789000-0xff78b000 stackSize=8MB
| held mutexes=
at com.zhangyue.iReader.DB.DBAdapter.execSQL(SourceFile:2512)
- waiting to lock <0x08d75003> (a com.zhangyue.iReader.DB.DBAdapter) held by thread 66
at com.zhangyue.iReader.DB.DBAdapter.queryBookIDWithoutPath(SourceFile:1497)
at com.zhangyue.iReader.read.ui.BookBrowserFragment.u(SourceFile:1223)
at com.zhangyue.iReader.read.ui.BookBrowserFragment.U(SourceFile:368)
at com.zhangyue.iReader.read.ui.cc.run(SourceFile:3098)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:7038)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:519)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)
"Jit thread pool worker thread 0" daemon prio=5 tid=2 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x135001f8 self=0xdcd1f000
| sysTid=20363 nice=9 cgrp=default sched=0/0 handle=0xdccff970
| state=S schedstat=( 803558025 113797923 579 ) utm=76 stm=4 core=6 HZ=100
| stack=0xdcc01000-0xdcc03000 stackSize=1022KB
| held mutexes=
kernel: (couldn't read /proc/self/task/20363/stack)
native: #00 pc 00018e20 /system/lib/libc.so (syscall+28)
native: #01 pc 000b79d1 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+80)
native: #02 pc 00390b81 /system/lib/libart.so (art::ThreadPool::GetTask(art::Thread*)+172)
native: #03 pc 003904f7 /system/lib/libart.so (art::ThreadPoolWorker::Run()+62)
native: #04 pc 00390115 /system/lib/libart.so (art::ThreadPoolWorker::Callback(void*)+92)
native: #05 pc 000473f3 /system/lib/libc.so (__pthread_start(void*)+22)
native: #06 pc 0001afb1 /system/lib/libc.so (__start_thread+32)
(no managed stack frames)
"ReferenceQueueDaemon" daemon prio=5 tid=4 Waiting
| group="system" sCount=1 dsCount=0 flags=1 obj=0x13500308 self=0xdca14600
| sysTid=20365 nice=4 cgrp=default sched=0/0 handle=0xc9e29970
| state=S schedstat=( 34968799 11582865 55 ) utm=2 stm=1 core=4 HZ=100
| stack=0xc9d27000-0xc9d29000 stackSize=1038KB
| held mutexes=
at java.lang.Object.wait(Native method)
- waiting on <0x03602b80> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
at java.lang.Daemons$ReferenceQueueDaemon.runInternal(Daemons.java:183)
- locked <0x03602b80> (a java.lang.Class<java.lang.ref.ReferenceQueue>)
at java.lang.Daemons$Daemon.run(Daemons.java:108)
at java.lang.Thread.run(Thread.java:764)
"OkHttp https://icloud.zhangyue.com/..." prio=5 tid=66 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x133c0a30 self=0xc4ca9200
| sysTid=21822 nice=0 cgrp=default sched=0/0 handle=0xbe396970
| state=S schedstat=( 14565089915 55131141 764 ) utm=1423 stm=33 core=2 HZ=100
| stack=0xbe294000-0xbe296000 stackSize=1038KB
| held mutexes=
kernel: (couldn't read /proc/self/task/21822/stack)
native: #00 pc 00018e20 /system/lib/libc.so (syscall+28)
native: #01 pc 000b79d1 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+80)
native: #02 pc 003e2949 /system/lib/libart.so (art::GoToRunnable(art::Thread*)+300)
native: #03 pc 003e27ed /system/lib/libart.so (art::JniMethodEnd(unsigned int, art::Thread*)+8)
native: #04 pc 00404d45 /system/framework/arm/boot-framework.oat (Java_android_database_sqlite_SQLiteConnection_nativeExecuteForChangedRowCount__JJ+132)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native method)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:748)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1658)
at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1604)
at com.zhangyue.iReader.DB.a.update(SourceFile:129)
at com.zhangyue.iReader.DB.DBAdapter.update(SourceFile:4224)
at dt.d.b(SourceFile:112)
at com.zhangyue.iReader.DB.DBAdapter.updateHighLightByPostion(SourceFile:1657)
at df.t.b(SourceFile:269)
- locked <0x08d75003> (a com.zhangyue.iReader.DB.DBAdapter)
at df.t.a(SourceFile:66)
at df.al.a(SourceFile:118)
at df.am.onHttpEvent(SourceFile:88)
at com.zhangyue.net.p$b.onHttpEvent(SourceFile:138)
at com.zhangyue.net.a.a(SourceFile:796)
at com.zhangyue.net.a.a(SourceFile:63)
at com.zhangyue.net.c.onResponse(SourceFile:698)
at okhttp3.RealCall$AsyncCall.execute(SourceFile:153)
at okhttp3.internal.NamedRunnable.run(SourceFile:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
开头会告诉你,是哪个包ANR 了。所以,以后搜索ANR 可以在log 里面搜索:
Cmd line: com.oppo.reader
后面替换成你的包名。
第一步:查看主线程
"main" prio=5 tid=1 Blocked
| group="main" sCount=1 dsCount=0 flags=1 obj=0x71ebca68 self=0xe6c0f000
| sysTid=20358 nice=-10 cgrp=default sched=0/0 handle=0xea9254a4
| state=S schedstat=( 2882074832 469149273 2373 ) utm=241 stm=47 core=1 HZ=100
| stack=0xff789000-0xff78b000 stackSize=8MB
| held mutexes=
at com.zhangyue.iReader.DB.DBAdapter.execSQL(SourceFile:2512)
- waiting to lock <0x08d75003> (a com.zhangyue.iReader.DB.DBAdapter) held by thread 66
at com.zhangyue.iReader.DB.DBAdapter.queryBookIDWithoutPath(SourceFile:1497)
at com.zhangyue.iReader.read.ui.BookBrowserFragment.u(SourceFile:1223)
at com.zhangyue.iReader.read.ui.BookBrowserFragment.U(SourceFile:368)
at com.zhangyue.iReader.read.ui.cc.run(SourceFile:3098)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:7038)
at java.lang.reflect.Method.invoke(Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:519)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)
- waiting to lock <0x08d75003> (a com.zhangyue.iReader.DB.DBAdapter) held by thread 66
他说,在等待一个锁,0x08d75003。 你可以在trace 里面搜索这个字符,或者后面说,held by thread 66,那就搜索线程66
tid=66
第二步:找到线程66
"OkHttp https://icloud.zhangyue.com/..." prio=5 tid=66 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x133c0a30 self=0xc4ca9200
| sysTid=21822 nice=0 cgrp=default sched=0/0 handle=0xbe396970
| state=S schedstat=( 14565089915 55131141 764 ) utm=1423 stm=33 core=2 HZ=100
| stack=0xbe294000-0xbe296000 stackSize=1038KB
| held mutexes=
kernel: (couldn't read /proc/self/task/21822/stack)
native: #00 pc 00018e20 /system/lib/libc.so (syscall+28)
native: #01 pc 000b79d1 /system/lib/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+80)
native: #02 pc 003e2949 /system/lib/libart.so (art::GoToRunnable(art::Thread*)+300)
native: #03 pc 003e27ed /system/lib/libart.so (art::JniMethodEnd(unsigned int, art::Thread*)+8)
native: #04 pc 00404d45 /system/framework/arm/boot-framework.oat (Java_android_database_sqlite_SQLiteConnection_nativeExecuteForChangedRowCount__JJ+132)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(Native method)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:748)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:754)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:64)
at android.database.sqlite.SQLiteDatabase.updateWithOnConflict(SQLiteDatabase.java:1658)
at android.database.sqlite.SQLiteDatabase.update(SQLiteDatabase.java:1604)
at com.zhangyue.iReader.DB.a.update(SourceFile:129)
at com.zhangyue.iReader.DB.DBAdapter.update(SourceFile:4224)
at dt.d.b(SourceFile:112)
at com.zhangyue.iReader.DB.DBAdapter.updateHighLightByPostion(SourceFile:1657)
at df.t.b(SourceFile:269)
- locked <0x08d75003> (a com.zhangyue.iReader.DB.DBAdapter)
at df.t.a(SourceFile:66)
at df.al.a(SourceFile:118)
at df.am.onHttpEvent(SourceFile:88)
at com.zhangyue.net.p$b.onHttpEvent(SourceFile:138)
at com.zhangyue.net.a.a(SourceFile:796)
at com.zhangyue.net.a.a(SourceFile:63)
at com.zhangyue.net.c.onResponse(SourceFile:698)
at okhttp3.RealCall$AsyncCall.execute(SourceFile:153)
at okhttp3.internal.NamedRunnable.run(SourceFile:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
问下了同事, - locked <0x08d75003> (a com.zhangyue.iReader.DB.DBAdapter) 表示,从这行的堆栈开始,进入synchronized 代码块。(至于是不是,可以自己去获取堆栈,尝试下。)
那么,也就是在这里,子线程执行代码,占用了 - locked <0x08d75003> (a com.zhangyue.iReader.DB.DBAdapter)这个锁。
第三步:处理
怎么处理呢?
- 把没有用的锁,去掉。程序里面不要随意的加锁
- 我们这里是因为一大坨代码,都写在了执行事务里,导致,执行事务的时候,占用了SQLite 链接。导致主线程拿不到SQLite 的锁。
其他技巧
1.如果你觉得是某一块代码执行时间过长导致ANR,那么可以把这一块代码换成下面这个,看看会不会ANR.
long begin = System.currentTimeMillis();
while(System.currentTimeMillis() - begin < 1000 * 60 * 10){
a = 50;
DBAdapter.getInstance().queryALLBook();
}
上面这块代码,会执行10分钟。里面不停的执行SQL 操作。
Android ANR 分析的更多相关文章
- Android ANR 分析解决方法
一:什么是ANR ANR:Application Not Responding,即应用无响应 二:ANR的类型 ANR一般有三种类型: 1. KeyDispatchTimeout(5 seconds) ...
- Android ANR分析(2)
转自:http://blog.csdn.net/ruingman/article/details/53118202 定义 主线程在特定的时间内没有做完特定的事情 常见的场景 A.input事件超过 ...
- Android ANR分析(1)
转自:http://blog.csdn.net/itachi85/article/details/6918761 一:什么是ANR ANR:Application Not Responding,即应用 ...
- android anr分析方法
目录(?)[+] 案例1关键词ContentResolver in AsyncTask onPostExecute high iowait 案例2关键词在UI线程进行网络数据的读写 一:什么是AN ...
- Android ANR分析及解决方案
一:什么是ANR ANR:Application Not Responding,即应用无响应. ANR定义:在Android上,如果你的应用程序有一段时间响应不够灵敏,系统会向用户显示一个对话框,这个 ...
- [转]Android ANR 分析解决方法
一:什么是ANR ANR:Application Not Responding,即应用无响应 二:ANR的类型 ANR一般有三种类型: 1. KeyDispatchTimeout(5 seconds) ...
- android ANR 分析定位问题
ANR ? android 规定,Activity如果5秒钟之内无法响应屏幕触摸事件或者键盘输入事件,BroadcastReceiver 如果10s中之内还未执行完操作就会出现ANR 定位ANR问题 ...
- Android ANR分析(三)
http://www.jianshu.com/p/8964812972be http://stackoverflow.com/questions/704311/android-how-do-i-inv ...
- Android ANR分析
1.发生anr时手机会生产traces文件 拉取trace文件:adb pull data/anr/traces.txt ./mytraces.txt 保存路径 参考
随机推荐
- 从数据流角度管窥 Moya 的实现(一):构建请求
相信大家都封装过网络层. 虽然系统提供的网络库以及一些著名的第三方网络库(AFNetworking, Alamofire)已经能满足各种 HTTP/HTTPS的网络请求,但直接在代码里用起来,终归是比 ...
- 【luogu P2762 太空飞行计划问题】 题解
题目链接:https://www.luogu.org/problemnew/show/P2762 算是拍照那个题的加强下. 输入真的很毒瘤.(都这么说但好像我的过了?) #include <qu ...
- java操作文件常用的 IO流对象
1.描述:流是字节数据或字符数据序列.Java采用输入流对象和输出流对象来支持程序对数据的输入和输出.输入流对象提供了数据从源点流向程序的管道,程序可以从输入流对象读取数据:输出流对象提供了数据从程序 ...
- idea开启自动编译
springboot+thymeleaf+idea idea默认是不自动编译的. 首先热部署的jar包肯定是要加进去的 2,快捷键 ctrl+shift+alt+/ 点击registr ...
- React性能优化总结(转)
原文链接: https://segmentfault.com/a/1190000007811296?utm_source=tuicool&utm_medium=referral 初学者对Rea ...
- string类中字符的大小写转换
今天做一道题,要用string类,涉及大小写转换,查看了C++文档,string类没有提供这样的方法,只好自己写. 之后是想到一个比较笨的方法,我把string当成一个容器,然后用迭代器一个一个来替换 ...
- 【TOJ 4475】The Coolest Sub-matrix(对角线前缀和)
描述 Given an N*N matrix, find the coolest square sub-matrix.We define the cool value of the square ma ...
- mysql系列一
学习mysql必备工具即安装mysql客户端:mysql安装教程在网上有很多,在此处就不在仔细说明: 下面将仔细介绍一下关于SQL语句: SQL语句:结构化查询语言(Structured Query ...
- MyEclipse格式化JSP代码,其中Javascript无法格式化的原因
MyEclipse格式化JSP代码,其中Javascript无法格式化的原因: 可能是JSP页面代码有错误的地方,而且可能是一个很微小的错误,比如多写了一个标点符号,这个需要仔细检查,包括HTML.C ...
- 因为之前完全没有接触过Spring,所以准备先把spring实战看完再落实项目
因为之前完全没有接触过Spring,所以准备先把spring实战看完再落实项目