Issue
For various reasons, I need to runOnUiThread() the actual instantiation & initialization of WebView.
Which means that its underlying HTTP connections are also made on the UI thread?
If this is true, is it possible to separate the WebView's UI thead from the HTTP connections thread?
If it is possible, what is the proper way of accomplishing this?
Solution
I find it very hard to believe that Android would run remote HTTP requests on the UI thread, assuming you initiate the requests via WebView.loadUrl()
. This would make for a terrible user experience.
Just quickly, I ran an Android app in the debugger, with a basic WebView
, and stopped in the debugger. Here's what I see:
If WebViewCoreThread
, WebViewWorkerThread
, or http0
- http3
aren't handling the network connections for WebView
objects, then
- They have very bad names
- Android is built really badly
Also, if you look at this answer by one of stack overflow's highest reputation users, loadUrl() is asynchronous. A quick step through in the debugger tells me that loadUrl()
, which is called on the UI thread (aka main
), completes way too fast for the connection to be handled synchronously on the UI thread. (I put a breakpoint before and after the call to loadUrl()
with a URL that I know isn't served very quickly).
So, my answer is you're done ... they're already separate! (yeah!)
Answered By - Nate
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.