This is a migrated thread and some comments may be shown as answers.

Lag between "change" and "refresh"

3 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Don
Top achievements
Rank 1
Don asked on 18 Mar 2013, 10:03 PM
I am working on a phonegap app in Icenium, but this question is really about Kendo UI Mobile.

My app has something like this:
var myObservable = kendo.observable({
     displayText: '',
     revealText: function (myText) {
              // Do some stuff...

          this.set('displayText', myText);
 
          playASound();
     }
});

kendo.bind($('#PlayGameContainer'), myObservable);
 
function playASound() {
     // This will play a sound.
}

function addRowsToAListView() {
      // This will add some rows to a ListView.
}
"displayText" is bound to a div so that when it changes, the text in the div also changes.

Calling "revealText()" by itself works as expected (i.e. the div updates with displayText and then the sound is played).  However, if there are calls made immediately after revealText() (e.g. we make a call to addRowsToAListView()), then there is some lag on the refresh (i.e. the sound will play and *then* the div will update with displayText a second later).

I need the sound to play immediately *after* the displayText has actually updated.  I tried binding to the "change" event of the ObservableObject (http://docs.kendoui.com/api/framework/observableobject) and playing the sound in the handler, but it made no difference.  Is there a way to bind the the "refresh" of the ObservableObject to ensure that the sound is played after the text of the div has updated with displayText?  Or is there some other way to deal with this lag?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 20 Mar 2013, 05:34 PM
Hello Don,

I am afraid that the provided information is not sufficient enough in order to determine what exactly is going wrong. Does the problem persists if you do not play a sound, but use another JavaScript logic? Does the issue occurs only on a specific device/platform or it can be reproduced in the desktop simulator?
Could you please send me a small page or Icenium project that isolates the issue, so I can examine it locally?

On a side note, it is not recommended to use kendo.bind in Mobile applications. Mobile Views should be bound to a ViewModel via data-model attribute.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Don
Top achievements
Rank 1
answered on 30 Mar 2013, 05:39 PM
Sorry for the delayed response here.  I've spent the last week+ trying many different things to get rid of this lag.  I started with the suggestion you made about it "not being recommended to use kendo.bind in Mobile applications" and went from there.  I was able to do a few things that helped (switch my ListView to use a plain array instead of a DataSource), but some lag is always there.

I know you asked for an Icenium project with which to test but I wasn't able to come up with one that simulated the lag until recently.  The reason is that my app utilizes a comet server which makes the app some "asynchronous."  Now, however, I'm able to simulate this async nature using javascript timers.

Please take a look at the Icenium project titled ScrollerTest that is tied to my Telerik account.  If you need me to send it to you via some other method, please let me know how.

A few things to note about the ScrollerTest project:
1)  The delay can only be simulated on an actual device because it is evident only when a sound is played, and I can't simulate sounds on the Device Simulator.
2)  I don't have an iOS device on which to test, so I only know that it works for sure on Android devices.
3)  When you start up the ScrollerTest on an Android device, you'll have to wait about 8 seconds for it to "spool up" before you'll start to notice the lag.  You'll notice that the bell ring and the updating of "myText" is not in sync.

In the end, I think my original thought still stands:  if I could bind the the "refresh" of myText and then play the sound at that point, that would somewhat solve the problem.  There would still be lag in that the ListView may take longer than 3 seconds to update, but at least the changing of the text and the bell sound would be in sync.

Looking forward to your help as I have spent entirely too much time on this.  Thx.


0
Alexander Valchev
Telerik team
answered on 02 Apr 2013, 04:05 PM
Hello Don,

Thank you for preparing a sample project.
I tested your application on phones with Android 4.1.2 and 2.3 but did not manage to reproduce the behaviour. On my side the sound and update of myText counter happen at the same time.

Generally speaking, KendoUI Mobiles should not interfere with PhoneGap media API. Does the project work as expected on your device, if KendoUI is not included? 

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Don
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Don
Top achievements
Rank 1
Share this question
or