admin管理员组

文章数量:1658612

今天测试反馈,第一次启动,开屏超级慢,大概再7S 左右。

开始的时候,我去再WelcomeActivity 那里加了log,发现过了很久才打印。

然后我就再Application 的onAttachBase, onCreate 里面加log.

结果发现,从attachBaseContext 到执行onCreate 这期间花费了4S时间。

2019-08-30 15:59:25.026 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext
2019-08-30 15:59:25.194 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext cost168
2019-08-30 15:59:29.679 27385-27385/com.chaozh.iReader E/ad2_Log_output: onCreate

那这个时间,就不是我们的操作了。看下过滤了ad2_Log_output 的日志:

2019-08-30 15:59:25.026 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext
2019-08-30 15:59:25.194 27385-27385/com.chaozh.iReader E/ad2_Log_output: attachBaseContext cost168
2019-08-30 15:59:29.679 27385-27385/com.chaozh.iReader E/ad2_Log_output: onCreate
2019-08-30 15:59:29.757 27385-27385/com.chaozh.iReader D/ad2_Log_output: 加载广告计时开始:1567151969757
2019-08-30 15:59:29.757 27385-27385/com.chaozh.iReader E/ad2_Log_output: onCreate cost78
2019-08-30 15:59:30.346 27385-27385/com.chaozh.iReader D/ad2_Log_output: enableThirdAd proxy.adTypeSwitchOn(): false
2019-08-30 15:59:30.348 27385-27385/com.chaozh.iReader E/ad2_Log_output: welcome oncreate enableThirdAd: true ,isInThirdTime : true ,userSupportAd : true
2019-08-30 15:59:30.348 27385-27385/com.chaozh.iReader D/ad2_Log_output: 当前加载广告类型:null
2019-08-30 15:59:30.366 27385-27385/com.chaozh.iReader D/ad2_Log_output:  welcome oncreate mWelcomeAdView: com.chaozh.iReader.ui.activity.WelcomeAdView{6541bb4 V.E...... ......ID 0,0-0,0}

我们再看下这期间,其他的日志:

