Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was having this same issue and I had to work it out. I tried these solutions, but at the end the performance, at least for the scrolling didn't improve at all. So here the workaroud that I did perform and the explanation of why it did work for me.</p> <p>If you had the chance to explore the drag events, just a little, by creating a "MiWebView" Class, overwriting the "onTouchEvent" method and at least printed the time in which every drag event occurs, you'll see that they are separated in time for (down to) 9ms away. That is a very short time in between events.</p> <p>Take a look at the <a href="http://www.netmite.com/android/mydroid/2.0/frameworks/base/core/java/android/webkit/WebView.java" rel="noreferrer" title="WebView Source Code">WebView Source Code</a>, and just see the onTouchEvent function. It is just impossible for it to be handled by the processor in less than 9ms (Keep on dreaming!!!). That's why you constantly see the "Miss a drag as we are waiting for WebCore's response for touch down." message. The code just can't be handled on time.</p> <p>How to fix it? First, you can not re-write the onTouchEvent code to improve it, it is just too much. But, you can "mock it" in order to limit the event rate for dragging movements let's say to 40ms or 50ms. (this depends on the processor).</p> <p>All touch events go like this: ACTION_DOWN -> ACTION_MOVE......ACTION_MOVE -> ACTION_UP. So we need to keep the DOWN and UP movements and filter the MOVE rate (these are the bad guys).</p> <p>And here is a way to do it (you can add more event types like 2 fingers touch, all I'm interested here is the single finger scrolling).</p> <pre><code>import android.content.Context; import android.view.MotionEvent; import android.webkit.WebView; public class MyWebView extends WebView{ public MyWebView(Context context) { super(context); // TODO Auto-generated constructor stub } private long lastMoveEventTime = -1; private int eventTimeInterval = 40; @Override public boolean onTouchEvent(MotionEvent ev) { long eventTime = ev.getEventTime(); int action = ev.getAction(); switch (action){ case MotionEvent.ACTION_MOVE: { if ((eventTime - lastMoveEventTime) &gt; eventTimeInterval){ lastMoveEventTime = eventTime; return super.onTouchEvent(ev); } break; } case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: { return super.onTouchEvent(ev); } } return true; } } </code></pre> <p>Of course Use this class instead of WebView and you'll see the difference when scrolling.</p> <p>This is just an approach to a solution, yet still not fully implemented for all lag cases due to screen touching when using WebView. However it is the best solution I found, at least for my specific needs.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload