A Little Message To The Developers RE: LiveCode 7.0.3

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by SirWobbyTheFirst » Sat Mar 07, 2015 3:29 pm

Hi Mark, I was wondering if you could shed some light here as I wonder whether an issue I'm having may be connected to the arrays performance in some way:

I am working on my new project called Hydra, it is intended to be a console like PowerShell and Bash for Windows, Mac and Linux and with it, it has a simple menubar, consisting of a Console, Edit and Help menu along with a context menu that pops up whenever you right click the input or result fields and because the results field is intended to show results, it has the lockText property true but the traversalOn property on and the Context and Edit menus are setup to disable menu items that cannot be used in the read only field such as Undo, Cut, Paste and Delete and thus I have a simple MouseDown handler in the Results field that goes like this:

Code: Select all

On MouseDown pButton
   If pButton = 3 Then
      Disable MenuItem 1 Of Button 4 // Undo
      Disable MenuItem 3 Of Button 4 // Cut
      Disable MenuItem 5 Of Button 4 // Paste
      Disable MenuItem 6 Of Button 4 // Delete
      Popup Button 4
   End If
End MouseDown
When doing this, the menu pops up but it takes an extremely long time to do so, like it is hella noticable from a user perspective (About a second or two) and it seems to be the calls to Disable and Enable menu items and I was wondering if you could possibly give a thought about what could cause it, using an If statement like so:

Code: Select all

On MouseDown pButton
   If pButton = 3 Then
      If Character 1 Of Line 1 Of Button 4 <> "(" Then
         Put "(" Before Line 1 Of Button 4
      End If
      // Rinse repeat for lines 3, 5 and 6.
      If pButton = 3 Then]
         Popup Button 4
      End If
   End If
End MouseDown
Yields the same lag in popping up the context menu, additionally doing a MouseDown in the Edit menu to disable those menu items before it appears also yields lag, but once the menu items are disabled, the lag doesn't occur until I make a call to Enable them again, at which point it the delay occurs again. It seems new to LiveCode 7 as 6.x seemed to handle the context menu fine and so I wondered if it could be connected to the array delay (Hey hey, it rhymed) in some way?

DISCLAIMER: I'm having to take meds for my tonsils and I think they've just kicked in again, so I hope this looks like English to everyone.

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

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by FourthWorld » Sat Mar 07, 2015 4:29 pm

@runrevmark: Given that many of the use-cases requiring sorting array keys involves numeric keys, could we consider adding indexed arrays to compliment the associative arrays we have now?

I would imagine that some aspects of indexed arrays would be more performant as well, yes?

Even better: is there some clever trick you could do under the hood so that when the engine see that keys are always numeric it uses an indexed array rather than an associative one? That may be too tricky; if not, having separate syntax for the separate type of array would be fine.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by FourthWorld » Sat Mar 07, 2015 7:03 pm

@mickpitkin92: I think there may be something else going on there, as I tested your handler in v7.0.3 on OS X and Ubuntu and the popup appears instantly.

Do you have any frontScripts in play which may be handling mouseDown?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by SirWobbyTheFirst » Sat Mar 07, 2015 11:46 pm

Hi Richard,

Nope, it is on Windows 8.1 and it is nothing but the vanilla scripts that the IDE loads, I haven't tried it as a standalone so maybes I should do that, I just thought the engines would be unified in functionality such as those.

EDIT: Upon further inspection, it seems to only be in the IDE, compiling to a standalone, results in no lag. Crap, ma bad.

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

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by FourthWorld » Sun Mar 08, 2015 12:02 am

The runtime and IDE engines are almost exactly parallel, so it seems what you've found is a side-effect something in the IDE scripts.

When you have a moment, could you read every script in the IDE and let me know if you find it? :)

More seriously, it may be worth poking around in the frontScripts that begin with "rev" and see if there are mouseDown messages trapped there, and what they might be doing.

The odd thing though is that I don't see this here, raising a different question: do you have any plugins installed other than the ones that shipped with LC?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

SirWobbyTheFirst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 239
Joined: Tue Jun 30, 2009 11:15 pm

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by SirWobbyTheFirst » Sun Mar 08, 2015 3:29 pm

That's what I figured would be the case, I'll take a gander at perusing the front scripts at some point today and see if they are trapping MouseDown or MouseUp. The only extra plugin I have loaded is one I made that has been kicking on since 5.5 and has never introduced any lag, it makes use of MouseDown but only when the plugin's main window has focus, the plugin main stack does live in the message path but it does not trap the MouseDown message nor any other message that would contribute such a lag.

I should note as well, that I have a rawKeyDown handler that looks for the Menu key code (Inbetween the right hand Ctrl+Win keys) and pops up the menu as well and that introduces the same kind of lag, so it is definitely in the Enable and Disable MenuItem commands in the IDE. It's baffling I know.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by LCMark » Thu Mar 12, 2015 9:36 am

@FourthWorld: Leveraging the 'indexable' nature of some arrays was precisely what I was meaning.

At the moment 'sort' and 'filter' only operate on strings - both could be extended to arrays.

Filter could act on any array as it is not an ordered operation.

Sort is an ordering operation and so would only be able to act on arrays which have numeric keys. Indeed, the engine already has the idea of a 'sequence' array (this is an array which has integral numeric keys from 1...the number of elements)... Thus 'sort' could 'easily' act on such an array - the effect of sorting such an array would be to swap the values of the keys around so that they are ordered in the way you requested as you iterated from 1...the number of elements.

Ideally a number of things would be a little more competent in the engine. In particular, such sequence arrays would probably be implemented internally as a 'proper list' (i.e. a vector of values, rather than a mapping); and things which are essentially 'string lists' in the engine at the moment (e.g. the result of keys()) would not be turned into strings until they really needed to be. This 'lazy' string construction means that values will flow as far as they can before having to undergo a string conversion and accumulation - which is, in many cases, extra work that is not needed (and is, as we have seen from @malte's test stack, quite expensive!).

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: A Little Message To The Developers RE: LiveCode 7.0.3

Post by LCMark » Thu Mar 12, 2015 9:37 am

@mickpitkin92: You can use the 'Suspend Development Tools' option in the IDE to get stacks to run more like they are running in a standalone. In this case it seems like there is an IDE script interacting with your scripts and causing the slow-down. If you file a bug then we'll be happy to take a look - hopefully we will be able to replicate the issue you are seeing :)

Locked

Return to “Engine Contributors”