Very slow launch of stack data, from a Splash stack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

trevix
Posts: 1047
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Very slow launch of stack data, from a Splash stack

Post by trevix » Sat Feb 01, 2025 7:08 pm

You could try setting the passkey of the stack before the "go stack" command...
I think you mean the "password", not the passkey.
I protect, with the password, the data stack at the "savingMobileStandalone" message.
The point is not to have a readable data stack in the app Bundle or APK.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7358
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Very slow launch of stack data, from a Splash stack

Post by jacque » Sat Feb 01, 2025 7:39 pm

Passkey is a temporary way to unlock the stack without removing the password. It will relock automatically when the stack is closed but if you want to manually relock it after a short delay then you can set the passkey to empty.

The only issue with that is that you need to store the password in order to set the passkey by script. You could store it in the splash stack where it would be unlikely to be hacked, especially if the mainstack is passworded.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

trevix
Posts: 1047
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Very slow launch of stack data, from a Splash stack

Post by trevix » Sun Feb 02, 2025 9:33 am

Sorry but I don’t understand.
Why would I want to unlock the data stack and how would this fix my delay problem?
In order to unlock the stack I need to load it first in memory, I think, and this is causing the delay. Can you clarify?
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7358
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Very slow launch of stack data, from a Splash stack

Post by jacque » Mon Feb 03, 2025 1:29 am

I'm not sure it would entirely fix the problem but it might help a little. I suspect the delay is caused by the engine decrypting a large amount of data. Whenever a script accesses a property of a closed stack, the stack will load into RAM in the background. If nothing else, it would move any delay a little earlier in the sequence, presumably when you're dealing with all the libraries and other things the mainstack does. You'd have an opportunity to put up a progress bar so the user knows something is going on. Then when you issue the "go" command, the stack will already be decrypted and in memory and should open immediately. (Actually, referencing any property would load the stack into memory but I'm not sure if it would be decrypted.)

Since setting a passkey only requires a single line of code in the mainstack sequence, it's an easy thing to test. The only other thing I can think of is to reduce the size of the data stack. I don't know what's in there, but if it is possible to load data on demand instead of all at once when the stack opens, that would speed things up.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9982
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Very slow launch of stack data, from a Splash stack

Post by FourthWorld » Mon Feb 03, 2025 2:32 am

I hope trevix has time to test this, if only because I'm curious whether it improves his situation.

I'm also hoping there's a bug report on the slowdown, even if it's just flagged for review.

There are few benefits to proprietary tools if we can't keep our work proprietary without accepting extreme performance loss.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevix
Posts: 1047
Joined: Sat Feb 24, 2007 11:25 pm
Contact:

Re: Very slow launch of stack data, from a Splash stack

Post by trevix » Mon Feb 03, 2025 9:03 pm

Let's recap:
- My splash stack is named "Referi"
- My data stack is named "ReferiTOP"
- When I test install or generate a standalone, I password protect "ReferiTOP" on the "savingMobileStandalone" message.
- MyLog messages are a internal log to help me out (save data to disk): the "Prev 2.126 s" means 2 seconds and 126 milliseconds from previous MyLog message.
- My problem is the long time the engine takes to open the password protected ReferiTOP, running in a not so fast Android 11 device.

Example one:
As suggested I passkeyed the "ReferiTOP" before opening it. The code, from the "Referi", is like this:

Code: Select all

if there is not a file sStackPath then
--just to be sure: if the stack is not in the document folder, use the stack loaded in the copy pane of standalone setting
--but this should never happens since the ReferiTOP stack, on first launch, is copied to the doc folder.
          put sSourceDirectory & "Referi_/ReferiTOP.livecode" into sStackPath
end if
  try
          myLog "","Setting ReferiTOP passkey"
          DeProtectMyStacks sStackPath
          go stack sStackPath--path to the ReferiTOP stack, be it in resources or Documents
          put the result into tResult
          if tResult is not empty then
               answer "Result of opening ReferiTOP:" && tResult
          end if
     catch errorVariable
          MyLog "", "-----------REFERI: ERROR launching ReferiTOP" && errorVariable
     end try

Code: Select all

private command DeProtectMyStacks pStackPath
     try --substack must be passkeyed too
          set the passkey of stack pStackPath  to "XXX"
          repeat for each line tSubStack in the substacks of stack pStackPath
               set the passkey of stack tSubStack of stack pStackPath to "XXX"
          end repeat
          MyLog "","-----------ReferiTOP PassKey has been set"
     catch errorVariable
          MyLog "","-----------Referi ERROR: Passkey failed" && pStackPath & cr & errorVariable
     end try
end DeProtectMyStacks
The result of the MyLog is the following:
2025,2,3,20,42,22,2 (Prev 0 s) = -----------REFERI: OpenStack
2025,2,3,20,42,23,2 (Prev 0.958 s) = -----------REFERI: GoReferiTOP /data/user/0/com.trevix.it.segnapunto/files/Referi_/ReferiTOP.livecode
2025,2,3,20,42,23,2 (Prev 0.001 s) = Setting passkey
2025,2,3,20,42,36,2 (Prev 12.843 s) = -----------REFERI: PassKey has been set
2025,2,3,20,42,36,2 (Prev 13.304 s) = PreOpenStack stack "/data/user/0/com.trevix.it.segnapunto/files/Referi_/ReferiTOP.livecode"
2025,2,3,20,42,36,2 (Prev 0.002 s) = Loading Prefs
As you can see, the delay is doubled (12.843 + 13.304), compared to the MyLog without the Passkey action:
2025,2,3,20,47,59,2 (Prev 0 s) = -----------REFERI: OpenStack
2025,2,3,20,48,0,2 (Prev 0.925 s) = -----------REFERI: GoReferiTOP /data/user/0/com.trevix.it.segnapunto/files/Referi_/ReferiTOP.livecode
2025,2,3,20,48,13,2 (Prev 13.072 s) = PreOpenStack stack "/data/user/0/com.trevix.it.segnapunto/files/Referi_/ReferiTOP.livecode"
2025,2,3,20,48,13,2 (Prev 0.002 s) = Loading Prefs
I believe that setting the passkey is the equivalent of reading a property of ReferiTOP, that is putting the stack in memory and, after that, removing it. That would explain why opening the stack still takes 13 seconds.
Trevix
OSX 14.6.1 xCode 15 LC 10 RC1 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”