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
ASSETS = [
"vega-lib"=>"https://cdn.jsdelivr.net/npm/vega@4.4.0/build/vega.min.js",
"vega-lite"=>"https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc12/build/vega-lite.min.js",
"https://cdn.jsdelivr.net/npm/vega-embed@3.29.1/build/vega-embed.min.js",
];
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.
self.ve = function (spc)
ve("#ddd", spc)
end
end)
obs = Observable(w, "spc", f(1))
s = slider(1:n)
on(s) do v
obs[] = f(v)
end
onjs(obs, @js val -> begin
self.ve(val)
end)
s |> display
w(node(:div, "aaaa"; id="ddd")) |> display