Unable to run JSContext in background thread

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 document , we can run it from any thread, but I'm facing a problem on the background thread . Any help on this please.

I have tried to run it in the background using the below code and it doesn't work.

Can you elaborate on “doesn’t work”? What symptoms do you see?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Facing application UI freeze when this method is running.

Unable to run JSContext in background thread
 
 
Q