Here I'm initiating the JS call from swift and based on the results app UI gets updated. Since this method is time taking process it freezes the app for a few seconds and becomes normal. We can understand it's running in the main thread so blocked the UI. I have tried to run it in the background using the below code and it doesn't work.
DispatchQueue.global(qos: .background).async {
let fn = engineJSContext?.objectForKeyedSubscript("jsMethodName")
let val = fn?.call(withArguments: [params1, params2])
}
As per the below document, we can run it from any thread, but I'm facing a problem on the background thread. Any help on this, please! https://developer.apple.com/documentation/javascriptcore/jsvirtualmachine