I'm implementing a mic plugin for a game and since the [capture_session startRunning] function is a long call, I'm wrapping it in an async call, but it is still laggy.
Commenting the code solves the lag, so I'm pretty sure this is the chunk that causes it.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[capture_session startRunning];
is_recording = true;
NSMutableDictionary *event = [Utils newEvent:EVENT_NAME];
event[PHASE_KEY] = @"started";
event[IS_ERROR_KEY] = @((bool)false);
[Utils dispatchEvent:lua_listener event:event];
});
Btw, I don't know much the language so I could be doing some very silly things here.
Really appreciate any help!