Inconsistent UI response time

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 48
Joined: Thu Jun 07, 2007 1:30 am

Inconsistent UI response time

Post by tetsuo29 » Sun Jan 28, 2018 11:39 pm

I'm working on a project in LiveCode 8.1.8 on macOS High Sierra 10.13.3 and I'm experiencing strange inconsistencies in the response time of my UI elements.

I have a field with locked text that contains a number. Above it, I have a button with a plus in it and below it, I have a button with a minus in it. As you can guess, clicking the plus button increments the number and pressing the minus button decrements it. (I actually have 6 of these locked fields with corresponding plus/minus buttons.)

Image

Unfortunately, when I click these buttons the UI doesn't respond as quickly as I think it should nor does it always respond in the same amount of time. Sometimes it takes a significant fraction of a second for the button click and resulting handlers to finish. The scripts are not complex.

For instance, the plus button above the right most field simply has this in its script:

Code: Select all

on mouseUp pButtonNumber
   handleAddSecond
end mouseUp
handleAddSecond is in the stack script and it is simply this:

Code: Select all

on handleAddSecond
   incrementUptoMax "SecondsOnes", 9
end handleAddSecond
incrementUptoMax is also in the stack script and is just this:

Code: Select all

on incrementUptoMax pField, pMax
   if field pField < pMax then
      put (field pField + 1) into field pField
   end if
end incrementUptoMax
Each field has a different name and each of the plus/minus buttons calls a handler that then calls "incrementUptoMax" with the appropriate field name & maximum value. (The minus buttons call "decrementDowntoMin" which I have not shown here but's just like the increment function except it decrements if the current value is greater than the minimum).

I was quite surprised by this slowness and inconsistency of response time in the UI. To the point that I rebooted my machine and even downloaded and installed LC 7.1.4 to see if I'd get the same behavior, which I did. I also built a standalone to see if its just something happening in the development environment but, unfortunately, I get the same behavior in the standalone.

To further test it, and because I definitely want this project deployed on Mac, I created the exact same UI in Supercard with essentially the same code (with the minor syntax differences "cd field" instead of "field") and when I click the buttons, the increment or decrement of the number in the locked fields is nearly instantaneous and as quickly as I click, the events fire and the handlers execute and update.

I'm puzzled as to why LC is having this slow, erratic behavior and if there's something I can do to alleviate it because I'd like to build my project with LC and be able to deploy on Mac, Win, & Lin.

Any help or insight is appreciated.

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 144
Joined: Thu Jun 29, 2006 4:16 pm

Re: Inconsistent UI response time

Post by Randy Hengst » Mon Jan 29, 2018 1:34 am

tetsuo29 I've never used SuperCard, so really can't answer the "why" of your question. But, have you tried using lock Screen?

on handleAddSecond
LOCK SCREEN
incrementUptoMax "SecondsOnes", 9
UNLOCK SCREEN
end handleAddSecond

randy hengst

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 48
Joined: Thu Jun 07, 2007 1:30 am

Re: Inconsistent UI response time

Post by tetsuo29 » Mon Jan 29, 2018 3:49 am

Randy,

Thanks for your reply. I had actually thought about lock screen (I've used it before). I just tried it and unfortunately it doesn't seem to have any effect.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6103
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Inconsistent UI response time

Post by FourthWorld » Mon Jan 29, 2018 3:51 am

For a single field being updated I would also expect near-instant redraw.

Can you post the stack? I don't think it's the script, but maybe there's something else going on we may be able to find.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 48
Joined: Thu Jun 07, 2007 1:30 am

Re: Inconsistent UI response time

Post by tetsuo29 » Mon Jan 29, 2018 4:08 am

Here's my stack. I'll be curious to see what anyone finds. Thanks.
Attachments
Count It Down.livecode.zip
(3.43 KiB) Downloaded 13 times

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 144
Joined: Thu Jun 29, 2006 4:16 pm

Re: Inconsistent UI response time

Post by Randy Hengst » Mon Jan 29, 2018 4:51 am

In your + and - buttons, I'd use a mouseDown call rather than mouseUp... that speeds things up a bit.

randy

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 224
Joined: Sun May 27, 2007 8:19 pm

Re: Inconsistent UI response time

Post by Martin Koob » Mon Jan 29, 2018 4:09 pm

Hi. I tried suggestions above on the buttons "ButtonAddTenHours" and "ButtonDelTenHours" locking the screen & using mouseDown to see if it would speed things up and I saw no difference.

Two other things I did was
-use send in time from the mouseDown well as using send in time ( 0 seconds ) for the handlers handleAddTenHours & handleAddTenHours
- removing the toolTip from the buttons "ButtonAddTenHours" and "ButtonDelTenHours" as I saw the tool tip appear briefly when clicking the buttons.
These two things did also not solve the problem

What I did notice is that the delay is on the second mouse click. If I click on one of the buttons like 'ButtonAddTenHours' repeatedly is that the number will change from 0 to 1 quickly, then there will be a delay in changing from '1' to '2' to 3 but then 4 - 9 will change quickly. So

Perhaps you should report this as a bug.

Martin
Attachments
Count It Down-rev MK.livecode.zip
revised stack
(3.49 KiB) Downloaded 8 times

tetsuo29
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 48
Joined: Thu Jun 07, 2007 1:30 am

Re: Inconsistent UI response time

Post by tetsuo29 » Mon Jan 29, 2018 5:17 pm

So, I changed the +/- buttons from rectangle buttons to standard buttons and this seemed to speed things up a little.

I also tried using mouseDown instead of mouseUp, and it definitely speeds things up but, I don't like it because it is technically incorrect (the user should be able to slide out of the button and release the mouse to cancel the button click).

Also, I notice that when I use mouseDown, the button's hilite and switch back to not hilited animation timing is erratic. This makes me think there's something going on with LC that has nothing to do with my scripts. I almost think that I've encountered this before and that maybe there's an issue with the hilite animation of buttons when you go below certain sizes. I dunno, maybe I just want to believe that I've encountered that previously.

Anyway, the speed is more tolerable with standard buttons and I appreciate those that looked at my stack and/or offered suggestions.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4560
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Inconsistent UI response time

Post by jacque » Tue Jan 30, 2018 9:23 pm

The pause/skip is because the engine is counting every other click as a mouseDoubleUp. Add this to your stack script:

Code: Select all

on mouseDoubleUp
  send "mouseUp" to the target
end mouseDoubleUp
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Martin Koob
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 224
Joined: Sun May 27, 2007 8:19 pm

Re: Inconsistent UI response time

Post by Martin Koob » Tue Jan 30, 2018 9:47 pm

Cool, I tried that out and just that bit of script in the card or the front script solves the issue tetsuo29 was having.

Jacque, is this something you would normally do in a stack to prevent odd button behaviour when people double click where they should click once?


Thanks

Martin

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4560
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Inconsistent UI response time

Post by jacque » Wed Jan 31, 2018 12:40 am

Martin Koob wrote:
Tue Jan 30, 2018 9:47 pm
Jacque, is this something you would normally do in a stack to prevent odd button behaviour when people double click where they should click once?
Yes, I do it when it's necessary. There are other times where you don't want multiple clicks at all, so flushEvents() is a better choice. But if you want multiple clicks to respond every time, like this stack, then I add that handler.

Edit: If you want to ignore double clicks only, but allow single clicks, then you have to set up a timing mechanism that checks if the click is inside the doubleClickInterval. If so, the handler exits.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6103
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Inconsistent UI response time

Post by FourthWorld » Wed Jan 31, 2018 1:31 am

The doubleClickInterval is also settable.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4560
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Inconsistent UI response time

Post by jacque » Wed Jan 31, 2018 8:34 am

FourthWorld wrote:
Wed Jan 31, 2018 1:31 am
The doubleClickInterval is also settable.
On April 1st, I occasionally consider setting someone's doubleclickInterval to 1 millisecond.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 10284
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Inconsistent UI response time

Post by Klaus » Wed Jan 31, 2018 11:28 am

jacque wrote:
Wed Jan 31, 2018 8:34 am
FourthWorld wrote:
Wed Jan 31, 2018 1:31 am
The doubleClickInterval is also settable.
On April 1st, I occasionally consider setting someone's doubleclickInterval to 1 millisecond.
:D :D :D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4560
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Inconsistent UI response time

Post by jacque » Wed Jan 31, 2018 5:22 pm

Actually, setting the doubleClickInterval to 1 millisecond would probably fix the timer too. The problem with that is how and when to set it back to normal so the user could doubleclick elsewhere. In this app it wouldn't matter.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Bug Triage”