android 4.0.3 "Miss a drag as we are waiting for webcores response"

edited July 2012 in Enyo 2
Having some issues with this error in my app.
They come up when you try to scroll a scroller, and it lags a little before the scroll catches up. Makes my app seem slow. Also get a message about Stale touchdown events when clicking buttons.
I've read some google search results that this is a problem for lots of other implementations as well. I read some threads that some preventDefaults may cause it.

Has anyone had issues with a phonegap app on android with this error?
Any ideas for work arounds?

Comments

  • Are you using write() or renderInto? It should be write on Android.
  • I am using renderInto().
    I tried to use write(), but that makes the app not work at all. It loads the first screen, but it fills only half the screen, and you can select anything in it. Also it doesn't seem to add any css styles.
    renderInto(), the app behaves how it should, other then the somewhat laggy scrolling, and missed touch events.

    Is there a special way or class i need to apply to use .write()?

  • You cant apply write() inside a onready function or any function. It needs to be just run as script.

    The best way i have found is to have two scrollers. The first is fit:true inside a fittablerow (it took me the longest time to realize row is measuring height and column width) then a control with a stroller inside that set as classes: enyo-fit (no set height) . I have no lag although I still get the error, but I figure that doesn't matter with no lag.
  • OK, i got write() to work and there was no difference in the scrolling. I tried your trick with 2 scrollers, and it seemed to help a little.
    But it still has a slow start. I've tried messing with the strategies, using scrim: true, translateOptimized: true, i've messed with the scroll math, and prevent Drag and scroll propigation....

    I've got it to where it is somewhat acceptable after all that, but it still has that slow start.
    If it is text only, it is nice and smooth, but through in an image or two and it really has a problem with it. And if it's an animated gif, it has major problems.

    I may have to redesign how i am going to display the data....
  • So i have added this to my index.html before i write my app,
    document.addEventListener( "touchstart", function(e){ onStart(e); }, false );
    			function onStart ( touchEvent ) {
    			  if( navigator.userAgent.match(/Android/i) ) {
    			    touchEvent.preventDefault();
    			  }
    			}
    And it seems to help. Instead of 100s of "Miss a drag"'s i only get 1 per drag now, and it seems to scroll smoother.

    (found this code on another site where people where have problems with this error)


    Now to go through and pull out as much as possible out of the scroller that doesn't really need to scroll so there is less for it to handle.
  • edited July 2012
    I have one minor optimization to recommend - use enyo.platform, rather than matching on the navigator.userAgent every time:
    
    if( enyo.platform.android ) {
            touchEvent.preventDefault();
    }
    
    This isn't going to make much difference, but since you're going to be processing it on every touch event...

    Also, enyo.platform.android is set to the major version of Android that you're running, so if you find out this is unnecessary in, for example, Android 4, you can do:
    
    if( enyo.platform.android < 4 ) {
            touchEvent.preventDefault();
    }
    
  • I have one minor optimization to recommend - use enyo.platform, rather than matching on the navigator.userAgent every time:
    Thanks for the tip.

    I have rearranged my user interface, and only scroll what really needs to be scrolled (which is hard thinking about phone-size screen), and along with the above little hack, it is finally useable on my android tablet.

    Now i can continue porting it :)
  • edited July 2012
    We know this to be a problem on Android 2, but everything is much smoother on the implementations of Android 4 that I've seen. I'm interested in giving this a little try.

    * unfortunately, no change was visible in my Enyo 1 apps :(
  • We know this to be a problem on Android 2, but everything is much smoother on the implementations of Android 4 that I've seen. I'm interested in giving this a little try.

    * unfortunately, no change was visible in my Enyo 1 apps :(
    Yeah, i gave up trying to optimize enyo 1 for android.
  • Just a note, adding this in your index html will disable the ability to have inputs (with vkb at least). The vkb won't popup.
    So i changed it around to add it to only where it was needed.

    (this view is pretty much just a div with a scroller)
    eventStarted: false,
    	rendered: function() {
    		this.inherited(arguments);
    		if (this.eventStarted === false) {
    			this.eventStarted = true;
    if (this.hasNode()) {
    			this.hasNode().addEventListener( "touchstart", function(e){ onStart(e); }, false );
    				function onStart ( touchEvent ) {
    				  if( enyo.platform.android ) {
    				    touchEvent.preventDefault();
    				  }
    				}
    		}
    }
    	},
  • 02-12 14:31:43.411: D/CordovaLog(28497): touchEvent
    02-12 14:31:43.411: I/Web Console(28497): touchEvent at file:///android_asset/www/index.html:23
    02-12 14:31:43.986: W/webview(28497): Miss a drag as we are waiting for WebCore's response for touch down.
    have a look at the numbers in bold, I think the lag still exists with about 400ms. That's the result after I tried `touchEvent.preventDefault()`. For me, that's really not a good result.
  • OK, just now I thought, maybe rendering the scrollbar leads to the lag because I tried reducing count of items so that the scrollbar dispeared and the list ran much more smooth. I also decrease height of each item and increase count of items but remained scrollbar dispeared, it works well too. Forgive me, I just don't know how to remove the scrollbar, however, I've tried ::-webkit-scrollbar: {display: none; }
  • I think you can disable through phonegap
  • thanks to strider73, I found the code below somewhere:
    `// Disable scrollbars
    super.appView.setVerticalScrollBarEnabled(false);
    super.appView.setHorizontalScrollBarEnabled(false);`.
    But actually that's not what I want. And then I tried with setting `strategyKind: "ScrollStrategy"`, the scrollbar dispears however I also lost the scrolling progress, but it seems much better now. I think we can do a fiddle with enyo's scrollstragy.
Sign In or Register to comment.