我是靠谱客的博主 要减肥大侠,最近开发中收集的这篇文章主要介绍setImageResource导致的ANR,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

----- pid 3076 at 2020-10-20 20:35:33 -----
Cmd line: com.tcl.settings
Build fingerprint: ‘Mstar/X5/X5:8.0.0/OPR5.170623.014/ydi10192302:user/dev-keys’
ABI: ‘arm64’
Build type: optimized
Zygote loaded classes=4624 post zygote classes=1550
Intern table: 44709 strong; 133 weak
JNI: CheckJNI is off; globals=540 (plus 38 weak)
Libraries: /system/lib64/libandroid.so /system/lib64/libcom_tcl_tv_jni.so /system/lib64/libcompiler_rt.so /system/lib64/libjavacrypto.so /system/lib64/libjnigraphics.so /system/lib64/libmedia_jni.so /system/lib64/libsoundpool.so /system/lib64/libwebviewchromium_loader.so libjavacore.so libopenjdk.so (10)
Heap: 47% free, 1752KB/3MB; 30085 objects
Dumping cumulative Gc timings
Start Dumping histograms for 4 iterations for concurrent copying
ProcessMarkStack: Sum: 237.276ms 99% C.I. 27.644ms-121.824ms Avg: 59.319ms Max: 122.116ms
VisitConcurrentRoots: Sum: 76.924ms 99% C.I. 6.302ms-40.336ms Avg: 19.231ms Max: 40.537ms
ScanImmuneSpaces: Sum: 73.240ms 99% C.I. 1.224ms-52.032ms Avg: 18.310ms Max: 52.719ms
GrayAllDirtyImmuneObjects: Sum: 72.990ms 99% C.I. 0.395ms-63.648ms Avg: 18.247ms Max: 64.078ms
FlipOtherThreads: Sum: 66.427ms 99% C.I. 1.905ms-50.400ms Avg: 16.606ms Max: 50.726ms
MarkingPhase: Sum: 26.307ms 99% C.I. 0.043ms-24.720ms Avg: 6.576ms Max: 25.154ms
VisitNonThreadRoots: Sum: 11.431ms 99% C.I. 0.130ms-10.592ms Avg: 2.857ms Max: 10.689ms
FlipThreadRoots: Sum: 9.683ms 99% C.I. 0.004ms-7.778ms Avg: 2.420ms Max: 7.885ms
ProcessReferences: Sum: 7.095ms 99% C.I. 2us-6728us Avg: 886.875us Max: 6924us
RecordFree: Sum: 5.067ms 99% C.I. 0.290ms-3.784ms Avg: 1.266ms Max: 3.844ms
ThreadListFlip: Sum: 4.091ms 99% C.I. 0.051ms-2.407ms Avg: 1.022ms Max: 2.407ms
ClearFromSpace: Sum: 3.002ms 99% C.I. 247us-1437us Avg: 750.500us Max: 1437us
InitializePhase: Sum: 2.370ms 99% C.I. 269us-747us Avg: 592.500us Max: 747us
ResumeRunnableThreads: Sum: 2.250ms 99% C.I. 54us-1715us Avg: 562.500us Max: 1715us
EnqueueFinalizerReferences: Sum: 1.196ms 99% C.I. 61us-607us Avg: 299us Max: 607us
ClearRegionSpaceCards: Sum: 981us 99% C.I. 34us-721us Avg: 245.250us Max: 721us
ForwardSoftReferences: Sum: 960us 99% C.I. 21us-517us Avg: 240us Max: 517us
SweepSystemWeaks: Sum: 871us 99% C.I. 100us-425us Avg: 217.750us Max: 425us
SweepAllocSpace: Sum: 384us 99% C.I. 34us-174us Avg: 96us Max: 174us
(Paused)ClearCards: Sum: 284us 99% C.I. 0.251us-67.999us Avg: 2.218us Max: 96us
ResumeOtherThreads: Sum: 238us 99% C.I. 9us-165us Avg: 59.500us Max: 165us
EmptyRBMarkBitStack: Sum: 220us 99% C.I. 22us-125us Avg: 55us Max: 125us
SweepLargeObjects: Sum: 219us 99% C.I. 24us-95us Avg: 54.750us Max: 95us
MarkZygoteLargeObjects: Sum: 199us 99% C.I. 20us-82us Avg: 49.750us Max: 82us
SwapBitmaps: Sum: 169us 99% C.I. 10us-93us Avg: 42.250us Max: 93us
ReclaimPhase: Sum: 138us 99% C.I. 11us-59us Avg: 34.500us Max: 59us
(Paused)FlipCallback: Sum: 56us 99% C.I. 11us-18us Avg: 14us Max: 18us
Sweep: Sum: 51us 99% C.I. 5us-27us Avg: 12.750us Max: 27us
UnBindBitmaps: Sum: 7us 99% C.I. 1us-4us Avg: 1.750us Max: 4us
Done Dumping histograms
concurrent copying paused: Sum: 77.413ms 99% C.I. 1.801ms-64.498ms Avg: 19.353ms Max: 64.498ms
concurrent copying total time: 604.346ms mean time: 151.086ms
concurrent copying freed: 36722 objects with total size 5MB
concurrent copying throughput: 60798/s / 8MB/s
Cumulative bytes moved 2734328
Cumulative objects moved 54272
Total time spent in GC: 604.346ms
Mean GC size throughput: 8MB/s
Mean GC object throughput: 60735.1 objects/s
Total number of allocations 66790
Total bytes allocated 6MB
Total bytes freed 5MB
Free memory 1592KB
Free memory until GC 1592KB
Free memory until OOME 190MB
Total memory 3MB
Max memory 192MB
Zygote space size 408KB
Total mutator paused time: 77.413ms
Total time waiting for GC to complete: 6.252us
Total GC count: 4
Total GC time: 604.346ms
Total blocking GC count: 0
Total blocking GC time: 0
Histogram of GC count per 10000 ms: 0:84,1:1,2:1
Histogram of blocking GC count per 10000 ms: 0:86
Registered native bytes allocated: 560849
/vendor/app/SystemSettings/oat/arm64/SystemSettings.odex: speed
Current JIT code cache size: 4KB
Current JIT data cache size: 3KB
Current JIT capacity: 64KB
Current number of JIT code cache entries: 2
Total number of JIT compilations: 2
Total number of JIT compilations for on stack replacement: 0
Total number of JIT code cache collections: 0
Memory used for stack maps: Avg: 1060B Max: 1984B Min: 136B
Memory used for compiled code: Avg: 2510B Max: 4KB Min: 380B
Memory used for profiling info: Avg: 256B Max: 848B Min: 32B
Start Dumping histograms for 2 iterations for JIT timings
Compiling: Sum: 559.152ms 99% C.I. 60.251ms-494.848ms Avg: 279.576ms Max: 498.901ms
TrimMaps: Sum: 27.954ms 99% C.I. 0.048ms-27.724ms Avg: 13.977ms Max: 27.906ms
Done Dumping histograms
Memory used for compilation: Avg: 549KB Max: 995KB Min: 102KB

