Hi i am developing an application using adobe air for iOS using flex.
i have the user take a snapshot and my intention is to upload the photo to my api.
the problem is when compressing the byteArray and then encoding it to a base64 String to send it up the apps freezes for 1-2 minutes.
My question is: is there a way to multithread this process in adove air, so i have it going in the background ?
and from your experience does an adobe native extension use another thread on the device for itself or no, maybe i can handle the background encoding and upload in a native extension.
Thank you all.
AS3, up until recently, was entirely single threaded. As of FP11.4 and AIR 3.4, you have access to Workers, which is essentially offloading tasks to a second thread. Beta support was added to Android in 3.8 or 3.9 and I believe it is out of beta now in 13.0. Workers are not supported by iOS, though. This is, I believe, because they have to cross compile to Objective-C to support iOS at all, so their methods won't work.
You're only option is to load the processing onto an ANE, which may or may not be a good idea. ANEs are meant to behave as a bridge between AIR and native OS APIs. While this would work, I think it goes beyond the scope of what an ANE is intended for.
Unless your photos are insanely large, I would suggest just not doing compression. Resizing photos (using the BitmapData class) is fairly quick on 4S+, so I don't think that is much of an issue (4S is closing in on being 3 years old at this point. Having old hardware means things run less than ideally, so anything older will just have to accept poorer performance)
Worker Documentation
Related
With the push towards multimedia enabled mobile devices this seems like a logical way to boost performance on these platforms, while keeping general purpose software power efficient. I've been interested in the IPad hardware as a developement platform for UI and data display / entry usage. But am curious of how much processing capability the device itself is capable of. OpenCL would make it a JUICY hardware platform to develop on, even though the licensing seems like it kinda stinks.
OpenCL is not yet part of iOS.
However, the newer iPhones, iPod touches, and the iPad all have GPUs that support OpenGL ES 2.0. 2.0 lets you create your own programmable shaders to run on the GPU, which would let you do high-performance parallel calculations. While not as elegant as OpenCL, you might be able to solve many of the same problems.
Additionally, iOS 4.0 brought with it the Accelerate framework which gives you access to many common vector-based operations for high-performance computing on the CPU. See Session 202 - The Accelerate framework for iPhone OS in the WWDC 2010 videos for more on this.
Caution! This question is ranked as 2nd result by google. However most answers here (including mine) are out-of-date. People interested in OpenCL on iOS should visit more update-to-date entries like this -- https://stackoverflow.com/a/18847804/443016.
http://www.macrumors.com/2011/01/14/ios-4-3-beta-hints-at-opencl-capable-sgx543-gpu-in-future-devices/
iPad2's GPU, PowerVR SGX543 is capable of OpenCL.
Let's wait and see which iOS release will bring OpenCL APIs to us.:)
Following from nacho4d:
There is indeed an OpenCL.framework in iOS5s private frameworks directory, so I would suppose iOS6 is the one to watch for OpenCL.
Actually, I've seen it in OpenGL-related crash logs for my iPad 1, although that could just be CPU (implementing parts of the graphics stack perhaps, like on OSX).
You can compile and run OpenCL code on iOS using the private OpenCL framework, but you probably don't get a project into the App Store (Apple doesn't want you to use private frameworks).
Here is how to do it:
https://github.com/linusyang/opencl-test-ios
OpenCL ? No yet.
A good way of guessing next Public Frameworks in iOSs is by looking at Private Frameworks Directory.
If you see there what you are looking for, then there are chances.
If not, then wait for the next release and look again in the Private stuff.
I guess CoreImage is coming first because OpenCL is too low level ;)
Anyway, this is just a guess
Currently, the AIR beta (3.9) allows concurrency on Android but does not provide it for iOS
To solve this problem, or maybe even to do it more efficiently than AIR workers when they become available on iOS, is it possible to do concurrency via a native extension (ANE)?
I see the section "Threading" at http://www.adobe.com/devnet/air/articles/extending-air.html but it only leaves me a little more educated at my guessing :)
Let's consider an MP3 Player with visualization. Can an app be built such that the native extension reads the MP3 data, processes it, and hands over both the raw sound data and computed visualization for the actionscript layer to then play/display (and possibly manipulate the display further)?
I definitely think this is a legitimate usage of native extensions. We use threading in a few of the ones we've developed. It's a complex area to create a quick tutorial though but basically the iOS documentation on NSThread is what you should be looking into.
There's a good rundown on the concepts and some sample code here:
https://developer.apple.com/library/ios/DOCUMENTATION/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html
The major difference between this and the AIR concurrency is that the concurrency code is written in AS3 whereas with the native extension you'll have to write in native code for every platform you develop on.
I've recently heard about the converting feature of Adobe Air but how well does it work?
Does it emulate every bit of code a complex Flash game using tons of libraries outputs or should you expect a lot of work to go around if you were to convert one?
I'm thinking of making a complex cross-platform game but not sure which is better/easier, to use Flash and Adobe Air for its abundant game libraries, resources and faster development or to simply go with Java.
It Would really save lots of time if I can use Flash. Though, I can imagine it would also give me headaches to worry about all the time. Like what if adobe/apple stops supporting Flash or what if the converting feature won't work.
Any advice and any bit of information would be welcome. Thanks.
AIR works well on iOS in my experience although native apps will always perform better. I cant think of any aspects of Flash that wont work when converted to run on iOS.
Whether AIR performance is good enough really depends on the individual case - how gpu and cpu intensive the game is.
You have to consider the trade-off: use existing Flash skills to create a 'good' game quickly; or learn new skills to create a 'better' game slowly - is it worth spending weeks/months learning new skills to get a few extra percent of performance? Only you can decide that.
Regarding Adobes AIR support in the future; who knows - they dont have a great track record (think flash on mobile) - but i would suggest AIR will be around for at least the medium term, if not long-term.
My personal opinion is that "mobile" is not going anywhere and now is the best time to start learning Java for Android and/or Objective-C for iOS. Like PhoneGap, Flash mobile Apps don't give you complete access to the devices entire API/SDK options, even though what they do offer usually suffices. Flash is still a respectable tool but developing "native" gives you full control over your app's memory, device interaction, cutting edge APIs, etc ...
Depending on how optimized your action script 3 code is written, you may experience some performance issues vs utilizing native graphics libraries. I assume the latest version of AIR (I know Flash 11.2 and on included some nice graphic stuff) may address performance but haven't seen any benchmarks for AIR on mobile devices yet.
If you are hoping to go the AIR route, I'd say why not take a few days and try to port it over. If all else fails get a nice iOS or Android book and cuddle with it every night until you are confident you can recreate your App natively.
It's a great thing that it's possible to compile an SWF into iOS native app. I think AIR is now the best option to write e.g. small games or interactive books. Of cause AIR app will be slowler than the same app written on e.g. objective C. The question is how slower AIR app will be. Can simple AIR apps be launched e.g. on iPhone 3G or iPAd 1?
And another question is, can arbitrary flash app be compiled into iOS native app?
Will be grateful for any thoughts!!!!!
Performance of AIR vs. Objective C:
For pure script execution, AIR apps perform rather slower than native, including on iOS. However, in virtually all cases the limiting factor of your app's performance will be rendering, not script, so it depends entirely on what you do visually in your content. This is why Crooksy suggested you look at Starling. Without Starling (or similar libraries that make use of the GPU), it's pretty challenging to get decent performance out of an iPad1. It can be done, but it takes expertise and incurs extra work. It will be much better to start with the huge performance boost of using Starling or similar.
Can arbitrary flash app be compiled into iOS native app?
As long as it's made with AS3, then it should compile. For whether it works, two main caveats come to mind: First, a handful of APIs don't work on mobile devices. (I think printing is one example.) Second, if you read in any SWFs at runtime, all actionscript inside them will be ignored. (Not for technical reasons, it's an Apple requirement.) So if your content is split into a bunch of SWFs you'll need to bundle them together at packaging time, and if you absolutely depend on reading in SWFs with script from the network at runtime, you're going to hit a wall.
Hope that helps!
Check out the new Starling frame work.
http://gamua.com/
Here's the start of a nice tutorial series (episodes 1 and 2)
http://www.hsharma.com/tutorials/
Lee Brimelow also has a few tutorials
http://www.gotoandlearn.com/
Regarding converting Flash apps into iOS compatible apps, yes that is possible but it depends on what the app actually does as to whether any modifications will be needed before it will perform correctly on a device.
I have been researching for this and read different opinions but i wanted to ask you more specific questions.
In my application i want to take 3 or 4 frames from the camera stream to process them without making the user press a button multiple times (and as fast as posible), i do this already on the android version, because android provides a callback method that contains each frame of the camera feed.
I have seen some people using the iOS AVFoundation (classes AVCaptureDevice, AVCaptureInput) to perform this tasks, but as far as i know, this is supported from version 4.0 of iOS.
Is there another way to do this and support older iOS versions? like 3.X?
how fast can the different pictures be taken?
Are there still problems using this Framework to get Apps/updates accepted on the App Store?
Thanks a lot,
Alex.
You should use the new way (AVCaptureInput), as only a few percent of users still use iOS 3. iOS adoption is much faster than android adoption. Early last winter about 90% had already upgraded to 4. At this point even 4.0 is likely in the small minority as well.
One pre-ios-4 way to do it was by opening a UIImagePickerController and taking screenshots. Depending on the exact version targeted, there are sometimes ways to disable the camera overlays.
I see this question: iPhone: Get camera preview