Solved - Encrypted Android standalone - 9 seconds to open

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Solved - Encrypted Android standalone - 9 seconds to open

Post by KimD » Sat Apr 08, 2017 5:36 am

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
Last edited by KimD on Wed Apr 12, 2017 9:17 pm, edited 1 time in total.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Encrypted Android standalone - 9 seconds to open

Post by MaxV » Sun Apr 09, 2017 11:13 am

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.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: Encrypted Android standalone - 9 seconds to open

Post by FourthWorld » Sun Apr 09, 2017 7:52 pm

What is happening in your app's init sequence?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: Encrypted Android standalone - 9 seconds to open

Post by KimD » Mon Apr 10, 2017 12:57 am

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

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: Encrypted Android standalone - 9 seconds to open

Post by KimD » Mon Apr 10, 2017 6:01 am

In case it is helpful, I also attach the results of the Message Watcher (in the IDE, not the Android app).

Regards

Kim
Attachments
MessageWatcher3.png
MessageWatcher2.png
MessageWatcher1.png

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: Encrypted Android standalone - 9 seconds to open

Post by KimD » Mon Apr 10, 2017 6:04 am

The above images have been displayed in order 3, 2, 1. The 4th, and final, output of the message watcher is attached below.
Attachments
MessageWatcher4.png

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Encrypted Android standalone - 9 seconds to open

Post by MaxV » Mon Apr 10, 2017 10:24 am

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.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

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

Re: Encrypted Android standalone - 9 seconds to open

Post by FourthWorld » Mon Apr 10, 2017 3:24 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Encrypted Android standalone - 9 seconds to open

Post by capellan » Mon Apr 10, 2017 4:55 pm

Maybe, just maybe, the Standalone builder is encrypting
all MP3 and Images too...
KimD, Could you verify this in your .apk installer?

Al

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Re: Encrypted Android standalone - 9 seconds to open

Post by KimD » Tue Apr 11, 2017 11:21 pm

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

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

Solved - Encrypted Android standalone - 9 seconds to open

Post by KimD » Wed Apr 12, 2017 6:49 am

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

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

Re: Encrypted Android standalone - 9 seconds to open

Post by Klaus » Wed Apr 12, 2017 9:24 am

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

KimD
Posts: 223
Joined: Wed Jul 08, 2015 5:51 am
Location: Wellington, New Zealand

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

Post by KimD » Wed Apr 12, 2017 9:18 pm

Nice. Thanks Klaus

Kim

Post Reply

Return to “Android Deployment”