I searched and hacked, and removed all my touch event listening code, and it would still break. Luckily the company work for has the resources to invest in development, and we went out and got a Samsung Galaxy S phone. I set the device up, published the app, and this phone did not have the cryptic issue! It did, however, show a range of other issues with fonts and the <canvas> object, which made me sad, as it's clear that building an HTML5-based app for Android isn't as easy as I hoped. The fragmentation of the Android platform is definitely an issue if you're attempting complex UI design and interaction with HTML/Javascript. I recommend keeping your HTML5 app very simple if you're targeting multiple Android platforms. Even though all new Android devices use Webkit, there are plenty of small, ugly differences.
[UPDATE]: The following code, when removed from my project, got rid of this weird error:
document.ontouchmove = function(event) { event.preventDefault(); };
Another update... Check out this post, and try out the demo code to get a bit more idea about how to handle preventDefault() on touch events in the Android browser: http://code.google.com/p/android/issues/detail?id=4549. It still crashes on my HTC device, but works great on the Samsung device.
I have been having similar issues with HTC Evo & Incredible.
ReplyDeleteThis is the signal of death:
Miss a drag as we are waiting for WebCore's response for touch down
As a consequence of this I see various rendering & scrolling issues.
I've tried a bunch of hacks top work around this issue. For rendering I force trigger a reflow and it seems to makes it work. But the basic problem is you never know when webkit flakes at the javascript layer and this makes it a tough problem to solve.
Thanks for posting this, Justin. I've been struggling with the same issue.
ReplyDelete@khivi: You mentioned that you force trigger a reflow.. could you explain how you do this? Do you dispatch a touch-end event after a certain X/Y distance has been made?
preventDefault prevents native scrolling use this shim instead : https://github.com/TNT-RoX/android-swipe-shim
ReplyDeleteShim for this bug at https://github.com/TNT-RoX/android-swipe-shim
ReplyDelete