suspend all histogram: Sum: 10.610ms 99% C.I. 0.002ms-3.662ms Avg: 1.061ms Max: 3.662ms
DALVIK THREADS (35):
“Signal Catcher” daemon prio=5 tid=3 Runnable
| group=“system” sCount=0 dsCount=0 flags=0 obj=0x135c1b28 self=0x79b785ce00
| sysTid=3084 nice=0 cgrp=default sched=0/0 handle=0x79ada494f0
| state=R schedstat=( 0 0 0 ) utm=3 stm=1 core=0 HZ=100
| stack=0x79ad94f000-0x79ad951000 stackSize=1005KB
| held mutexes= “mutator lock”(shared held)
native: #00 pc 000000000039745c /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+212)
native: #01 pc 000000000045d6ac /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMapb+348)
native: #02 pc 0000000000474690 /system/lib64/libart.so (_ZN3art14DumpCheckpoint3RunEPNS_6ThreadE+880)
native: #03 pc 000000000046d13c /system/lib64/libart.so (ZN3art10ThreadList13RunCheckpointEPNS_7ClosureES2+476)
native: #04 pc 000000000046cb4c /system/lib64/libart.so (_ZN3art10ThreadList4DumpERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEb+796)
native: #05 pc 000000000046c6ec /system/lib64/libart.so (_ZN3art10ThreadList14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+920)
native: #06 pc 0000000000441cf4 /system/lib64/libart.so (_ZN3art7Runtime14DumpForSigQuitERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEE+196)
native: #07 pc 000000000044b604 /system/lib64/libart.so (_ZN3art13SignalCatcher13HandleSigQuitEv+1676)
native: #08 pc 000000000044a444 /system/lib64/libart.so (_ZN3art13SignalCatcher3RunEPv+356)
native: #09 pc 0000000000065e60 /system/lib64/libc.so (_ZL15__pthread_startPv+36)
native: #10 pc 000000000001eca4 /system/lib64/libc.so (__start_thread+68)
(no managed stack frames)

