Prehistory
When developing a mobile application for a large international company, it became necessary to display a Web page in WebView. The page on Java Script and contains DOM content of the order of 10-15 MB. Due to the large size of the page loads about 30 - 50 seconds, depending on the Internet connection. These results did not please, so there was a need for a thorough study of this problem.
WebView Caching
The only solution found was to use caching for downloadable content:
webview.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
Download speed doubled. However, to maintain the relevance of the content, WebView checks each file individually for its validity. Although the speed has increased, the loading time of this page inside the WebView compared to the mobile browser Chrome was inferior several times.
WebView single-threading
After careful research, I came to the conclusion that WebView uses only one stream to load data. This is true for both WebView built on its own WebKit (SDK <19) and for WebView with the Chromium engine (SDK> = 19). Chrome, unlike WebView, uses many threads (the number depends on the processor) and does not use WebView. Therefore, comparing WebView with Chrome is the same as comparing a Cossack with a Lamborghini, it makes no sense. The developers of the native Cromium component for WebView do not involve the introduction of multithreading and believe that one stream guarantees stable operation.
Let's not forget that the platform is focused on the use for such purposes of third-party applications, which the user himself chose for some of their qualities.
')
Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri); startActivity(browserIntent);
But within the framework of my project this did not suit the customer. Therefore, it was decided to leave WebView with all its flaws. I had to prove beforehand that other large projects would also not work efficiently with the original page:
1. Twitter refused to open the page and immediately suggested using a browser.
2. Facebook suggested using a browser, but it still opened the page in WebView at the same speed as my solution.
Fortunately, that was enough and the pressure on me was gone.
Conclusion
Do not use WebView to display large and complex pages. Recommended use for WebView:
1. For authorization on any services.
2. To display simple pages.
3. For text alignment in width (Standard TextView does not have this function, but this is a completely different story).
Let's not forget that Android uses the Intent system, thanks to which we can use third-party browsers, the speed of which is noticeably higher.