title: executeJavascript does not call completionHandler when inside a DispatchQueue
body: <p>I've written a function that's supposed to return the HTML string that makes up a WKWebview. However, the completion handler is never called, and the project freezes indefinitely. I've also already adopted the WKScriptMessageHandler protocol so that's not the problem.</p>
  
  <pre class="lang-swift prettyprint-override"><code>public func getHTML() -&gt; String {
      var result = ""
      let group = DispatchGroup()
  
      group.enter()
  
      DispatchQueue.main.async {
          self.webView.evaluateJavaScript("document.documentElement.outerHTML.toString()", completionHandler: {(html: Any?, error: Error?) in
              if (error != nil) {
                  print(error!)
              }
              result = html as! String
              group.leave()
          })
      }
  
      group.wait()
      print("done waiting")
      return result
  }
  </code></pre>
  
  <p>I've found several examples on how to <em>get</em> the html, like <a href="https://stackoverflow.com/questions/34751860/get-html-from-wkwebview-in-swift">here</a>, but I don't want to merely print, I want to be able to return its value. I'm not experienced with DispatchQueues, but I do know for that WKWebView's <em>evaluateJavaScript</em> <a href="https://developer.apple.com/documentation/webkit/wkwebview/1415017-evaluatejavascript" rel="nofollow noreferrer">completion handler always runs on the main thread</a></p>