Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does blockWebkitDraw mean and how to fix it? [duplicate]

I'm wrapping an Android app using a WebView and it requires rendering an HTML5 canvas. It works perfectly on all my devices, except for one. My Galaxy S4 (4.2.2) is flashing the canvas, then it quickly turns grey. Here is the logcat message it's producing:

D/GestureDetector(20071): [Surface Touch Event] mSweepDown False, mLRSDCnt : -1 mTouchCnt : 7 mFalseSizeCnt:0

V/WebViewInputDispatcher(20071): blockWebkitDraw

V/WebViewInputDispatcher(20071): blockWebkitDraw lockedfalse

D/webview(20071): blockWebkitViewMessage= false

I click on a button, then the canvas is supposed to render. That is why the first log item is for a surface touch event. It works on my S4 when I ping my app using the webkit browser directly, but when wrapping it myself or using Cordova is gives me that error. I've added two screenshots to further display the issue. The first is rendered correctly and the second is the problem.

Android 2.3.6:

enter image description here

Android: 4.2.2:

enter image description here

So back to my question. What's going on with this message? Does anybody have any suggestions on how to have it properly render the canvas?

like image 617
Joshua Avatar asked Aug 03 '13 11:08

Joshua


3 Answers

I was able to fix the problem by setting my minimum sdk version in the android manifest file to 14:

<uses-sdk android:minSdkVersion="14" />

At version 14, the messages still appear in the log, but the touch events are processed. When I set the minSdkVersion back, the touch events are not processed. Turning off hardware acceleration in the manifest, as well as by various CSS webkit styles, did not help. Only the minSdkVersion setting fixed it for me.

Somehow, on the Galaxy Tab, the SDK support for older versions causes problems with the javascript touch event processing, and blockWebkitDraw stays true while a touch move is happening. This prevents my canvas code from receiving the touchmove events and executing the draw. When I set the SDK version to 14, blockWebkitDraw gets set to true when a touch event fires, but it is unset after the touch is processed, and the canvas code to draw gets called.

like image 199
NoelHunter Avatar answered Nov 05 '22 17:11

NoelHunter


I did some cursory browsing of the WebView and WebViewInputDispatcher classes, but didn't come up with anything. Maybe you could take a look there.

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/android/webkit/WebView.java http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.2.2_r1/android/webkit/WebViewInputDispatcher.java

My thought was that perhaps you could pinpoint where the blocking occurs and either extend those classes or create your own copy and modify them.

like image 20
JstnPwll Avatar answered Nov 05 '22 17:11

JstnPwll


I was banging my head with a very similar issue while testing on a Galaxy Tab 2. In my case, I had a simple hyperlink, not a button, but the issue is the same. Here's what I discovered:

The error message in my console with tag WebViewInputDispatcher and value blockWebkitDraw lockedfalse appears to occur every single time I touch the screen, regardless of whether I click on a button or link. Therefore, this error message relates to onTouch events, not your button click as you might have expected.

When originally testing by clicking on one of my links, I originally thought the Galaxy Tab was blocking my link. It turns out, the Galaxy Tab 2 is just very insensitive to click behavior so when I thought I was clicking on the link, I was actually missing. By clicking slightly higher than I thought was necessary, I was able to activate my link.

To validate my suspicion, I greatly increased the font size of my link. With the much bigger link, I am able to click the link successfully on the first try, and my app now performs as expected. I strongly suspect that if you just make your button a lot bigger, you'll be able to click it successfully.

like image 1
Steven Avatar answered Nov 05 '22 15:11

Steven