Skip to main content
Known Participant
November 15, 2013
Question

can a swc library include a native extension?

  • November 15, 2013
  • 1 reply
  • 862 views

I'm working on an AIR application for IOS that uses a SWC that my company created. The AIR application is the shell for browsing books, and the SWC is responsible for downloading the book and displaying it. While a book is downloading, we present a nice loading animation - a sparkly book turning pages. We are disappointed with the performance of the animation - it stutters badly as the files are being unzipped.

We started out using FZip as our library for decompressing our download zip files. It's really nice, as it extracts the files from the zip as it downloads, and never saves the zip file to disk. The problem with FZip is that it's reading the zip FileStream bit by bit, looking for file descriptors so it knows what to decompress. While it's doing this, it gets stuck in a while... loop that doesn't allow anything to animate until it finds the descriptor it's searching for. This is the cause of our stuttering.

I tried another AIR based zip library called Airxzip. This one works beautifully on most files - the animation plays smoothly all the way through the download with only minor stuttering after the file is downloaded to disk and it starts unzipping the files. The problem with this one is that when we try to download zip files over 50MB our app crashes on the iPad Mini - a low memory environment.

I found an ANE called ANEZipFile that I thought might manage memory better as it gets downloaded and decompressed with native IOS code. The problem now is that because my books are downloaded and displayed by a SWC, the SWC won't allow me to include the ANE. I tried creating an instance of a ZipFile object in the main AIR application, and it works okay there. Then I tried to pass a reference to that object into the SWC, and it didn't work. It fails on init, where the ANE tries to create its ExtensionContext.

Does anyone have any suggestions for me? Is there a tricky way for me to use the ANE within the SWC? Are there any other AIR Zip libraries I should try? I found one called Nochump, but it didn't look much different from Airxzip so I figured it would probably crash because of the same memory issues of downloading the large file before unzipping the files.

Any help would be greatly appreciated.

Steve Warren

Senior Software Developer

Speakaboos

This topic has been closed for replies.

1 reply

Participant
December 9, 2013

Hi Steve,

I'm just wondering if you found an answer to this question?  I'm in a similar position in that I'm developing a native extension to handle Bluetooth access which has been progressing fine in my dummy project.  However it needs to be used from an AIR project which has Desktop and Mobile flavours which are simple wrappers making use of a large shared library.  Optimistically I thought I'd be able to reference the native extension from the library but can't see how to do it.

I'm now wondering whether I can just include the ActionScript part of my native extension in the main library, build the SWC and then package the whole lot along with the native implementations in an ANE?  If so is there a performance hit in using the pure ActionScript classes of the original library via a SWC in an ANE compared to via a simple SWC?

Any thoughts greatly apprecaited.

Regards,

David Gould

Software Developer

Transpose Software

Known Participant
December 9, 2013

Hi David,

I wasn’t able to use the ANEZipFile ANE within my SWC, and I now believe that it’s not possible to do so. I used a different zip library Airxzip which came as a SWC, but included the source files along with it. I linked to their source rather than using the SWC, and it worked well for me.

I think what you’re suggesting would work well for you - build a SWC library and package it along with the ANE. I don’t suspect you’d run into any performance issues doing it that way, but of course you’d have to verify that yourself.

Best of luck with your project. I’m curious to hear how it goes for you. If you get stuck, post your progress here in this thread, or if you start a new thread, email me and send me a link to your forum post. I haven’t found too many people to respond to the questions I’ve been posting, so I’d appreciate some live dialog with other developers.

Steve Warren

Senior Software Developer

www.speakaboos.com

Participant
December 13, 2013

Hi Steve,

Thanks for getting back to me.  I know what you mean about lack of responses to Bluetooth LE questions, I've hit the same wall.  There seem to be very few experts around.

I haven't had the chance to experiment with a combined SWC as yet but will let you know the results as/when I get to it.

I did have to implement a quick and dirty workaround for a demo which might be of interest.  We use Starling on this project so I added a backing variable and get/set accessors to our root class that is passed in when Starling starts.  I then listened for the starling.events.Event.ROOT_CREATED event and populated the property from the wrapper project which has the reference to the ANE.  The major downside to this approach was that I couldn't find a way to keep the property strongly typed and had to declare it as an Object so it's not something I want to retain going forward.

Glad to hear you found a workable solution to your own issue.

David