CPU usgae

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Re: CPU usgae

Post by FourthWorld » Fri Oct 01, 2021 5:17 pm

One of the ironies with this is that the need to support nonstandard usage is at least part of the reason it ate so much CPU time.

MacOS handles the rendering with some additional overhead, but being highly optimized within the system it's not too bad by itself.

But the OS routines insist on rendering it against the OS default background. If folks using xTalks could be relied on to read and adhere to the design conventions published by the OS vendor, the xTalk engine might be able to use those more directly.

But xTalkers may place a default button over anything, even an image or a video, so the OS antiasing would leave unpleasant artifacts, with some pixels showing the default background color/pattern against an underlying object that doesn't match what the OS expects should be there.

So xTalk engine devs need to jump through all sorts of extra hoops to make that possible. And those extra hoops eat lots of clock cycles, because they need to be called over and over to maintain the animated pulsing effect.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: CPU usgae

Post by jacque » Fri Oct 01, 2021 6:03 pm

Didn't the pulsing default button go away when Apple changed its OS to be flatter? It's been so long since I saw a default button I can't remember. Apple says to avoid dialogs now except for extreme cases where you absolutely have to interrupt the user.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: CPU usgae

Post by FourthWorld » Fri Oct 01, 2021 6:52 pm

jacque wrote:
Fri Oct 01, 2021 6:03 pm
Didn't the pulsing default button go away when Apple changed its OS to be flatter? It's been so long since I saw a default button I can't remember.
Yep. I described it in past tense for that reason. But I'm not sure if the LC engine special-cases its redraw for newer macOS versions that no longer need the constant churn. Hopefully Mark can clarify (or perhaps I missed it in his earlier replies here).
Apple says to avoid dialogs now except for extreme cases where you absolutely have to interrupt the user.
Multiple windows in general have been fading from common usage ever since around the turn of the century when Apple premiered iMovie.

Earlier video editors commonly required at least four separate windows, and a bit of fiddling to place them where you want them. Most '90s apps did.

iMovie and other newer apps adopt a web-inspired layout motif favoring a single window containing multiple resizable panes, easily doable in LC with groups.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: CPU usgae

Post by dalkin » Sat Oct 02, 2021 12:19 am

Thank you everyone for your input. I changed the code as Mark/Stam advise on page 1 but the problem/crashing remains. I am now going to move toward SVG objects as buttons so I'll let you know how that goes. The recalcitrant card does contain plenty of rectangular buttons .. no Blue Throbbers. On mouseOver in the IDE, only the blue button is declared as a default button but I'm guessing the rectangular button and standard button are also default buttons, though not labelled as such.

Edit: I've just noticed that a rectangular button can also be labelled as a Default Button in the Property Inspector. I've deselected the 3 that were rectangular AND default and I'll press on and update from time to time.

Edit: 25 minutes in and everything is behaving as it should. Touch wood.
If we're treading on thin ice, well you might as well dance.

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

Re: CPU usgae

Post by LCMark » Sat Oct 02, 2021 11:01 am

FourthWorld wrote:
Fri Oct 01, 2021 6:52 pm
jacque wrote:
Fri Oct 01, 2021 6:03 pm
Didn't the pulsing default button go away when Apple changed its OS to be flatter? It's been so long since I saw a default button I can't remember.
Yep. I described it in past tense for that reason. But I'm not sure if the LC engine special-cases its redraw for newer macOS versions that no longer need the constant churn. Hopefully Mark can clarify (or perhaps I missed it in his earlier replies here).
The engine does not - I must confess I thought that there was some direct API we used to query the animation requirements but it appears there is not, and thus if a button is labelled as default and is being rendered as a themed button then it still periodically redraws.

If anyone happens to know in which macOS version (exactly) the default button animation stopped being used then that would be most helpful - I'm pretty sure its certainly not present in Mojave, Catalina nor Big Sur - perhaps not High Sierra either.

Anyway, I've put resolving the above issue on the list to fix for 9.6.6 - however, regardless of that I'd still suggest only using default buttons for the purpose they were intended :D

@dalkin: Yay! I'm glad you've got your stack working well again on Big Sur!

dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: CPU usgae

Post by dalkin » Sat Oct 02, 2021 9:23 pm

Using default buttons for the purpose for which they were intended does not appear to be defined in the docs anywhere. It would seem to me that a lesson is needed to specifically address this because building an app using a strategy to NOT use buttons freely available in the IDE is like having a bowl of peanuts permanently available on the dining room table ie. it's hard to stop snacking on them.

