Android Question B4A - No responsive and very Slow startup to Main Activity

DeviousD

Member
Licensed User
Longtime User
Hi Guys,

Need a little assistance with an problem i have coded myself into. 🤯

APP was developed with 5 images to load to a quiz type page, showing an image and then the user selects the right answer, simple stuff.
Got all the bugs and kinks all sorted as usual before implementing the additional 350 Plus .png files.

So i added all the images to the projects FILE folder via the IDE. They are all there, in Debug mode it was all good as i used the File.DirAssets to load an image into the imageview all works well.
I then proceeded to make it a Release build, the files were not present. i kept getting an exception as "File not found..."
I then proceeded to add the files to the Visual Designer, thinking this will definitely include such files in my build.

Grand, this is the case, BUT the app takes ages before it get to display the main activity. the startup is over 15 seconds.... and yes getting the ANR message... its trying to kill the APP before it even starts... 😭

@Erel, i did review your video on performance, and i didn't stumble on any other way to kind of get the app to load up the Assets in a Async mode. So its not the usual suspects as per the video you made.

The 350 .png are about an average size is about 75kb small sized files.
The WHOLE apk works out to be 40MB, im not sure if that is large for a APK, most of my other work was MAX 6MB.

I get that this must be the bulk of images that now need to be "Moved" to the "cache" workspace of the APP so i can be addressed when needed.

Any ideas on how to streamline this, SQLite DB has the file name references, the SQLite is super fast. the Bottleneck from what i can see, is the Loadup before first Activity is shown.

I have looked on the Forum for a similar post and have not found one that addresses lagging/black screen/ startup delay / long memory load...

Any advice guys?
 

JohnC

Expert
Licensed User
Longtime User
Have you tried remarking out lines of code in the Activity_Create sub (and possible Activity_Resume sub) to narrow down what lines are causing the delay?
 
Upvote 0

DeviousD

Member
Licensed User
Longtime User
thanks the the suggestion JohnC, nada, i get where you coming from, however, im still thinking its gotta do with the Assets loading in...
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Then, maybe as a test you could remove 3/4 of the png files in the assets folder, recompiling and see if the app starts faster.
 
Upvote 0

DeviousD

Member
Licensed User
Longtime User
hmmmm, that was my only other option to do should the wise owls here not have any advice, it was effort to get them in, now im gonna have to get them out.. i was hoping it was some compiler directive... hahaha - wishful thinking right...

Thanks JohnC
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
If the startup is due to a 40MB APK, then there is a trick I use in these situations...

Put all of the png files in a zip file and put the "quiz-images.zip" file on your website.

Then modify your app so when it starts, it checks to see if the zip file was already downloaded, and if so, start the quiz.

However, if the zip file was not previously downloaded, then tell the user that you need to do a one-time download of the media for the app. Then download the media zip file from your website and unzip it to a folder that your app can easily access.

This way, it would reduce the APK down to 10MB or less so it will then *always* load quickly.
 
Upvote 0

DeviousD

Member
Licensed User
Longtime User
nice thinking sir, split the images into a "extended" pack and download those when they want more from the Quizz, really a very doable solution, thank you , you are a Squire and a gentleman!
Ill look into that option also...
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
But the reason I'm thinking it might not be due to all the png's is that when you install an APK with a lot of assets, from what I understand those assets are alerady put in a separate folder as part of the install process, and the asset files are only loaded into the app when the app specifically asks for an asset file.

So having a lot of image assets should not effect the app's load time because your app is not loading in all of the png files when it starts, right? It only loads the png files as the quiz progresses, right?
 
Upvote 0

DeviousD

Member
Licensed User
Longtime User
yesh, only load a imagefile related to the selected question, so its a single when needed. and this work 100% with 5 sample images, Only when adding the extra 350 images BOOM, its a APP meltdown... lmao! not the Blue Screen of death, but a Black screen of the VOID!
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Some other experts on the forum are probably sleeping, so give it another 12 hours and maybe they might have a clue.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Only when adding the extra 350 images BOOM, its a APP meltdown
That is to be expected if you are loading them on the main thread. You need a solution that loads the images when required, or in the background rather than loading them all at once. Loadin them when needed will save memory too.
 
Upvote 0
Top