Memory leak in Browser when using WebIO + Interact (+ VegaLite)?


My browser tab consumes unlimited amount of memory after I evaluated the following snippet in a Jupyter notebook and dragged the slider back and forth quickly for a dozen of times.

Throttling the slider observable alleviates but does not cure the memory issue. So I guess that some Javascript object sent to the browser is somehow not freed.

Another issue is that I have to refresh the notebook webpage once before the slider works.

Some maybe relevant info:
Julia: v1.1.0
browser: Google Chrome Version 72.0.3626.119 (Official Build) (64-bit)
OS: Archlinux
WebIO: #master
Interact: 0.9.1
IJulia: 1.17.0

Any suggestions appreciated!

using DataFrames
using Interact
using JSExpr
using WebIO
using VegaLite: @vlplot
n = 10_000

f(v) = DataFrame(x=1:n, y=sin.((1:n)./v)) |> @vlplot(:line, x="x", y="y") |> spc->spc.params

w = Scope(;imports=ASSETS)
onimport(w, @js function (vg,vl,ve)
# can this be the culprit? But otherwise I don't know how to access the imported modules. = function (spc)
        ve("#ddd", spc)
obs = Observable(w, "spc", f(1))

s = slider(1:n)
on(s) do v
    obs[] = f(v)

onjs(obs, @js val -> begin

s |> display
w(node(:div, "aaaa"; id="ddd")) |> display

I’m not really familiar with WebIO and Interact, so other than saying that we didn’t take support for that into account in how we designed VegaLite.jl, I don’t have any further insights into that particular combo.

Having said that, maybe another tactic would be to use Vega-Lite interactions directly to achieve a similar outcome? They are documented at Selection Parameters | Vega-Lite. That would only work in either JupyterLab or nteract, not in the classic notebook, though.

For my application client side filtering and transformation is not feasible and needs to be done in Julia on a cluster. Moreover a few weeks ago I tried Jupiter lab but interactivity was lacking due to possible version issues with the vega/vegalite they ship. Using webio is also a bit faster because ijulia render svg and png version of a vegalite specification regardless of whether a richer/better mime type is showable.

That said I really like the mini DSL in VegaLite.jl. I find it much easier to write than vanilla json specifications. Thank you for making it!