Skip to main content
sinious
Legend
April 25, 2012
Question

Adobe: What frameworks are compatible with Native Extensions on iOS?

  • April 25, 2012
  • 3 replies
  • 7314 views

Man it's really hard to diagnose what could possibly be going wrong compiling ANEs for iOS. I dev apps in Xcode that work perfect, zero leaks. I use any part of the majority of the frameworks I've tried (none visual) and they simply don't work outside a very rare few. Vibration, gyroscope, alert modals, etc.

Is there a list of compatibility between ANEs and classes on platforms that AIR supports? Whether it be Windows, iOS, Android, MacOSX, etc?

Is there some way to "know" that a framework should be supported? For example, all I remember reading is to steer clear of visual classes. Oddly the UIAlertView modal works on iOS (that's visual to me but *shrug*).

My current need is to use NSURLConnection and NSURLRequest. Both are in Foundation.h. Neither are visual. They're simply classes that make a connection to a host while sending and receiving responses. Yet any time I attempt to instantiate a NSURLRequest it's insta-crash. I comment it out and the ANE works fine. So far I find almost everything I do with ANEs to fail.

Clearly the framework classes I'm using aren't supported or I'm doing it miserably wrong.

A chart indicating support would be REALLY nice for each platform.

On another note, has anyone utilized NSURL* on iOS successfully in an ANE?

This topic has been closed for replies.

3 replies

Inspiring
March 19, 2013

Just stumbled across this thread.  In terms of native extensions that are visual, can you point me to more info on that?  I have had wierd issues and thinking it might be native UI Extension on iOS causing it since it is used throughout.  Would like to understand if this is the issue.

sinious
siniousAuthor
Legend
March 19, 2013

Take this with a grain of salt but as of the time of this discussion, visual classes were absolutely not supported. Only any obj-c/cocoa libs that were non-visual (logic, network, etc) were able to be wrapped in an ANE. Displaying the visual like cocos2d, etc were not supported at all.

To be honest, Flash is a far easier to develop graphics in so I can understand that limitation. I'm not saying 1 whole major version later since this post that this is still the case but it would make sense if it is. Stage3D is very similar to the lower level openGL ES programming in obj-c. With the frameworks you almost, or do, have a similar cocos2d workflow that directly uses the GPU for acceeleration.

Inspiring
May 9, 2012

Very interested in this topic and would love to know if you get an answer to your original question.  Did you resolve this yet?

I've been using Adobe Native Extensions for Native Alerts and NetworkInfo.  I'd like to find more information on why native iOS visual classes can't be used in an ANE.  Do you know why specifically?

sinious
siniousAuthor
Legend
May 10, 2012

I've only seen it in videos and have read about it and from what I've seen and read is pretty sparse on the subject. Only a presumption but probably the complexity of what devices do to optimize their displays has a lot to do with it.

For instance I'm sure you've noticed on an iOS device when viewing a component (list view, web view, etc) that it appears pixelated for a split second and then renders crisp and clear. Zoom in a lot with pinch zoom (web view) and pixelation happens again and then a split second later it's crisp. The reason why is the device takes a "screenshot" of the webpage so when you scroll up and down, all it does is pan an image. That's why it's so smooth. That's also why it takes a second to register a touch on a hyperlink. It needs to see where you are in the image, calculate what's under it and then select it on the (non fake image) website.

Transferring over tech like that isn't very easy and is device specific. Also Flex comes with most of the normal components that devices have anyhow. The lowest level (GPU) is also now accessible with Stage3D. All in all, they're doing pretty well.

Mind you, for example, there's absolutely no reason you need to use Native Alert (visual). You can EASILY re-create your own, better, sexier dialog instead.

The real work here which is 'apparently' possible is getting at libs we can't recreate. Like the lower level access of NSURL*. There is nothing that can replicate it with AIR on Mobile, it simply lacks the functionality (so far). The classes are there (SecureSocket, Socket, etc) that can be pretty low level but we still have no access to them and no workarounds.

Inspiring
May 10, 2012

interesting.  I'm using the native alert just fine...i've also implemented an alert in AS, and it feels like the native alert is faster.

I just found this StackOverflow article on displaying a display in an ANE:

http://stackoverflow.com/questions/8968726/how-to-create-an-ane-that-will-natively-display-a-floating-window/8974888#8974888

May 2, 2012

In my experience (which is pretty limited) an insta-crash could mean:

  • The framework was not properly linked in when the ANE was created (ex. You're using a non-standard .framework and adt doesn't know where to find it.)
  • The iOS Build Packaging preferences (for your AIR project) don't know where the Apple iOS SDK's base directory is. (This can be an easy one to forget.)

I assume you've already ruled both of those out but just in case I thought I'd mention them.

sinious
siniousAuthor
Legend
May 2, 2012

Thanks for the response. A few questions on your insights.. I don't use the command line adt tool to do anything besides package the ANE. Otherwise I'm not sure why my AIR project would need to know where the iOS SDK base directory is. The static library is already produced.

Here's the simple code I'm using (just the NSURL* related stuff):

http://pastebin.com/SFsq578R

I'm producing the Static Lib using XCode 4.3.x. I only need NSURL* functionality which is found in Foundation.h which is included and required for compile in build phases. If I comment out anything to do with NSURL* and simply return a string (FREObject of a const char*) I get that string back to flash and can print it to prove I have the context/initializer/finalizers set up and the function named properly. So the bridge between AIR and ANE work just fine. It's only when I use a NSURL* function that I crash.

Since my troubles I read this extensively long PDF on creating native extensions:

http://help.adobe.com/en_US/air/extensions/air_extensions.pdf

To be brief, it warned that a FREObject only exists until the return of the function you call. What I'm wondering is if it's even possible to use NSURL* functions because they require a delegate and will be running async. So even if I make a request and a connection using that request, after I return from the FRE function the connection is probably being cleaned up.

That aside, I did make the connection and request a synthesized global hoping to get around this. Also to be brief I found an excellent post about debugging an IPA using XCode. Otherwise you're pretty much in a black hole debugging. Here's the post:

http://blogs.adobe.com/rajorshi/2011/11/18/debugging-native-extensions-for-air-ios/

The recipe works although it didn't right out of the box.

XCode is telling me it's a EXC_BAD_ACCESS which typically means the object does not exist that I'm doing something to. My call stack looks like this (loosely, and the name of my static lib is libWebUtil):

0 objc_msgSend

1 CFStringGetLength

2 _CFStringIsLegalURLString

3 -[NSURL(NSURL) initWithString:relativeToURL:]

4 -[NSURL(NSURL) URLWithString:relativeToURL:]

5 -[WebUtil performRequest] // this is my method

6 performRequest

7 avmplus::ExtensionContextObject::_call(avmplus::String*,avmplus::ArrayObject*)

.. etc

From that stack I see it firing off the NSURLRequest and NSURL itself is first taking my string and testing it (CFStringIsLegalURLString) and then it runs CFStringGetLength. I assume it has completed verifying the string and goes to send a message (0 objc_msgSend) and I get a EXC_BAD_ACCESS on that.

I see 9 threads running. This happens on Thread 1 (com.apple.main-thread). The stack traces all look like ASM code to me. Not very useful but at least I can tell the official error.

Mind you that code linked above works perfectly if I make a new empty app, import it and run it. I print out the response data and it's fine.

Right around the incident on the stack there's a avmplus::EventDispatcherObject::NativeDispatchEvent(MMgc::GCAPI::GCRef<avmplus::EventObject>, avmplus::WeakRefList<SObject> const*) + 1076;  .. if that helps at all. It's like the event it dispatches (perhaps from NSURL) to signal that the NSURL I'm making on the fly is correct but there's no object to receive it. That might happen if my method finishes and the object is destroyed before NSURL can even fire off the message.

So I'm very interested in learning about object lifecycle in an ANE.

May 2, 2012

Like you, I also only used ADT from the command line to package the ANE. For everything else I have been using Flash Builder. I don't know, off the top of my head, why Flash Builder requires the base-directory for your iOS SDK. I only know that my app instantly crashed until I realized I had forgotten to specify that base directory. (Your mileage may vary, though.)

I'm not an Objective-C wizzard by any means. I know enough to get by but it's not a strong point. Maybe others will see some chatter on this thread and chime in.

Thanks so much for the link to the Xcode debugging article. I believe that will help me greatly, going forward.