Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook
Accepted Solution

ANE contexts?

Is an ANE run exclusively in each applications own context (user space) or are only some parts? What I'm wondering is if the ExtensionInitializer is run only once or does it run every time an application uses the ANE. Some functions can only be called once in the BPS library so I was placing the code there and want to make sure each call is made in the applications user space and not a global user space for the extension if this function will be called more than once.

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: ANE contexts?

ANE run in the same sandbox as the parent app. Otherwise, it would be a security nightmare.
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: ANE contexts?

Ok, I was just wondering because I don't know when the Extension initializer and finalizer functions are called. Are they automatically called when the applications loads?
Developer
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course

Re: ANE contexts?

No.

 

The initializer is called when you callExtensionContext.createExtensionContext() from ActionScript. You normally do this in your .SWC.

 

The finalizer will be called whenever your extension goes out of scope (e.g. the reference to it is nulled, or your app is closed).

 

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: ANE contexts?

If that's true, then the ExtensionInitializer function can be called more than once. So how do you guarantee BPS library functions are not called more than once?

I thought the ExtensionInitializer was only called once to intialize data needed by the extension and the ContextInitializer function was called each time a context was intialized.
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: ANE contexts?

You can control all that with your SWC library wrapper around the ANE. You can also add a static boolean in the ANE that gets set if the ANE has already been initialized.
Developer
Developer
Posts: 1,123
Registered: ‎02-10-2009
My Device: 8130 / 8350 / 9530 / 9550 / 9850 / PlayBook

Re: ANE contexts?

[ Edited ]

Well I just made a quick test application to check on this and ExtensionInitializer is only run once, but ContextInitializer is run each time createExtensionContext is called.

 

So it sems the ContextInitializer is only used if you want different functions available for different context/uses of your ANE but global data is shared between all of your contexts, which I can see being useful but can be a pitfall if you're not aware of this.

Developer
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: ANE contexts?

I think this was fixed in AIR 3.4... I remember some reported bugs regarding issues with conflicting initialzier/finalizer calls when including multiple ANE's.