App slows down with 'Wait with messages"

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

App slows down with 'Wait with messages"

Post by mattrgs » Fri Feb 21, 2014 7:45 pm

Hi everyone,
I have created an app in which there is a timer which relies on "Wait for 1 second with messages", it counts down from 30. While this timer is running a button can also be tapped, this adds one to a variable and then displays the new number in a label, this could happen up to 6/8 times per second. I initially just tested my code in the development environment in 'Run' mode, in this it worked mostly fine, although if I kept on tapping fast it would only update the label for every other one even though it counted it, I wasn't to concerned about this. However, the major problem came when I transferred the app onto my phone to test. The phone didn't register every click, if it I tapped constantly for 30 seconds it might get to 12 if I was lucky, so it had slowed down. I then created a small app with everything except the timer this ran fine, showing that it should be the timer which is the problem. Can someone shed some light on this problem, hopefully offering a solution?! Also in my app all my buttons are skinned with images, however these aren't great quality and there are only about 4.
Can someone offer some help with this please,
Thanks
Matthew

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: App slows down with 'Wait with messages"

Post by Dixie » Fri Feb 21, 2014 7:49 pm

Hi...

Instead of 'wait 1 second with messages', try...

Code: Select all

wait 0 millisecs with messages
if all you are wanting to do it wait for the liveCode engine to execute everything

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: App slows down with 'Wait with messages"

Post by mattrgs » Fri Feb 21, 2014 8:20 pm

Dixie wrote: Instead of 'wait 1 second with messages', try...

Code: Select all

wait 0 millisecs with messages
if all you are wanting to do it wait for the liveCode engine to execute everything
Hi Dixie,
I still want to keep the waiting for 1 second as I need to count down for 30 seconds, so I don't think this would work. If I didn't make it clear the timer is run completely separately from the tapping of the button.
Any Suggestions?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: App slows down with 'Wait with messages"

Post by Simon » Sat Feb 22, 2014 1:12 am

Hi Matthew,
I think the consensus on timers is to use the system clock.

Code: Select all

local tStart, tRunIt
on mouseUp
   put the milliseconds into tStart
   put true into tRunIt
   countIt
end mouseUp

on countIt
   if tRunIt then
      put the millisecs into tEnd
      put tEnd - tStart  
      if tEnd - tStart >= 30000 then
         put false into tRunIt
      end if
      send countIt to me in 1 second
   end if
end countIt
See if you can fit that in your code.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: App slows down with 'Wait with messages"

Post by Dixie » Sat Feb 22, 2014 2:14 am

Code: Select all

local count

on mouseUp
   put 0 into count
   start30Count
end mouseUp

on start30Count
   if count = 30 then exit start30Count
   send "start30Count" to me in 1 second
   add 1 to count
   put count
end start30Count
Do other things whilst counting up to 30...

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: App slows down with 'Wait with messages"

Post by mattrgs » Sat Feb 22, 2014 2:58 pm

Thanks Simon and Dixie
As far as I can see both of your suggested codes are very similar, is there any advantages to one over another?
On a slightly unrelated point when I did transfer the app to my phone all off the fonts which I had set had been lost, is there any reason for this and a way to solve it?
Thanks
Matthew

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: App slows down with 'Wait with messages"

Post by Dixie » Sat Feb 22, 2014 3:06 pm

mattrgs wrote...
is there any advantages to one over another?
LOL.. not really, there are many ways to 'skin a cat' in liveCode... I didn't see Simons post when I replied... as for your font problem
From the iOS release notes...
In iOS 3.2 and later, the ability was introduced to allow applications to bundle custom fonts which
then become available to the app (and only that app) while it is running.
To take advantage of this feature, all you need to do is reference the files of any fonts you wish to
include in the Copy Files pane. These files can either be a direct file reference, or contained in one
of the folder references. The Standalone Builder will treat any files that end with the extension ttf or
ttc as font files to use in this way.
Any fonts included in this way will appear in the fontNames and can be used in the same way as
any other font on the system.
Important: Make sure you have an appropriate license for the fonts you choose to bundle with your
app like you would any other media such as sounds, images and videos.

mattrgs
Posts: 37
Joined: Tue May 28, 2013 1:41 pm

Re: App slows down with 'Wait with messages"

Post by mattrgs » Sat Feb 22, 2014 3:53 pm

Thanks, I got that to work, I wasn't sure where to find the font files, so I found it easiest just to download one from online.

Post Reply

Return to “Android Deployment”