How to show an image on a card without delay [SOLVED]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

How to show an image on a card without delay [SOLVED]

Post by William Jamieson » Thu Dec 18, 2014 12:45 am

Hello. Quite a simple problem I have for you today. I have a very small image (20kb) that I want to show on a card with minimal loading time on Android and iOS.

Here is the situation. I have a card with a button. I click the button. I want to go to another card with a button with the icon set to my 20kb image in less than 50 milliseconds on an Android device.

Here
Image Test.zip
Here is a sample LC file set up for android deployment
(53.9 KiB) Downloaded 187 times
is a sample stack that demonstrates what I am trying to do. Try it out!

If you have any ideas how to get the time down to less than 50 milliseconds, please let us know because I couldn't find any post about this on the forum.

[When I deployed it to my phone it took 7 seconds]

-Will
Last edited by William Jamieson on Fri Dec 19, 2014 3:08 am, edited 1 time in total.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to show an image on a card without delay

Post by Simon » Thu Dec 18, 2014 12:54 am

Hi Will,
Replace the answer with
put "Loading the image took " & tS2 && "milliseconds!"
Now how long does it take? :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: How to show an image on a card without delay

Post by William Jamieson » Thu Dec 18, 2014 5:46 am

Hmmm.. Good question. I wouldn't know exactly because the put statement doesn't show any visual feedback on Android. But by the looks of it, about 8 seconds with me counting.

BTW Happy Holidays Simon!

-Will

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How to show an image on a card without delay

Post by Simon » Thu Dec 18, 2014 12:55 pm

Ahh OK caught me on that one :)
So in testing the delay is in the image quality setting.
With your png;
Normal 27 ms
Good 27 ms
Best 9170 ms

With a 97 KB jpg image
Normal 45 ms
Good 53 ms
Best 106 ms
And yes it has to do with caching the image, if the image is on the first card, then it takes the approx 9 seconds to go from black screen to seeing the card.

Hey I did discover something I didn't know, on my Android device you don't actually have to hit the "OK" btn to make the dialog box go away, just touching the screen does it. Even with multiple responses (with "Yes" or "No" (ackkk!)).
Will, if you can confirm that we should bug it.

Simon
Edit; Hey... your image is 56 KB not 20
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: How to show an image on a card without delay

Post by jacque » Thu Dec 18, 2014 8:28 pm

Besides reducing the resolution, try displaying the image directly on card 2 instead of using it as a button icon, and see if that speeds it up.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: How to show an image on a card without delay

Post by William Jamieson » Fri Dec 19, 2014 3:08 am

No need Jacque. Simon was absolutely right! There is such a huge difference between setting the quality from 'good' to 'best', it is insane!

Solution: Create a couple sizes of image files that dont have to be resized so much so that we can get away with the 'good' setting. Wow, that caused every card on my app to speed up!

I think I would suggest to any future readers to stay away from setting the imageQuality to 'best' when developing for mobile. They simply cannot handle the graphics processing.

I will upload a sample file that allows you to play around with this phenomenon and try different resizeQualities.

Thank you Simon!

And thanks for your input Jacque.

-Will
Attachments
Image Test.zip
(54.16 KiB) Downloaded 169 times

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: How to show an image on a card without delay [SOLVED]

Post by William Jamieson » Fri Dec 19, 2014 3:12 am

BTW @Simon

I am not getting the same answer dialogue error as you. The dialogue box only goes away when i press "OK" or i use the BackKey. I

Might be specific to your version of LC?

I just used 6.6.2 and haven't noticed it on 7.0.1 RC3 and 6.7.1

-Will

Post Reply