Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How can I decrease my load time?

Author
Message
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 4th Jun 2012 10:04
My current project loads 13 image files, a total of 4.3 megabytes. It takes less than 3 seconds to load them on my Windows Vista machine, but it takes 11 seconds to load them on my iPad, and 23 seconds(!) to load on an iPod Touch or iPhone.

They are mostly 1024 x 1024, and about half are atlas images. I made them big to take advantage of the new iPad display. I could make smaller versions for the iPhone/iPod Touch, but I'd really like to cut down that 11 seconds on the iPad.

Anybody got any ideas?

Some days, the bear will eat you.
Some days, you'll eat the bear.
Today, I'm eating the bear!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 4th Jun 2012 11:03
I put a timer.

I loaded 30 single images and converted them into sprites.

Then I loaded 2 atlas files (1024x1024) with the same 30 images and converted into sprites.

Both tests were on ipad3. The sprite atlas version took much longer.

I ended up only loading the bare necessary at startup so that my app launches in 2 seconds. As the user progresses in the game more data is loaded level by level.

Now I am trying to put a spinner animation when the loading happens as there is always a 3 second delay.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 4th Jun 2012 18:37 Edited at: 4th Jun 2012 18:39
@bj - I'll try splitting up the non-sprite-sheet atlas images, see if that helps. Fortunately, I planned ahead, and all my images are sized as powers-of-two.

The sprite sheets are 5 different 1024x1024 "Themes" and changing the code to load them "on demand" does not reduce the load time. The rest of the images really have to be loaded at the start.

Thanks for the reply.

Some days, the bear will eat you.
Some days, you'll eat the bear.
Today, I'm eating the bear!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 4th Jun 2012 19:12
Put in timers and compare loading single images, and the same images in spritesheets & see for yourself which is faster. But you need timers in the code, else it's difficult to check
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 4th Jun 2012 20:59 Edited at: 4th Jun 2012 21:16
Yah, I've already got the timers in, that's how I know it takes 11 and 23 seconds, respectively.

For instance, loading in my 87,438 word lexicon takes 0.345 seconds, give or take a milli-second or two.

Some days, the bear will eat you.
Some days, you'll eat the bear.
Today, I'm eating the bear!
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 4th Jun 2012 23:12
11 vs 23 seconds, that's almost x2!!!

i did some further testing. most of the time is not in the loading of the spritesheet but in the processing from spritesheet to sprite.

this has to be improved from TGC's end.

unless it is, using spritesheets in AppGameKit on iOS is not very feasible. who wants to wait double the time when data can be loaded in half the time?
Alain91
13
Years of Service
User Offline
Joined: 20th Aug 2011
Location: France
Posted: 4th Jun 2012 23:25
I got the same problems and ended with a load tiles when needed..

But it is slow anyway..

Does anyone found a technique for this problem ?

Alain
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Jun 2012 00:16
It depends what AppGameKit is doing after it loads a spritesheet.

are subimages textures grabbed directly from memory from the main spritesheet texture, or saved in a temporary file, and reloaded?
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Jun 2012 06:25 Edited at: 5th Jun 2012 07:57
Here are some test results...



* file sizes vary, the sprite sheets are larger files than the atlas files, since the atlas images have a lot of transparent areas.

So, by loading the sprite sheets "as needed", I can shave 3 seconds off the iPad load time, and 7 seconds off the iPod load time. There is a slight delay (max of 2 seconds on iPod) when loading a new sprite sheet during the game.

I'm going to go ahead and load the sprite sheets "as needed", but that's still a long load time for the iPod.

As you can see, loading the sub-images is really quick, so I'm probably not going to load all the individual images instead of using atlases. (atli?)

Load times on Android are 12.21 seconds for the Kindle Fire, and 16.56 seconds for my HTC Droid Incredible.

Oh, and my iPad 2 (64 GB) beats the iPad 3 (16GB) by about half a second.

EDIT: Grrrrr. Switching out the sprite sheets works fine on Windows, but the iOS versions crash after a few DeleteImage(), LoadImage(), redo animation iterations. Dammit, why can't things just work like they're supposed ta? I'll try inserting a short pause and "Loading Tileset" message, see if that stops the crashing.

EDIT AGAIN: Wow, I took out the "redo animation" code, and the iOS versions crash the first time I Delete/Load the new image. I guess what works on Windows ain't gonna work on the iDevices.

LAST EDIT: Okay, got it sorted. I think you cannot delete an image, reload a new image into the same ID, then re-make an animation with that image, at least not on iOS. You have to store the original image ID, load the new image with a new ID, re-make the animation, THEN delete the original image, using the stored ID.

Some days, the bear will eat you.
Some days, you'll eat the bear.
Today, I'm eating the bear!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-23 15:01:20
Your offset time is: 2024-11-23 15:01:20