Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14940] Android: touchend event not fired if two touches occured

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-11-07T23:51:14.000+0000
Affected Version/sRelease 3.1.1
Fix Version/s2013 Sprint 23, 2013 Sprint 23 API, Release 3.2.0
ComponentsAndroid
LabelsAndroid, qe-testadded, triage
Reporterjithinpv
AssigneePing Wang
Created2013-08-23T06:50:35.000+0000
Updated2014-02-19T11:19:09.000+0000

Description

var win = Ti.UI.createWindow({
    backgroundColor:'green',
    width:'100%',
    height:'100%',
        // fullscreen : true,
        // navBarHidden : true
 });
 
 var view = Ti.UI.createView({
    width:'20%',
    height:'20%',
    backgroundColor:'red'
 });
 view.addEventListener('touchstart',function(){
    view.backgroundColor = 'white'
 });
 view.addEventListener('touchend',function(){
    view.backgroundColor = 'red'
 });
 win.add(view);
 win.open();
step 1 : Run the above code step 2 : tap on the red view step 3 : without removing the finger tap on the green window or in the white view again step 4: remove both fingers Actual result The view remains white expected result The view should turn red

Comments

  1. Mark Mokryn 2013-09-11

    1. It also reproduces on 3.1.3RC 2. Here's another way to cause the bug: tap inside the view to trigger touchstart, then tap quickly outside the view (even if you do lift the finger, doesn't matter) - the touchend doesn't fire. 3. The same bug occurs even without event listeners - just define backgroundColor and backgroundSelectedColor, and on occasion the backgroundSelectedColor is stuck. 4. This bug is extremely annoying! On small clickable elements, when the user is apt to often click on the element boundary, it appears to happen quite a lot in normal usage patterns.
  2. Mark Mokryn 2013-09-18

    Also happens with backgroundSelectedImage. Frankly I'm surprised this is pushed out to 3.2.0 - it's a pretty serious issue, giving the user wrong indications regarding key events such as button clicks.
  3. Ingo Muschenetz 2013-09-18

    [~mokesmokes] I agree it needs to be fixed, but we can only take on so many issues at once. We always welcome pull requests against titanium_mobile to help speed up the process.
  4. Mark Mokryn 2013-09-18

    Ingo, I hear you loud and clear..... and with iOS7 release you guys have more than a handful. However, for Android this is a big UI issue, I'm hoping it can be fixed and merged into 3.1.x even if not in an official release. I'm in complete agreement on the PRs, I have submitted several already, not sure though that I will be able to dig into this one soon. Thanks!
  5. Mark Mokryn 2013-09-19

    OK - here's the source of the bug: the touch listener in TiUIView.java gets confused when there are secondary touches after the initial touch start. Here is the simplest example I logged: 0 (ACTION_DOWN), 261 (ACTION_POINTER_2_DOWN), 6 (ACTION_POINTER_1_UP), 1 (ACTION_UP) touchstart is fired after ACTION_DOWN, touchend is never fired and of course the backgroundSelectedColor/Image is stuck. Frankly, I don't understand the implemented logic with the secondary touches in this function, but somehow you're losing the end event. It would be great if someone familiar with this code took care of this, since accidental, secondary touches happen frequently, and the UI just goes bonkers with this bug. Thanks!
  6. Mark Mokryn 2013-09-19

    Additionally, the logic in that function also triggers the 'twofingertap' event on the view - even though only one of the touches was inside the view....
  7. Mark Mokryn 2013-09-19

  8. Mark Mokryn 2013-09-19

    (Attempted workaround deleted)
  9. Mark Mokryn 2013-09-20

    Pull request submitted: https://github.com/appcelerator/titanium_mobile/pull/4720 Description: In Android there are frequent cases when the touchend event is not sent, when the background colors and images are not responding correctly to touches, etc. The root of this issue is the additional handling for (the rarely used) pinch and twofingertap events. (BTW - in the docs pinch is defined for iOS only..... but the Android code apparently supports it, untested by me). This PR skips the handling for pinch and twofingertap if there are no listeners or these events, and thus restoring correct behavior for the rest of the touch events. Item of note: it's not clear how twofingertap is supposed to interact with backgroundSelectedColor/Image, and touchend (all these seem to not function with twofingertap, both before and after this PR).
  10. Mark Mokryn 2013-10-17

    Does this really need to be pushed out to 3.3.0? The PR I submitted works and is in production in my app, for about a month now without a glitch. Touches were much less reliable before my fix.
  11. Ingo Muschenetz 2013-10-17

    I'll try and pull it back. We're just way overloaded.
  12. Ping Wang 2013-11-05

    Another test case for the "twofingertap" event. For FR, run the code, and touch the screen with one finger inside the red view and on finger inside the green view. It should not fire "twofingertap" event.
        var win = Ti.UI.createWindow({
            backgroundColor:'green',
            width:'100%',
            height:'100%',
                // fullscreen : true,
                // navBarHidden : true
         });
          
         var view = Ti.UI.createView({
            width:'20%',
            height:'20%',
            backgroundColor:'red'
         });
         view.addEventListener('touchstart',function(){
            view.backgroundColor = 'white'
         });
         view.addEventListener('touchend',function(){
            view.backgroundColor = 'red'
         });
         view.addEventListener('twofingertap', function(){
         	Ti.API.info("*************** twofingertap");
         });
         win.add(view);
         win.open();
        
  13. Ping Wang 2013-11-05

    Hi [~mokesmokes], I left comment on your PR. Due to the tight schedule for the release, can you take a look and let me know if you have time to update it ASAP? Thanks.
  14. Mark Mokryn 2013-11-05

    Hi, I also commented on the PR. Unfortunately I don't have time to make additional updates on the PR. Having said that, if your team doesn't have the time either - my PR is definitely better than the existing situation, where simple click handlers, background image changes, etc don't work as expected in many cases.
  15. Ping Wang 2013-11-05

    PR: https://github.com/appcelerator/titanium_mobile/pull/4917 For FR, please run the above two test cases, and TIMOB-768 and KS->BASE UI->Window Events.
  16. Hieu Pham 2013-11-07

    CR + FR
  17. Paras Mishra 2013-11-12

    Touchend event is getting fired when two touches occurred. Using Environment: Appcelerator Studio, build: 3.2.0.201311112306 SDK:3.2.0.v20131111174605 alloy: 1.3.0 CLI : 3.2.0 Xcode:5.0.1 Device: Google nexus 7(v4.3),Samsung Note(v2.3.6) OS: Mac OSX 10.9
  18. Mark Mokryn 2013-11-19

JSON Source