Page 1 of 1

Solved - Encrypted Android standalone - 9 seconds to open

Posted: Sat Apr 08, 2017 5:36 am
by KimD
Hi

I hope to get my second LC app (a puzzle game) onto the Google Play Store next week. I'm in the final stages of testing. I've now encrypted my app, using the message box "set the password of this stack to ..." method, where-as during earlier development & testing it was un-encrypted.

On the 2nd launch (not the install launch) of my app on a mid-range Android test device :
> If my app is NOT ENCRYPTED - then I see 3.3 seconds of black screen between tapping the icon and my splash screen being displayed.
> If my app is ENCRYPTED - then I see 9 seconds of black screen between tapping the icon and my splash screen being displayed.
> Ive tested the milliseconds between the first line of my PreOpenStack and the last line of the OpenCard on my first card. For both encrypted and un-encrypted versions of my app it takes 300 milliseconds to go from the start of PreOpenStack to the splash screen being displayed. The other 3 to 8.7 seconds is whatever LC does before PreOpenStack.

1) Is there any way to encrypt an Android standalone & still have it open promptly?

2) How much (real) risk is there in not encrypting a LC (puzzle game) app which is going up on the Google Play Store?

Thanks in advance

Kim

Re: Encrypted Android standalone - 9 seconds to open

Posted: Sun Apr 09, 2017 11:13 am
by MaxV
Do you have included some source stacks? For example 2 or more main stacks (different programs).
If you used just a main stack and substacks, you don't need to encrypt.
If in the stand alone application settings, "copy files" tab, there aren't livecode source files, you don't need to encrypt. The APK is a zip file, rename it with ".ZIP", open it and see what the user can see.

Re: Encrypted Android standalone - 9 seconds to open

Posted: Sun Apr 09, 2017 7:52 pm
by FourthWorld
What is happening in your app's init sequence?

Re: Encrypted Android standalone - 9 seconds to open

Posted: Mon Apr 10, 2017 12:57 am
by KimD
Thanks Max & Richard

My app currently only has a main stack (with 6 cards). Contents include:
- 3 images (about 50KB in total, with resize quality "normal") embedded in the app
- 5 MP3 files (about 500KB in total) in Standalone > Copy Files
- about 200 SVG widgets (I confess, I love SVG widgets)
- about 1500 lines of code, 50 buttons and 10 small text fields

The unencrypted APK file is 9500KB.

=====================================

On init my app does the below. According to my monitoring this executes in 300 milliseconds.

PreOpenStack
> Set the location of 3 files (saved state, puzzle results, in-app monitoring)
> mobileSetAllowedOrientations "portrait"
> Set the textfont of this stack to "Roboto"

InitialiseVariables1 > Set the values of 24 variables

ConfigureMainScreenGrid > Set the values of 125 variables

SetupCard
> Set the values of 2 variables
> Write 2 variables into the saved state file
> Choose which style of SVG widget (Android or IOS) to use for the back button

SetControlSizeLocation > Resize card. Determines the size & location of the controls on my first card, being:
- 2 images (both 21KB)
- 1 SVG widget
- 2 buttons
- 2 text fields

SetStrata > Set the layers of the above elements

OpenCard
> Write 6 variables into the saved state file
> mobileStoreEnablePurchaseUpdates & mobileStoreRestorePurchases

InitaliseVariables2 > Set the values of 23 variables

PositionScrollElements > Resize the 2 text fields & 1 image that make up the scrolling group on the first card

SetupScroller > Configure mobileControlSet

==============================================

Regards

Kim

LC 8.1.2 rc 3 Indy

Re: Encrypted Android standalone - 9 seconds to open

Posted: Mon Apr 10, 2017 6:01 am
by KimD
In case it is helpful, I also attach the results of the Message Watcher (in the IDE, not the Android app).

Regards

Kim

Re: Encrypted Android standalone - 9 seconds to open

Posted: Mon Apr 10, 2017 6:04 am
by KimD
The above images have been displayed in order 3, 2, 1. The 4th, and final, output of the message watcher is attached below.

Re: Encrypted Android standalone - 9 seconds to open

Posted: Mon Apr 10, 2017 10:24 am
by MaxV
KimD wrote:Thanks Max & Richard

My app currently only has a main stack (with 6 cards).
...
You don't need to encrypt. Malicious user could only copy the MP3 files.

Re: Encrypted Android standalone - 9 seconds to open

Posted: Mon Apr 10, 2017 3:24 pm
by FourthWorld
KimD wrote:On init my app does the below. According to my monitoring this executes in 300 milliseconds.
Have you been able to determine where the additional time is spent?

Encryption can be expected to add a little extra time to unpack scripts, but with the relatively small number of scripts in play here that shouldn't be the cause of the extra delay. I would imagine unencrypting scripts should normally add only a few milliseconds to boot time.

You might consider filing a bug report on this to see what the core dev team suggests.

Re: Encrypted Android standalone - 9 seconds to open

Posted: Mon Apr 10, 2017 4:55 pm
by capellan
Maybe, just maybe, the Standalone builder is encrypting
all MP3 and Images too...
KimD, Could you verify this in your .apk installer?

Al

Re: Encrypted Android standalone - 9 seconds to open

Posted: Tue Apr 11, 2017 11:21 pm
by KimD
Damn - wrote a long reply then lost it when my forum connection timed out.

Short version.

I've identified that the problem is my 200 SVG widgets. If I reset the icon paths of these to the LC default icon path, then the load time for my encrypted Android standalone drops from over 8.5 seconds to under 2 seconds. It seems that LC is encrypting my complex icon path data, then spending 6.5+ seconds un-encrypting this when the app is launched.

Options that occur to me:

1) Store the icon path data in a copy file, and use this to populate the SVG widgets after the app launches.

2) Store the icon path data in an un-encrypted sub-stack.

3) Just not worry about encrypting my Android standalone.

Thanks in advance for any advice

Kim

Solved - Encrypted Android standalone - 9 seconds to open

Posted: Wed Apr 12, 2017 6:49 am
by KimD
I realised that there was an easy solution available to me.

Only 10% of my SVG widgets are "source". The other 90% of my SVG widgets are derived, by copying a source SVG widget, during the execution of my app.

So I:
1) wrote a "SpringClean" handler which set the iconPath of my (approx 180) derived SVG widgets to empty; and
2) immediately before building my standalone, called SpringClean from the message box.

The encrypted version of my app now opens in under 2 seconds on my mid-range Android test device.

What I've learnt - clean up any derived graphics, including SVG widgets, before building a standalone.

Thanks for all of your help.

Kim

Re: Encrypted Android standalone - 9 seconds to open

Posted: Wed Apr 12, 2017 9:24 am
by Klaus
Hi Kim,

instead of using the message box, add this handler in your stack script:

Code: Select all

on savingstandalone
  springClean
end savingstandalone
LC will send this message BEFORE it creates the standalone form your stack!
A quite helpful thing :D

There are more "standalone creating" related messages that may be helpful,
check the dictionary for "standalone".


Best

Klaus

Re: Solved - Encrypted Android standalone - 9 seconds to op

Posted: Wed Apr 12, 2017 9:18 pm
by KimD
Nice. Thanks Klaus

Kim