I went to play the ol' Some Adventure Guy on the new iOS4 on my 3GS (sooo many TLAs!) - but alas, my already crappy controls had become even more crappier! And it looks like a crazy change (hopefully bug) in webkit's touch handling is to blame.
So, the problem occurred when I tried to jump AND moved at the same time. A fairly common requirement for a platform game, I think you'll agree. It appeared that any time the lil' guy jumped, the left or right command would be killed dead in it's tracks. After some hunting by me and a vigilant coworker we found that the touchend
event was being fired twice whenever one finger was lifted.
Here is a minimal test case which seems to confirm the horrible - when you lift one finger from a multitouch event, all events are immediately cancelled. If you move one of the remaining touches then its touchstart event is re-fired! Oh the humanity!
The demo updates on touchstart and touchend and shows the current number of touches. If you hold down 2 or more fingers, then release one (being careful not to move the other fingers - less you re-trigger a start event) then you can see that all the remaining touches get ended. No multitouch for you.
I have a most terrifying workaround for my platform game (that not work for most people's multitouch requirements) - but I'm hoping someone can stand up and tell me I'm doing something terribly wrong and that there's an easy fix before I release it.
If it is a bug, and I were a more mis-trusting kind of a guy, I might suspect that Apple is getting scared of web apps and is doing their best to disable them! Of course, more likely is that someone forgot to run their unit tests. Right guys?
5 Comments
Spotted here too… the touch identifier seems to be the same when touchstart is called the second time round. Although this seems to work for rapid motion, if the second finger is lifted, the touchstart will not fire until the first finger begins to move again.
Did you find a better fix ?
I’m running through the same difficulty. Good to know I’m not alone. Have you spotted if anyone has submitted a bug to the webkit project?
Errm – no… I couldn’t find one at bugs.webkit.org – but I don’t know how to test the nighties etc, and to tell you the truth – it was such an obviously big bug (for me) that I just assumed I was doing something wrong! If I get a minute this weekend I’ll test everything and submit a ticket.
I ran into the exact same issue when writing the touch events abstraction for Sencha Touch. When talking to some Apple Webkit employees at WWDC, they told me they were aware of this behavior but that they didnt know if it was actually wrong. It is a shame that there is no standard defined for this yet, because now we have to convince them that this is not the wanted behavior. The trick with the touch identifier and the touchstart firing once you start moving the remaining finger is not exactly ideal, and in the end I gave up on using that as a solution.
I filed a bug for this at in Apple’s bug reporter at https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/11/wo/GCgTgQBJJ5Uak58Ew97vsg/5.83.28.1.13
Unfortunately it was closed with the same exact response I get for every bug I report to Apple:
Engineering has requested the following information in order to further investigate this issue:
Could you please attach your device log to the bug report. Device logs can be retrieved via the Organizer in Xcode. Or, from the iPhone Configuration Utility:
1. Download and install iPCU from http://www.apple.com/support/iphone/enterprise/
2. Launch iPCU, then connect device with USB cable
3. Click the Console tab in iPCU
4. Reproduce the problem
5. Click the “Save as” button to save the log to a text file.
6. Attach the text file to the bug report
Phew! That was a close one… the iPhone OS 4.1 update looks like it’s fixed the issue. Kind of… my “test case” above still seems a bit funny (lift a finger and now the event can remain on?!) but it might just be some dodgy code.
Right, back to makin’ some games! Thanks David and Tommy for your help and comments.