Skip to content

Hovering with the mouse over an interactive plot spams GLMakie error in the REPL #1090

@damianodegaspari

Description

@damianodegaspari

I am opening this at the suggestion of this Discourse topic.

I am trying to visualize agents based models through interactive plotting.
I created the following MWE by copy-pasting the code found in this page of the documentation.
What happens is that an error (see output below) keeps getting spammed in the REPL while hovering with the mouse over the GLMakie window, even without clicking. However, the buttons “step model”, “run model”, “reset model” seems to work as expected.
The discourse topic linked above (is quick to read and) has a bit more information on how I got to this point, but I think I selected here all the relevant pieces.

Runnable MWE:

using GLMakie
using Agents
using AgentsExampleZoo

model = AgentsExampleZoo.daisyworld(;
    solar_luminosity = 1.0, solar_change = 0.0, scenario = :change
)

model

daisycolor(a) = a.breed
agent_size = 20
agent_marker = '✿'
agentsplotkwargs = (strokewidth = 1.0,) # add stroke around each agent

heatarray = :temperature
heatkwargs = (colorrange = (-20, 60), colormap = :thermal)
plotkwargs = (;
    agent_color = daisycolor, agent_size, agent_marker,
    agentsplotkwargs = (strokewidth = 1.0,),
    heatarray, heatkwargs
)

fig, ax, abmobs = abmplot(model; add_controls = true, plotkwargs...)
fig

Error message (I tried to isolate one of them, as said in the description it seems to be always the same one, spammed multiple times):

nested task error: BoundsError: attempt to access 30×30 Matrix{Int64} at index [15, 1, 0]
    Stacktrace:
      [1] getindex
        @ ./essentials.jl:14 [inlined]
      [2] id_in_position
        @ ~/.julia/packages/Agents/rX42e/src/spaces/grid_single.jl:77 [inlined]
      [3] ids_to_inspect
        @ ~/.julia/packages/Agents/rX42e/ext/AgentsVisualizations/src/spaces/grid.jl:31 [inlined]
      [4] agent2string(model::StandardABM{GridSpaceSingle{2, true}, AgentsExampleZoo.Daisy, Dict{Int64, AgentsExampleZoo.Daisy}, Tuple{DataType}, typeof(AgentsExampleZoo.daisy_step!), typeof(AgentsExampleZoo.daisyworld_step!), typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, Random.MersenneTwister}, pos::Tuple{Int64, Int64, Int64})
        @ AgentsVisualizations ~/.julia/packages/Agents/rX42e/ext/AgentsVisualizations/src/spaces/abstract.jl:143
      [5] show_data(inspector::DataInspector, p::Plot{AgentsVisualizations._abmplot, Tuple{ABMObservable{Observable{StandardABM{GridSpaceSingle{2, true}, AgentsExampleZoo.Daisy, Dict{Int64, AgentsExampleZoo.Daisy}, Tuple{DataType}, typeof(AgentsExampleZoo.daisy_step!), typeof(AgentsExampleZoo.daisyworld_step!), typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, Random.MersenneTwister}}, Nothing, Nothing, Nothing, Nothing, Bool, Observable{Int64}, Observable{Tuple{Base.RefValue{Int64}, Vector{Int64}}}}}}, idx::UInt32, source::Scatter{Tuple{Vector{Point{2, Float32}}}})
        @ AgentsVisualizations ~/.julia/packages/Agents/rX42e/ext/AgentsVisualizations/src/spaces/abstract.jl:101
      [6] show_data_recursion(inspector::DataInspector, plot::Plot{AgentsVisualizations._abmplot, Tuple{ABMObservable{Observable{StandardABM{GridSpaceSingle{2, true}, AgentsExampleZoo.Daisy, Dict{Int64, AgentsExampleZoo.Daisy}, Tuple{DataType}, typeof(AgentsExampleZoo.daisy_step!), typeof(AgentsExampleZoo.daisyworld_step!), typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, Random.MersenneTwister}}, Nothing, Nothing, Nothing, Nothing, Bool, Observable{Int64}, Observable{Tuple{Base.RefValue{Int64}, Vector{Int64}}}}}}, idx::UInt32, source::Scatter{Tuple{Vector{Point{2, Float32}}}})
        @ Makie ~/.julia/packages/Makie/YkotL/src/interaction/inspector.jl:370
      [7] show_data_recursion(inspector::DataInspector, plot::Scatter{Tuple{Vector{Point{2, Float32}}}}, idx::UInt32)
        @ Makie ~/.julia/packages/Makie/YkotL/src/interaction/inspector.jl:340
      [8] (::Makie.var"#1398#1399"{DataInspector, Scene})()
        @ Makie ~/.julia/packages/Makie/YkotL/src/interaction/inspector.jl:317
      [9] lock(f::Makie.var"#1398#1399"{DataInspector, Scene}, l::ReentrantLock)
        @ Base ./lock.jl:229
     [10] on_hover
        @ ~/.julia/packages/Makie/YkotL/src/interaction/inspector.jl:309 [inlined]
     [11] (::Makie.var"#1390#1394"{DataInspector})(ch::Channel{Nothing})
        @ Makie ~/.julia/packages/Makie/YkotL/src/interaction/inspector.jl:286
     [12] (::Base.var"#651#652"{Makie.var"#1390#1394"{DataInspector}, Channel{Nothing}})()
        @ Base ./channels.jl:142
Error in callback:
TaskFailedException
Stacktrace:
  [1] check_channel_state
    @ ./channels.jl:188 [inlined]
  [2] put!
    @ ./channels.jl:340 [inlined]
  [3] (::Makie.var"#1391#1395"{Channel{Nothing}})(::Tuple{Float64, Float64}, ::Tuple{Float64, Float64})
    @ Makie ~/.julia/packages/Makie/YkotL/src/interaction/inspector.jl:291
  [4] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
    @ Base ./essentials.jl:892
  [5] invokelatest(::Any, ::Any, ::Vararg{Any})
    @ Base ./essentials.jl:889
  [6] (::Observables.OnAny)(value::Any)
    @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:420
  [7] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
  [8] invokelatest
    @ ./essentials.jl:889 [inlined]
  [9] notify
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
 [10] setindex!
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123 [inlined]
 [11] (::GLMakie.MousePositionUpdater)(::Makie.TickState)
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/events.jl:6
 [12] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [13] invokelatest
    @ ./essentials.jl:889 [inlined]
 [14] notify
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
 [15] setindex!
    @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123 [inlined]
 [16] pollevents(screen::GLMakie.Screen{GLFW.Window}, frame_state::Makie.TickState)
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/screen.jl:484
 [17] on_demand_renderloop(screen::GLMakie.Screen{GLFW.Window})
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/screen.jl:982
 [18] renderloop(screen::GLMakie.Screen{GLFW.Window})
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/screen.jl:1010
 [19] (::GLMakie.var"#72#73"{GLMakie.Screen{GLFW.Window}})()
    @ GLMakie ~/.julia/packages/GLMakie/NAHlI/src/screen.jl:870

Information about my system:

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × AMD Ryzen 5 PRO 4650U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver2)
Threads: 12 default, 0 interactive, 6 GC (on 12 virtual cores)
Environment:
  JULIA_EDITOR = code

Information about my environment:

(testing) pkg> status
Status `~/projects/testing/Project.toml`
  [46ada45e] Agents v6.1.8
  [88acaeb2] AgentsExampleZoo v0.1.2
  [e9467ef8] GLMakie v0.10.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplotting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions