Fork me on GitHub
#portal
<
2022-04-03
>
Carlo14:04:06

I found a bug using my navigation functions; I bound in my emacs commands like:

(portal.web/eval-str "(portal.ui.commands/select-root portal.ui.state/state)")
now, I have two commands select-next and select-prev, and they work initially, but if I go very fast between them, at a certain point they will stop working. This is not the only time in which this happens, but is a reproducible behaviour for me. How could I debug this?

Carlo14:04:38

In particular, this definition:

(defn eval-str [code]
  (let [response (c/request {:op :portal.rpc/eval-str :code code})]
    (if-not (:error response)
      (:result response)
      (throw (ex-info (:message response)
                      {:code code :cause (:result response)})))))
I see that if the response is an error, we throw it, but I never saw the error when using a cljs repl

Carlo14:04:44

hmm, I restarted my repl and I'm not able to reproduce the issue anymore (which, on one hand, makes me very happy 😂 )

djblue19:04:57

Interesting, let me know if this happens again. Hopefully not 🤞

Daniel Slutsky23:04:11

Hi. Something strange: trying to submit random plots to Portal, I repeatedly get plots that all look like the first one. Calling this a few times

(-> [:portal.viewer/vega-lite 
     {:encoding
      {:y {:field "y", :type "quantitative"},
       :x {:field "x", :type "quantitative"}},
      :mark {:type "circle", :size 500},
      :data {:values
             (vec
              (for [i (range 9)]
                {:x i :y (rand)}))}}]
    (#(do (println %)
          %))
    (with-meta
      {:portal.viewer/default
       :portal.viewer/hiccup})
    portal.api/submit)
gives me identical plots, while the printed values are different each time.

djblue01:04:03

I'm seeing the same thing. I'll see about fixing it, thanks for the bug report 🙏

djblue02:04:57

So I think this is the result of how cljs does hashing for floats :thinking_face:

djblue02:04:39

;; in cljs
(hash 0.0) ;; => 0
(hash 0.5) ;; => 0
(hash 1.0) ;; => 1
(hash 1.5) ;; => 1

djblue02:04:24

If you submit a value in between both charts, it should work 👌

djblue02:04:38

Not sure how to fix this within portal

djblue02:04:17

For now, something like:

(-> [:<>
     {:key (rand)}
     [:portal.viewer/vega-lite
      {:encoding
       {:y {:field "y", :type "quantitative"},
        :x {:field "x", :type "quantitative"}},
       :mark {:type "circle", :size 500},
       :data {:values
              (vec
               (for [i (range 9)]
                 {:x i :y (rand)}))}}]]
    (with-meta
      {:portal.viewer/default
       :portal.viewer/hiccup})
    portal.api/submit)
should fix it 👌

Daniel Slutsky05:04:41

Fascinating. Good idea to use the key. Thanks!!

hiredman05:04:58

Depending on values that are not equal having hash codes that are not equal sounds like a bug

hiredman05:04:20

Hashes collide

djblue05:04:39

Indeed it is, but the existing solution works well enough for now given implementation constraints. We can log it as an issue, and if enough people run into it, we can look into a long term solution 👌

Daniel Slutsky05:04:00

Thanks. Makes sense. I'll write an issue.

🙏 1