Helper Apps, SSBs and Sandboxing

My app currently plays a music track and in a background thread it extracts the samples and creates a waveform for display. It saves this data to a cache file so that the next time this file is opened the cached data is used and I don’t need to export the audio data again.

This works fine on my mid 2012 MacBook Pro, but on my old 2008 MacBook the audio can at times stutter when the export thread finishes and saves the cache file. Also the UI updates slowly and not smoothly as the data is being exported. When the cache file is used the old MacBook doesn’t stutter at all, it’s only when exporting the samples and saving out the cache data.

I was thinking about using a Helper App to export the waveform data and create the cache file separately. Then my main app can just check for the cache file at intervals and load it up when it’s available. The theory being that that should stop the stutter on the older Mac when the data is exporting as it only needs to load a cache file (which works fine).

I’ve been trying to find information online about how helper apps work with the MAS sandbox, but there seems to be a lot of contradictory info out there. So I thought I’d see if any of you clever people have tips on what to look out for and avoid.

My initial thoughts on possible issues are these:

  1. My app uses Security Scoped Bookmarks to save access to audio files in a playlist. Will the helper app automatically inherit the access from the parent app or will I need to pass the bookmark across so the helper can access the track?

  2. Currently the cached data is saved into the sandbox folder, so will my helper app have access to the parent app’s sandbox folders? If not, how do I get the helper to save a cache file in an allowed location that both apps can access?

From the info I find online, some say that the helper will have access to the parent’s sandbox (good for me), some say it will be independently sandboxed with no access (bad for me) and others say it depends on how you launch it (fine - but how do I launch in Xojo to ensure it works OK?).

I can dive in and just experiment, but before I waste time I thought I’d see if anyone knows if I’m barking up the wrong tree? I don’t want to spend time on this if it’s only going to be rejected by Apple from the App Store.

Any advise greatly appreciated!

Check my helper app at www.xojo-fr.com
You can find sample code that work with MAS. tell me if You need more.

http://www.xojo-fr.com/helperapp/

Thanks Valdemar, I’ll download and have a play. Out of interest, do you know if the helper app can access the sandbox folders of the parent app if the parent app launches the helper?

Yes she can. You need to have same bundle id. Sign the helper. Integrate it in your app and then sign all the App

AFAIK no, in order to use SSBs (which are evil in nature), you’ll have to use a document SSB (make sure you app is set up for it and then write into a ‘playlist’ file.

This one is not so difficult, in theory all you need do is to pass the helper app a location where you main app can write to and your helper app ‘should’ have access to that folder.

Helper apps need to be Sandboxed, there is a entitlement called “Inherit” which means it has the same privileges as the parent app. However to play it safe, you should treat it as an independent application, for instance making sure that when you launch it, your main app provides it with everything it needs, opposed to expecting the helper app to go and collect what it needs.

You could try talking to Christophe as he’s got a Sandboxed app with a helper app. While I’ve learned what I can, I haven’t yet gotten my app to that point (busy with other things).

You also need to use NSTask to launch a Sandboxed console app, but I suspect that you’ll probably want to do a headless GUI app so that you can display a progress window.

I would advise against this as it messes up application persistence if you use it. The ability to get the OS to save/restore windows during re-launches. App persistence is a very fragile and finicky thing, breaks if you sneeze in the wrong direction.