myself
myself

Reputation: 502

Android WebView: parallel Loading, Layout and Javascript

I have many (5-10) WebViews that are shown simultaneously (e.g. as a "carousel" similar to stock Gallery). Remote web sites are loaded into these WebViews (not local html files). The web sites are quite complex - they have lots of javascript, images, may have some flash...

When app starts, all WebViews start loading/layouting their content and running javascript - all this takes quite some time. On the other hand, app is very responsive when the WebViews are loading - scrolling and other UI stuff is really smooth - CPU is definitely not under pressure.

  1. So is it possible to make those views load in parallel? I think my app will benefit greatly from loading WebViews in parallel.
  2. Also, maybe there is a way to do javascript, load and layout manually by reusing WebView source code?

Upvotes: 2

Views: 1223

Answers (1)

myself
myself

Reputation: 502

Answering my own question:

  1. Is impossible - javascript on all webviews (and consequently layouting) is done on the same shared thread.
  2. Will not work either - it uses lots of non-public API.

Instead, I used WebChromeClient#shouldInterceptRequest to cache as much resources as possible, which improved loading times quite a bit.

Upvotes: 0

Related Questions