“main” prio=5 tid=1 Blocked
| group=“main” sCount=1 dsCount=0 flags=1 obj=0x72924d38 self=0x79b785ba00
| sysTid=3076 nice=0 cgrp=default sched=0/0 handle=0x79bd4929b0
| state=S schedstat=( 0 0 0 ) utm=49 stm=13 core=2 HZ=100
| stack=0x7fcb607000-0x7fcb609000 stackSize=8MB
| held mutexes=
at android.app.ContextImpl.getTheme(ContextImpl.java:276)

  • waiting to lock <0x0fd8b9b0> (a java.lang.Object) held by thread 35
    at android.content.ContextWrapper.getTheme(ContextWrapper.java:125)
    at android.content.Context.getDrawable(Context.java:612)
    at androidx.core.content.ContextCompat.getDrawable(ContextCompat.java:455)
    at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:144)
  • locked <0x05fae029> (a androidx.appcompat.widget.ResourceManagerInternal)
    at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:132)
  • locked <0x05fae029> (a androidx.appcompat.widget.ResourceManagerInternal)
    at androidx.appcompat.widget.ResourceManagerInternal.checkVectorDrawableSetup(ResourceManagerInternal.java:489)
    at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:137)
  • locked <0x05fae029> (a androidx.appcompat.widget.ResourceManagerInternal)
    at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:132)
  • locked <0x05fae029> (a androidx.appcompat.widget.ResourceManagerInternal)
    at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:104)
    at androidx.appcompat.widget.AppCompatImageHelper.setImageResource(AppCompatImageHelper.java:90)
    at androidx.appcompat.widget.AppCompatImageView.setImageResource(AppCompatImageView.java:98)
    at com.tcl.settings.view.itemview.MainLayoutItem.initLayoutItemData(MainLayoutItem.kt:62)
    at com.tcl.settings.view.settingview.MainSettingView$MainViewAdapter.onBindViewHolder(MainSettingView.kt:363)

