UI API called on a background thread - iOS 11 - Xcode 9
ziadtamim opened this issue ยท 7 comments
Hi!
Erik unfortunately does not work on iOS 11. With the new Main Thread Checker in XCode 9 it prints out the following in the console:
- Main Thread Checker: UI API called on a background thread: -[WKWebView navigationDelegate]
- Main Thread Checker: UI API called on a background thread: -[WKWebView evaluateJavaScript:completionHandler:]
Best regards,
Ziad
on your instance of Erik, maybe the shared one you can change the queue
if let engine = Erik.sharedInstance.layoutEngine as? WebKitLayoutEngine {
engine.javaScriptQueue = .main
//engine.callBackQueue = .main // maybe this one also if you access some attribute in callback like title
}
I will remove the assert on navigationDelegate
let engine = Erik.sharedInstance.layoutEngine as? WebKitLayoutEngine
engine?.javaScriptQueue = .main
let url = URL(string: "https://www.ups.com/track?loc=en_US&tracknum=1ZA289R6YW99070191&requester=WT/trackdetails")
engine?.browse(url: url!) { object, error in
if let e = error {
} else if let doc = object {
// HTML Inspection
print(doc)
}
}
is still giving me the warning
Main Thread Checker: UI API called on a background thread: -[WKWebView navigationDelegate]
2019-03-11 15:30:33.955446+0800 App[81937:34098633] [reports] Main Thread Checker: UI API called on a background thread: -[WKWebView navigationDelegate]
PID: 81937, TID: 34098633, Thread name: (none), Queue name: ErikLoading, QoS: 0
Backtrace:
4 Erik 0x0000000107f078c6 $S4Erik18WebKitLayoutEngineC16PageLoadedPolicyO17continueConditionySbACcvgSbACcfU1_ + 422
5 Erik 0x0000000107f0c982 $S4Erik18WebKitLayoutEngineC27handleLoadRequestCompletion33_71293D9CF0077E78ADF7737E6959095DLL17completionHandleryys5Error_pSgXE_tF + 178
6 Erik 0x0000000107f0c38d $S4Erik18WebKitLayoutEngineC14currentContent17completionHandleryyypSg_s5Error_pSgtcSg_tFyycfU_ + 173
7 Erik 0x0000000107f10e95 $S4Erik18WebKitLayoutEngineC14currentContent17completionHandleryyypSg_s5Error_pSgtcSg_tFyycfU_TA + 21
8 Erik 0x0000000107f0cb4d $SIeg_IeyB_TR + 45
9 libdispatch.dylib 0x000000010c96a595 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x000000010c96b602 _dispatch_client_callout + 8
11 libdispatch.dylib 0x000000010c972b0b _dispatch_lane_serial_drain + 791
12 libdispatch.dylib 0x000000010c973784 _dispatch_lane_invoke + 428
13 libdispatch.dylib 0x000000010c97d89a _dispatch_workloop_worker_thread + 733
14 libsystem_pthread.dylib 0x000000010cd5b60b _pthread_wqthread + 409
15 libsystem_pthread.dylib 0x000000010cd5b405 start_wqthread + 13
Running Erik on iOS 12.1 emit UI API called on a background thread warning.
Try to set like that but still has same issue.
DispatchQueue.main.async { [weak self] in
(self?.browser.layoutEngine as? WebKitLayoutEngine)?.javaScriptQueue = .main
self?.browser.visit(url: url, completionHandler: { document, error in
consolePrint(document)
consolePrint(error)
})
}
This is an other part of the code that make this
wekbkit love to be acceded using main queue ;)
but I don't to block always the main queue
I think this code is executed to know when the page is loaded
and the queue is not javaScriptQueue but waitLoadingQueue
I seem to be getting this on iOS 13 still with the newest version of Erik:
Main Thread Checker: UI API called on a background thread: -[WKWebView navigationDelegate]
PID: 12577, TID: 584936, Thread name: (none), Queue name: ErikLoading, QoS: 0
Backtrace:
....
I have the same issue as fitch. Is there any fix yet?