I have an app that uses multiple WebViews next to each other to display content. When vertically scrolling on one, and I scroll another before the first stops completely I get an exception with the below stack trace. The first line in the stack is the most puzzling to me. I do not know what a VelocityTracker is, or what any of the other variables refer to.
11-30 10:47:04.740: E/webview(2199): Got null mVelocityTracker when mPreventDefault = 0 mDeferTouchProcess = false mTouchMode = 3
11-30 10:50:23.771: D/AndroidRuntime(2199): Shutting down VM
11-30 10:50:23.771: W/dalvikvm(2199): threadid=1: thread exiting with uncaught exception (group=0x40015560)
11-30 10:50:23.795: E/AndroidRuntime(2199): FATAL EXCEPTION: main
11-30 10:50:23.795: E/AndroidRuntime(2199): java.lang.NullPointerException
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.webkit.WebView.onTouchEvent(WebView.java:5283)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.View.dispatchTouchEvent(View.java:3885)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
11-30 10:50:23.795: E/AndroidRuntime(2199): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1702)
11-30 10:50:23.795: E/AndroidRuntime(2199): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
11-30 10:50:23.795: E/AndroidRuntime(2199): at android.app.Activity.dispatchTouchEvent(Activity.java:2132)
11-30 10:50:23.795: E/AndroidRuntime(2199): at
...
I am using a sub-classed WebView, but I do not override the onTouchEvent() method.
Interestingly I am only finding this error on the OS v2.3 device I am using as well as any OS v2.x emulator. Anytime I test on a 4.x device everything is fine and all WebViews are able to handle touching and scrolling simultaneously.
What is going on? Is this a known bug in Android? I could not find any record of a similar circumstance. Any suggestions for a workaround? I could just prevent other WebViews from being touched so long as one of them is scrolling, but that seems ridiculous.
I found out how I was causing the problem, but not what the problem truly was.
I stumbled on this link which described a problem when a
WebViewdoes not pass along allonTouchevents. I had anonTouchListenerset to myWebViews which handled the firstonTouchevent by returningtruebut then passed along subsequent events by returningfalse.Apparently some versions of the OS get messed up when they aren’t able to process all
onTouchevents.