2019-08-30 15:59:25.242 27410-27410/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:25.242 27410-27410/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:25.243 27410-27410/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_config/1567151755000.apk --output-vdex-fd=58 --oat-fd=59 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_config/oat/arm/1567151755000.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:25.349 27410-27410/? I/dex2oat: dex2oat took 108.005ms (96.173ms cpu) (threads: 4) arena alloc=28KB (28824B) java alloc=64KB (65552B) native alloc=504KB (517040B) free=1543KB (1580112B)
2019-08-30 15:59:25.406 27417-27417/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:25.406 27417-27417/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:25.407 27417-27417/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_mine/1567151746872.apk --output-vdex-fd=59 --oat-fd=60 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_mine/oat/arm/1567151746872.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:25.642 27417-27417/? I/dex2oat: dex2oat took 236.792ms (458.101ms cpu) (threads: 4) arena alloc=16KB (17096B) java alloc=638KB (654000B) native alloc=953KB (976408B) free=1606KB (1645032B)
2019-08-30 15:59:25.714 27424-27424/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:25.715 27424-27424/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:25.715 27424-27424/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_video/1567151747044.apk --output-vdex-fd=60 --oat-fd=61 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_video/oat/arm/1567151747044.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:26.007 27424-27424/? I/dex2oat: dex2oat took 292.551ms (538.776ms cpu) (threads: 4) arena alloc=27KB (28144B) java alloc=520KB (532880B) native alloc=1386KB (1420008B) free=1685KB (1725720B)
2019-08-30 15:59:26.181 27430-27430/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:26.181 27430-27430/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:26.181 27430-27430/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_business/1567151758728.apk --output-vdex-fd=62 --oat-fd=63 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_business/oat/arm/1567151758728.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:26.313 27430-27430/? I/dex2oat: dex2oat took 132.834ms (184.244ms cpu) (threads: 4) arena alloc=19KB (19856B) java alloc=146KB (150448B) native alloc=734KB (751992B) free=1313KB (1345160B)
2019-08-30 15:59:26.393 27437-27437/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:26.394 27437-27437/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:26.394 27437-27437/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookdetail/1567151758669.apk --output-vdex-fd=63 --oat-fd=64 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookdetail/oat/arm/1567151758669.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:26.744 27437-27437/? I/dex2oat: dex2oat took 351.174ms (813.728ms cpu) (threads: 4) arena alloc=7KB (8016B) java alloc=1378KB (1411200B) native alloc=1457KB (1492560B) free=1614KB (1653168B)
2019-08-30 15:59:26.846 27442-27442/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:26.846 27442-27442/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:26.846 27442-27442/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_pdf/1567151747864.apk --output-vdex-fd=64 --oat-fd=65 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_pdf/oat/arm/1567151747864.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:27.030 27442-27442/? I/dex2oat: dex2oat took 184.560ms (286.851ms cpu) (threads: 4) arena alloc=18KB (18824B) java alloc=287KB (293960B) native alloc=952KB (975784B) free=1607KB (1645656B)
2019-08-30 15:59:27.102 27447-27447/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:27.103 27447-27447/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:27.103 27447-27447/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore/1567151780572.apk --output-vdex-fd=65 --oat-fd=66 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore/oat/arm/1567151780572.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:27.900 27447-27447/? I/dex2oat: dex2oat took 797.989ms (2.040s cpu) (threads: 4) arena alloc=11KB (11760B) java alloc=3MB (3925032B) native alloc=2MB (2284432B) free=1865KB (1909872B)
2019-08-30 15:59:28.080 27453-27453/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:28.081 27453-27453/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:28.081 27453-27453/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore2/1567151765411.apk --output-vdex-fd=66 --oat-fd=67 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookstore2/oat/arm/1567151765411.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:28.319 27453-27453/? I/dex2oat: dex2oat took 239.148ms (466.151ms cpu) (threads: 4) arena alloc=6KB (6864B) java alloc=620KB (635624B) native alloc=1138KB (1166240B) free=1421KB (1455200B)
2019-08-30 15:59:28.400 27458-27458/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:28.400 27458-27458/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:28.400 27458-27458/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_personal/1567151766654.apk --output-vdex-fd=67 --oat-fd=68 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_personal/oat/arm/1567151766654.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:28.668 27458-27458/? I/dex2oat: dex2oat took 268.957ms (584.370ms cpu) (threads: 4) arena alloc=17KB (17944B) java alloc=1096KB (1123232B) native alloc=1178KB (1207240B) free=1381KB (1414200B)
2019-08-30 15:59:28.753 27464-27464/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:28.753 27464-27464/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:28.754 27464-27464/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookshelfcard/1567151754443.apk --output-vdex-fd=68 --oat-fd=69 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_bookshelfcard/oat/arm/1567151754443.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:29.059 27464-27464/? I/dex2oat: dex2oat took 306.687ms (670.528ms cpu) (threads: 4) arena alloc=5KB (5656B) java alloc=1239KB (1268784B) native alloc=1208KB (1237064B) free=1351KB (1384376B)
2019-08-30 15:59:29.151 27469-27469/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:29.151 27469-27469/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:29.152 27469-27469/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginweb_search/1567151758977.apk --output-vdex-fd=69 --oat-fd=70 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginweb_search/oat/arm/1567151758977.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:29.368 27469-27469/? I/dex2oat: dex2oat took 217.446ms (407.470ms cpu) (threads: 4) arena alloc=4KB (4288B) java alloc=473KB (484984B) native alloc=965KB (989024B) free=1594KB (1632416B)
2019-08-30 15:59:29.444 27475-27475/? W/dex2oat: Using default instruction set features for ARM CPU variant (default) using conservative defaults
2019-08-30 15:59:29.444 27475-27475/? I/dex2oat: The ClassLoaderContext is a special shared library.
2019-08-30 15:59:29.445 27475-27475/? I/dex2oat: /system/bin/dex2oat --debuggable --debuggable --dex-file=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_common/1567151753366.apk --output-vdex-fd=70 --oat-fd=71 --oat-location=/data/data/com.chaozh.iReader/plugins/pluginwebdiff_common/oat/arm/1567151753366.odex --compiler-filter=quicken --class-loader-context=&
2019-08-30 15:59:29.591 27475-27475/? I/dex2oat: dex2oat took 146.851ms (207.739ms cpu) (threads: 4) arena alloc=3KB (3792B) java alloc=303KB (310616B) native alloc=734KB (751968B) free=1313KB (1345184B)

发现一直再执行dex2oat!!! 花费了大概4S时间!

那这个应用层也可以想办法解决,比如后面让系统执行这个dex2oat,或者其他的。

总结:

    1.这篇文章只是给大家一个思路,第一次特别慢可能是dex2oat 导致 的!
    2.看log 的时候,别只看内容,要看下两个log 的打印相隔时间。

本文标签: android