Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI API called on a background thread - iOS 11 - Xcode 9 #28

Closed
ziadtamim opened this issue Oct 2, 2017 · 7 comments
Closed

UI API called on a background thread - iOS 11 - Xcode 9 #28

ziadtamim opened this issue Oct 2, 2017 · 7 comments

Comments

@ziadtamim
Copy link
Contributor

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

@phimage
Copy link
Owner

phimage commented Oct 3, 2017

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

@phimage phimage closed this as completed Oct 5, 2017
@phimage
Copy link
Owner

phimage commented Oct 5, 2017

thanks for the PR #29

@stephenfung98
Copy link

  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]

@MainasuK
Copy link

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)
    })
}

@phimage
Copy link
Owner

phimage commented Mar 11, 2019

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

@fitch
Copy link

fitch commented Oct 1, 2019

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:
....

@eduhh94
Copy link

eduhh94 commented Nov 25, 2019

I have the same issue as fitch. Is there any fix yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants