     (Platform/runLater (fn [] (.setPrefWidth @webview width)))
     (Platform/runLater (fn [] (.sizeToScene @stage)))
     (Platform/runLater (fn [] (.show @stage)))
+    (wait-for-worker)
     (Platform/runLater
       (fn []
         (let [snap (SnapshotParameters.)]

           (javafx.geometry Rectangle2D)
           (javafx.embed.swing SwingFXUtils)
           (javax.imageio ImageIO)
           (java.io File)))

(defonce latch (CountDownLatch. 1))
(defonce webview (atom nil))

                                    (str (name kwd) ":" val "; "))
                                 (apply hash-map info))))})

(defn get-worker-state []
  (let [res (atom nil)
        ll (CountDownLatch. 1)]
    (Platform/runLater
      (fn []
        (swap! res (fn [x] (.getState (.getLoadWorker @engine))))
        (.countDown ll)))
    (.await ll)
    @res))

(defn wait-for-worker []
  (let [state (get-worker-state)]
    (cond (= Worker$State/SUCCEEDED state) state
          (= Worker$State/FAILED state) state
          (= Worker$State/CANCELLED state) state
          :else (do (println "waiting for worker ... state was" state)
                    (Thread/sleep 10) (recur)))))

(defn render-string [s]
  (if @engine
    (do
      (Platform/runLater (fn [] (.loadContent @engine s "text/html")))
      (wait-for-worker))
    (do
      (launch)
      (.await latch)