10-20 20:35:44.635 2585 2643 E ActivityManager: PID: 3076
10-20 20:35:44.635 2585 2643 E ActivityManager: Reason: Input dispatching timed out (Waiting to send key event because the focused window has not finished processing all of the input events that were previously delivered to it. Outbound queue length: 0. Wait queue length: 1.)
10-20 20:35:44.635 2585 2643 E ActivityManager: Load: 16.81 / 15.97 / 10.74
10-20 20:35:44.635 2585 2643 E ActivityManager: CPU usage from 0ms to 11674ms later (2020-10-20 20:35:32.928 to 2020-10-20 20:35:44.602):
10-20 20:35:44.635 2585 2643 E ActivityManager: 55% 2915/com.tcl.cyberui: 46% user + 8.6% kernel / faults: 2975 minor 54 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 27% 2020/surfaceflinger: 16% user + 10% kernel / faults: 4188 minor 23 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 16% 2585/system_server: 9.6% user + 6.6% kernel / faults: 2809 minor 111 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 15% 5958/com.tcl.MultiScreenInteraction_TV:AirPlay: 11% user + 4.3% kernel / faults: 2757 minor 28 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 10% 1//init: 5.3% user + 4.6% kernel / faults: 63 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 9.6% 2062/logd: 3.5% user + 6% kernel / faults: 5 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 9.3% 2417/sitatvservice: 4% user + 5.3% kernel / faults: 84 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 7.1% 2305/MiSysSrv: 3.6% user + 3.4% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 6.2% 2304/MiSysSrv: 3.1% user + 3% kernel / faults: 2 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 6.2% 3839/com.tcl.vod: 4.7% user + 1.5% kernel / faults: 924 minor 41 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 5.2% 2126/irq/42-scaler: 0% user + 5.2% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 3.6% 2298/tmmgr: 1% user + 2.6% kernel / faults: 25 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 3.4% 6130/logcat: 1.7% user + 1.6% kernel / faults: 8 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 3.3% 5478/com.tcl.tvweishi:main: 2.6% user + 0.6% kernel / faults: 2008 minor 16 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 2.9% 3709/com.tcl.cyberui:cyberservice: 2.3% user + 0.5% kernel / faults: 938 minor 54 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 2.3% 4887/com.tcl.c2dm.client: 1.4% user + 0.8% kernel / faults: 819 minor 133 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 2.2% 4066/com.iflytek.xiri: 1.6% user + 0.5% kernel / faults: 1239 minor 30 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 2% 783/kswapd0: 0% user + 2% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 2% 4034/logcat: 0.9% user + 1.1% kernel / faults: 8 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 1.6% 1096/mmcqd/0: 0% user + 1.6% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 1.5% 3076/com.tcl.settings: 0.9% user + 0.5% kernel / faults: 969 minor 219 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 1.3% 10945/kworker/0:1: 0% user + 1.3% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 1.1% 2698/kworker/u9:2: 0% user + 1.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 1% 1233/T_sensor_Check: 0% user + 1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 1% 4314/com.iflytek.xiri2.system: 0.6% user + 0.3% kernel / faults: 1126 minor 2 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 1% 6974/com.tcl.usagestats: 0.9% user + 0% kernel / faults: 682 minor 8 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 1% 9844/kworker/u9:1: 0% user + 1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.9% 6833/com.tcl.recognize.service: 0.8% user + 0% kernel / faults: 654 minor 8 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.8% 4816/com.tcl.healthinfo: 0.5% user + 0.2% kernel / faults: 1022 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.8% 7329/cp: 0% user + 0.8% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.7% 3754/com.tcl.factory.view: 0.5% user + 0.2% kernel / faults: 1565 minor 38 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.6% 3939/com.sohu.inputmethod.sogou.tv: 0.5% user + 0% kernel / faults: 1131 minor 2 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.5% 3366/com.android.bluetooth: 0.1% user + 0.4% kernel / faults: 147 minor 63 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.5% 2418/tcl_rc_voice: 0% user + 0.5% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.5% 2992/RtmpCmdQTask: 0% user + 0.5% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.5% 3820/com.tcl.bi:remote: 0.3% user + 0.1% kernel / faults: 604 minor 22 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.5% 4115/com.tcl.walleve: 0.4% user + 0% kernel / faults: 610 minor 14 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.5% 8745/kworker/3:0: 0% user + 0.5% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0% 2329/media.extractor: 0% user + 0% kernel / faults: 1128 minor 25 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.4% 5331/logcat: 0.3% user + 0% kernel / faults: 16 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.4% 5965/com.tcl.MultiScreenInteraction_TV:Private: 0.3% user + 0% kernel / faults: 69 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.3% 7/rcu_preempt: 0% user + 0.3% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.3% 15/ksoftirqd/1: 0% user + 0.3% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.3% 2285/MiSysSrv: 0.1% user + 0.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.3% 5526/com.tcl.appmarket2: 0.2% user + 0% kernel / faults: 7 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.3% 11526/kworker/1:2: 0% user + 0.3% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.2% 3/ksoftirqd/0: 0% user + 0.2% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.2% 2268/android.hardware.bluetooth@1.0-service: 0% user + 0.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0% 2352/tombstoned: 0% user + 0% kernel / faults: 116 minor 43 major
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.2% 2996/RtmpMlmeTask: 0% user + 0.2% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.2% 4949/com.tcl.tvweishi:service: 0.1% user + 0% kernel / faults: 112 minor
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.1% 25/ksoftirqd/3: 0% user + 0.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.1% 1235/sugov:0: 0% user + 0.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.1% 1242/usb-storage: 0% user + 0.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.1% 1319/usb-storage: 0% user + 0.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.1% 2017/servicemanager: 0% user + 0.1% kernel
10-20 20:35:44.635 2585 2643 E ActivityManager: 0.1% 2022/tperfd: 0% u

/**
     * Sets a drawable as the content of this ImageView.
     * <p class="note">This does Bitmap reading and decoding on the UI
     * thread, which can cause a latency hiccup.  If that's a concern,
     * consider using {@link #setImageDrawable(android.graphics.drawable.Drawable)} or
     * {@link #setImageBitmap(android.graphics.Bitmap)} and
     * {@link android.graphics.BitmapFactory} instead.</p>
     *
     * @param resId the resource identifier of the drawable
     *
     * @attr ref android.R.styleable#ImageView_src
     */
    @android.view.RemotableViewMethod(asyncImpl="setImageResourceAsync")
    public void setImageResource(@DrawableRes int resId) {

这个方法是在UI线程中对图片读取和解析的,所以有可能对一个Activity的启动造成延迟。所以如果顾虑到这个官方建议用setImageDrawable和setImageBitmap来代替。

最后

以上就是要减肥大侠为你收集整理的setImageResource导致的ANR的全部内容,希望文章能够帮你解决setImageResource导致的ANR所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(38)

评论列表共有 0 条评论

立即
投稿
返回
顶部