JuliaGizmos / Observables.jl

observable refs
Other
105 stars 32 forks source link

async_latest can cause world age problems #17

Closed rafaqz closed 3 years ago

rafaqz commented 6 years ago
ERROR (unhandled task failure): MethodError: no method matching (::##272#273)(::Array{Widgets.Widget{:slider},1})      
The applicable method may be too new: running in world age 24284, while current world is 24288.

I got this by running async_latest in this function where sliders are rebuilt when I swap to a different model, and they are remapped for sending back to the model. I think the key issue is that map!(x, y, async_lates(z)) ocurrs within another map!().

function make_sliders(model)
    params = flatten(Vector, model)
    rnge = metaflatten(Vector, model, range)
    labels = metaflatten(Vector, model, fieldname_meta)

    sliders = broadcast((x,l,v) -> InteractBase.slider(x[1]:(x[2]-x[1])/200:x[2], label=string(l), value=v), rnge, labels, params)
    map!(make_plot, plt, model, async_latest.(observe.(sliders))...)
    sliders
end
map!(make_sliders, sliders, model)

Swapping async_latest to throttle resolves the issue, but thought I should document it here because it took a while to track down the problem.

timholy commented 3 years ago

Fixed by #65