搜索

首页  >  问答  >  正文

android - 为什么webview在第一次加载的时候很慢?

在使用webview的时候发现,app在第一次启动带有webview的fragment的时候响应很慢,而后续再次开启却不是同样慢

05-05 20:57:18.721   I/WebViewFactory: Loading com.google.android.webview version 51.0.2704.81 (code 270408150)
05-05 20:57:18.897   W/System: ClassLoader referenced unknown path: /system/app/WebViewGoogle/lib/arm64
05-05 20:57:18.919   I/cr_LibraryLoader: Time to load native libraries: 14 ms (timestamps 7291-7305)
05-05 20:57:18.919   I/cr_LibraryLoader: Expected native library version number "51.0.2704.81", actual native library version number "51.0.2704.81"
05-05 20:57:18.939   V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {20922c4}
05-05 20:57:18.940   I/cr_LibraryLoader: Expected native library version number "51.0.2704.81", actual native library version number "51.0.2704.81"
05-05 20:57:18.941   I/chromium: [INFO:library_loader_hooks.cc(143)] Chromium logging enabled: level = 0, default verbosity = 0
05-05 20:57:19.015   I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
05-05 20:57:19.153   E/ActivityThread: Failed to find provider info for com.google.settings
05-05 20:57:19.197   D/cr_Ime: [InputMethodManagerWrapper.java:30] Constructor
05-05 20:57:19.210   W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
05-05 20:57:19.211   D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: false
05-05 20:57:19.217   D/EgretLoader: EgretLoader(Context context)
05-05 20:57:19.224   D/EgretLoader: The context is not activity

查看logcat发现只有第一次加载的时候会执行上方这些操作,有什么办法可以提高第一次打开webview的响应速度吗?

PHP中文网PHP中文网2802 天前1637

全部回复(2)我来回复

  • 伊谢尔伦

    伊谢尔伦2017-05-16 13:29:29

    webview也是一个浏览器,需要下载文件,后面有了缓存自然变快。

    优化不外乎按需加载,压缩之类的。基本浏览器可以用的优化,这里也用上就好了。

    回复
    0
  • PHPz

    PHPz2017-05-16 13:29:29

    可以预开启webview并设置1像素的高和宽,并且预加载很多静态资源,国内有不少app就是这样做的,用户体验非常好。

    回复
    0
  • 取消回复