calabash / calabash-ios-server

An embedded HTTP server for performing queries and test automation
Other
87 stars 82 forks source link

LPWKWebViewCalabashStringByEvaulatingJavaScriptIMP deadlock #375

Open lucatorella opened 7 years ago

lucatorella commented 7 years ago

When I push a new view controller containing a WKWebView, if I wait for a element to exist with wait_for_element_exists("WKWebView xpath:'//..., then the app freezes. If I pause the Xcode debugger, I can see it's somehow stuck in LPWKWebViewCalabashStringByEvaulatingJavaScriptIMP:

screen shot 2016-12-07 at 15 21 52

If instead I wait for a second then I do the wait_for_element_exists everything works fine.

My guess is that the completion handler is not called and so the finish property is never set to YES, therefore this while loop will run forever:

while(!finish) {
    [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
  }
jmoody commented 7 years ago

@lucatorella I think the problem is that the WKWebView has not finished loading.

Can you try wait for the page to load?

Here is an example: https://github.com/calabash/ios-webview-test-app/blob/master/CalWebViewApp/features/pages/wkwebview.rb#L24

We are investigating whether or not we can wait for the page to load in the LPServer, but it might not be possible.