strummachine / sm-audiokit

0 stars 0 forks source link

Offloading CPU from the main thread #8

Closed banjerluke closed 2 years ago

banjerluke commented 2 years ago

I got the occasional EXC_BAD_ACCESS when I was using DispatchQueue.global(qos: .utility).async to interact with AudioManager in the Cordova plugin/bridge. So I changed them all to use DQ.main.async, and no errors.

The question remains: is there a way to offload stuff from the main thread? Should I even worry about it?

When I don't use any DQ.main.async calls at all, I get warnings from Cordova saying the calls are taking 10-20ms to return, which will affect the responsiveness/smoothness of the app. DQ.main.async gets rid of the warnings, but I think it's still taking up time on that same thread, right?

maksutovic commented 2 years ago

Just for posterity sake: We can move loading of samples and non-audio tasks to background thread. Anything dealing with the audio engine, audio players, etc.. should be called from mainThread