But notwithstanding that, a huge thanks to everyone who contributed to resolving this at a local level!

A quick search using those (new) broad search terms reveals this from 2017, specifically:
Image

https://livecode.fandom.com/wiki/DefaultButton
Attachments
Screen Shot 2021-10-03 at 7.12.05 am.png
If we're treading on thin ice, well you might as well dance.

dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: CPU usgae

Post by dalkin » Sun Oct 03, 2021 2:33 am

I give up.

LC is now freezing when I switch from 'Run' mode to 'Edit' mode. I don't have any 'default' buttons in the stack. It just freezes. There was a brief respite a few hours ago but despite restarting the Mac and reinstalling LC, the freeze continues.
If we're treading on thin ice, well you might as well dance.

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

Re: CPU usgae

Post by jacque » Sun Oct 03, 2021 5:41 pm

That sounds like what happens when there's an infinite loop somewhere. Do you have any repeat loops in the code?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: CPU usgae

Post by dalkin » Sun Oct 03, 2021 10:10 pm

I'm unable to identify the issue. I have reverted to an earlier version of the project that seems to be working.
If we're treading on thin ice, well you might as well dance.

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

Re: CPU usgae

Post by FourthWorld » Sun Oct 03, 2021 10:12 pm

If you have the time to identify the differences between the working and non-working stack files it would be interesting to know what they are.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: CPU usgae

Post by dalkin » Mon Oct 04, 2021 10:54 am

Here's a screen shot showing 3 versions of the same file, saved consecutively but displaying different byte sizes, otherwise identical in every way. NB V2 is the working stack and shows a later modified time only because it was the last stack re-opened to confirm that it is working.
Screen Shot 2021-10-04 at 8.49.08 pm.jpg
If we're treading on thin ice, well you might as well dance.

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

Re: CPU usgae

Post by FourthWorld » Mon Oct 04, 2021 10:59 am

The difference in bytes is telling. What's in those bytes?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: CPU usgae

Post by dalkin » Mon Oct 04, 2021 11:13 am

Good question. Could it be that using variables adds data? For example, at one part of the stack where I'm loading sound files the code to load a folder of files into a field 'Playlist' is:

Code: Select all

on mouseUp
   answer folder "Choose the folder containing the sound files?"
   if the result is not cancel then
      put it into tChosenFolder
      set the defaultFolder to tChosenFolder
      
      // Get the current file lists
      put field "playlist" into tPlayList
      put the cPlayListPaths of field "playlist" into tPlayListPaths
      
      put the files into tFiles
      filter tFiles with regex pattern "(?i)\.(wav|aif|wmv|m4a|mp3|wma)$"
      repeat for each line tFile in tFiles
         // Update the list of full paths
         put tChosenFolder & "/" & tFile & return before tPlayListPaths
         
         // Update the list of files
         put tFile & return before tPlaylist
      end repeat
      
      // Clean up
      if the last char of tPlayListPaths is return then
         delete the last char of tPlayListPaths
      end if
      
      if the last char of tPlaylist is return then
         delete the last char of tPlaylist
      end if
      
      // Update the field
      set the cPlayListPaths of field "playlist" to tPlayListPaths
      set the text of field "playlist" to tPlayList
      put the longFilePath of tFile into fld "URL"
   end if
end mouseUp
And I clear the field and the list by using a button to put 'empty' into the field 'Playlist' .. but I don't know enough to know whether the data fed into the variable should be somehow cleaned out.
If we're treading on thin ice, well you might as well dance.

dalkin
Posts: 176
Joined: Wed Jul 04, 2007 2:32 am
Location: Blackheath, Australia
Contact:

Re: CPU usgae

Post by dalkin » Mon Oct 04, 2021 11:26 am

That seems to be the source of the problem indeed. I duplicated the working stack of 2,355,234 bytes then loaded the sound files into the duplicate and emptied the fields and quit the stack. Reopened it, navigated to the card with the controls and instant freeze in Edit mode with a byte size of 2,355,263.
If we're treading on thin ice, well you might as well dance.

Bernard
Posts: 351
Joined: Sat Apr 08, 2006 10:14 pm
Location: London, England

Re: CPU usgae

Post by Bernard » Mon Oct 04, 2021 12:59 pm

What happens if you repeat that process but you also put empty into the customproperty when you clear the fields (I know that's not a solution, just trying to identify at what point a change causes your problem).

Post Reply

Return to “Mac OS”