Loading large images in iOS

84 views
Skip to first unread message

Pier Bover

unread,
Jun 23, 2014, 1:40:52 AM6/23/14
to haxe...@googlegroups.com
TL;DR: How long does it take for a retina image to be displayed in the screen using OpenFL? Is it possible to use multithreading to load images in iOS?

Long version:

I'm developing in Adobe Air a sort of photo album for a client that involves viewing retina images for iPad (2048 x1536). At first I loaded each image individually. It worked fine. I loaded 1 photo, the user swipes left or right, remove the current photo, and load the next photo.

Now my client insists he wants to see the photos next to each other "like the in the Apple photos app" which forces me to preload all photos of the album because if I do the loading on the fly, it takes too long and the UI animations aren't fluid. Also another problem I haven't been able to solve is that Adobe Scout reports "rendering dirty regions" which causes the app to stutter for a few frames whenever I display a new image (even if that image is already loaded and decoded in memory).

I've made a native extension in Objective C to display large photos, and it works much better than Air at loading and displaying large photos. Problem is that considering the photo viewing is central to the app it would force me to develop a large portion of my code in Objective c, which would take me too long, as I don't know much Objective C nor Apple's SDK.

Another solution would be to use Starling, but on the forums people say the loading of images to the GPU memory takes too long.

So, I'd like to turn to Haxe / OpenFL and see if I can solve this. Before jumping into the pool could someone tell me if you think the performance would improve?
How long does it take to load a retina image to the screen?
Can this be done in a separate thread?

Any help is appreciated!

TIA

David Elahee

unread,
Jun 23, 2014, 3:32:45 AM6/23/14
to haxe...@googlegroups.com
There is no short answer, performance will be better and you'll be able to thread but there are still hidden horrors that can bite :-/

If you are time constrained, I would be you I would go with apple sdk, obj c is horrid but it has many builtin thing that are already top  notch optimised. If you have time, take the path you'll be able to control.

Gl



--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
David Elahee


Pier Bover

unread,
Jun 23, 2014, 3:37:10 AM6/23/14
to haxe...@googlegroups.com
But loading times would be faster?

What horrors are you referring to?


You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.

For more options, visit https://groups.google.com/d/optout.



--
Pier Bover
y...@pierbover.com

David Elahee

unread,
Jun 23, 2014, 3:43:08 AM6/23/14
to haxe...@googlegroups.com
Loading times depens on how much you are able to control what are the asset source format, what is the loading lib etc... from one source to another you can go from 4sec to 0ms (thanks to DMA calls) so I can't offer you any guarantee but I found that being able to recompile everything and have real native code usualling allows to leverage your app speed.

That being said, hidden horrors cannot be spoken...because you don't know in advance who they are :D

My "classical" hidden horror lurks beyon "that macro cannot compile on cpp but it works on flash" or "well why it that code branch fully dynamic instead of inline assembly" but hey that s life :).

Anyway your choice will have to be rationnal, so if you choose openfl , expect that some surprise may arise.

Cristian Baluta

unread,
Jun 23, 2014, 3:56:32 AM6/23/14
to haxe...@googlegroups.com
Do you want to load the whole images at once? That would be impossible, it will take all your memory very fast. What you want to do is having 3 images loaded all the time and display the one in the middle, when you swipe to right you take the left image and put it in the right and load a new image there. If the user doesn't swipe like crazy should be fluid.
In your place i would take a free native objc photo gallery and make an extension out of it.

Pier Bover

unread,
Jun 23, 2014, 4:23:50 AM6/23/14
to haxe...@googlegroups.com
Hey Christian

Problem is that if I only load 3 images, at some point I have to load another image and that breaks the UI animations. Air offers an async load method that in theory uses a different thread, but it makes my app stutter anyway.

Like I said in my first post, I have already made a gallery with Objective C, but that would force to code other parts of the app in objective C and I'd prefer to avoid that.

Do you have any hints if loading / decoding /showing images with OpenFL is faster than in Air?

Philippe Elsass

unread,
Jun 23, 2014, 6:02:51 AM6/23/14
to haxe...@googlegroups.com
One trick we found was to load the image bytes, then create a thread to run the image decoding.
Everything's been smooth after that.
Philippe

Pier Bover

unread,
Jun 23, 2014, 1:29:41 PM6/23/14
to haxe...@googlegroups.com
Hey Phillippe, how long did it take to load a retina image on an iPad?

Philippe Elsass

unread,
Jun 23, 2014, 2:47:30 PM6/23/14
to haxe...@googlegroups.com

I don't remember but it certainly isn't instant...

Reply all
Reply to author
Forward
0 new messages