Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive WGLMakie figure throws errors #3781

Closed
kbarros opened this issue Apr 11, 2024 · 5 comments · Fixed by #3975
Closed

Interactive WGLMakie figure throws errors #3781

kbarros opened this issue Apr 11, 2024 · 5 comments · Fixed by #3975
Labels
bug interaction anything event related WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@kbarros
Copy link
Contributor

kbarros commented Apr 11, 2024

The test case that I currently have requires installing Sunny. When I execute this,

using Sunny, WGLMakie
cryst = Sunny.fcc_crystal()
view_crystal(cryst)

and then interact the the WGLMakie figure, it throws many "key not found" errors. Example stack trace below. I haven't had luck reducing this to a simpler standalone test case. When I starting remove things from the scene, the frequency of the errors decrease, in a seemingly nondeterministic way.

An exception was thrown in JS: Error: Key 25837 not found! undefined
Additional message: Error while processing message {"payload":false,"id":"25837","msg_type":"0"}
Stack trace:
    Error: Key 25837 not found! undefined
        at lookup_global_object (http://localhost:9384/assets/a3ea2b1768bae0eec7c90e59010978af2088e5c5-Bonito.bundled.js:3708:11)
        at Object.process_message (http://localhost:9384/assets/a3ea2b1768bae0eec7c90e59010978af2088e5c5-Bonito.bundled.js:3650:17)
        at http://localhost:9384/assets/439a543fe5196e6a836a7ad81e559b5ad3108dec-Websocket.bundled.js:95:32
        at http://localhost:9384/assets/a3ea2b1768bae0eec7c90e59010978af2088e5c5-Bonito.bundled.js:3638:33
        at new Promise (<anonymous>)
        at Lock.lock (http://localhost:9384/assets/a3ea2b1768bae0eec7c90e59010978af2088e5c5-Bonito.bundled.js:3632:16)
        at http://localhost:9384/assets/439a543fe5196e6a836a7ad81e559b5ad3108dec-Websocket.bundled.js:94:48
        at new Promise (<anonymous>)
        at websocket.onmessage (http://localhost:9384/assets/439a543fe5196e6a836a7ad81e559b5ad3108dec-Websocket.bundled.js:89:17)
┌ Warning: Error in window event callback
│   exception =
│    ArgumentError: collection must be non-empty
│    Stacktrace:
│     [1] first
│       @ ./abstractarray.jl:473 [inlined]
│     [2] (::Makie.var"#1441#1443"{Scene, Base.RefValue{Bool}, Base.RefValue{Union{Nothing, Makie.Mouse.Button}}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Bool}, Base.RefValue{Bool}, Base.RefValue{Union{Nothing, Makie.Mouse.Button}}, Base.RefValue{Bool}, Base.RefValue{Point{2, Float32}}, Base.RefValue{Point{2, Float32}}, Base.RefValue{Makie.Mouse.Action}, Observable{MouseEvent}, Float64, Module})(event::Makie.MouseButtonEvent)
│       @ Makie ~/.julia/dev/Makie/src/makielayout/mousestatemachine.jl:292
│     [3] #invokelatest#2
│       @ ./essentials.jl:892 [inlined]
│     [4] invokelatest
│       @ ./essentials.jl:889 [inlined]
│     [5] notify
│       @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
│     [6] setindex!
│       @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123 [inlined]
│     [7] (::WGLMakie.var"#58#60"{Dict{Any, Any}, Scene, Events})()
│       @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:63
└ @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:109
┌ Warning: Error in window event callback
│   exception =
│    ArgumentError: collection must be non-empty
│    Stacktrace:
│     [1] first
│       @ ./abstractarray.jl:473 [inlined]
│     [2] (::Makie.var"#1441#1443"{Scene, Base.RefValue{Bool}, Base.RefValue{Union{Nothing, Makie.Mouse.Button}}, Base.RefValue{Float64}, Base.RefValue{Float64}, Base.RefValue{Bool}, Base.RefValue{Bool}, Base.RefValue{Union{Nothing, Makie.Mouse.Button}}, Base.RefValue{Bool}, Base.RefValue{Point{2, Float32}}, Base.RefValue{Point{2, Float32}}, Base.RefValue{Makie.Mouse.Action}, Observable{MouseEvent}, Float64, Module})(event::Makie.MouseButtonEvent)
│       @ Makie ~/.julia/dev/Makie/src/makielayout/mousestatemachine.jl:292
│     [3] #invokelatest#2
│       @ ./essentials.jl:892 [inlined]
│     [4] invokelatest
│       @ ./essentials.jl:889 [inlined]
│     [5] notify
│       @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
│     [6] setindex!
│       @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123 [inlined]
│     [7] (::WGLMakie.var"#58#60"{Dict{Any, Any}, Scene, Events})()
│       @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:63
└ @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:109
@kbarros kbarros added the bug label Apr 11, 2024
@t-bltg t-bltg added the interaction anything event related label Apr 18, 2024
@asinghvi17 asinghvi17 added the WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. label Apr 20, 2024
SimonDanisch added a commit that referenced this issue Jun 19, 2024
SimonDanisch added a commit that referenced this issue Jun 19, 2024
* fix #3781

* fix text picking for #3752

* check for !isempty at correct place

* add changelog
@kbarros
Copy link
Contributor Author

kbarros commented Jun 20, 2024

Fantastic progress in #3975 !

I played around with the interactive scene above, and eventually it crashed with this new "timed out" error. I don't have a simple recipe to reproduce, though.

┌ Warning: Error in window event callback
│   exception =
│    Timed out
│    Stacktrace:
│      [1] error(s::String)
│        @ Base ./error.jl:35
│      [2] evaljs_value(session::Bonito.Session{Bonito.SubConnection}, js::Bonito.JSCode; error_on_closed::Bool, timeout::Float64)
│        @ Bonito ~/.julia/packages/Bonito/5OnJB/src/session.jl:284
│      [3] evaljs_value(session::Bonito.Session{Bonito.SubConnection}, js::Bonito.JSCode)
│        @ Bonito ~/.julia/packages/Bonito/5OnJB/src/session.jl:243
│      [4] pick_native(screen::WGLMakie.Screen, rect::GeometryBasics.HyperRectangle{2, Int64})
│        @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/picking.jl:7
│      [5] pick(::Scene, screen::WGLMakie.Screen, xy::Vec{2, Float64})
│        @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/picking.jl:64
│      [6] pick(scene::Scene, xy::Tuple{Float64, Float64})
│        @ Makie ~/.julia/dev/Makie/src/interaction/interactive_api.jl:73
│      [7] pick
│        @ ~/.julia/dev/Makie/src/interaction/interactive_api.jl:68 [inlined]
│      [8] mouseover(::Scene, ::MakieCore.Text{Tuple{Vector{Point{2, Float32}}}}, ::Vararg{AbstractPlot})
│        @ Makie ~/.julia/dev/Makie/src/interaction/interactive_api.jl:12
│      [9] (::Makie.var"#2191#2214"{Menu, Makie.var"#mouse_up#2213", Base.RefValue{Bool}, Base.RefValue{Bool}, Makie.var"#pick_entry#2211"{Base.RefValue{Vector{Float32}}, Scene}, MakieCore.Text{Tuple{Vector{Point{2, Float32}}}}, Poly{Tuple{Vector{GeometryBasics.HyperRectangle{2, Float64}}}}, Makie.var"#update_option_colors!#2205"{Menu, Observable{Vector{ColorTypes.RGBA{Float32}}}, Observable{Vector{String}}}, MakieCore.Text{Tuple{Vector{Point{2, Float32}}}}, Poly{Tuple{GeometryBasics.HyperRectangle{2, Float64}}}, Scene, Observable{Float64}, Scene})(position::Tuple{Float64, Float64}, butt::Makie.MouseButtonEvent)
│        @ Makie ~/.julia/dev/Makie/src/makielayout/blocks/menu.jl:201
│     [10] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
│        @ Base ./essentials.jl:892
│     [11] invokelatest(::Any, ::Any, ::Vararg{Any})
│        @ Base ./essentials.jl:889
│     [12] (::Observables.OnAny)(value::Any)
│        @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:420
│     [13] #invokelatest#2
│        @ ./essentials.jl:892 [inlined]
│     [14] invokelatest
│        @ ./essentials.jl:889 [inlined]
│     [15] notify
│        @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
│     [16] setindex!
│        @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123 [inlined]
│     [17] (::WGLMakie.var"#58#60"{Dict{Any, Any}, Scene, Events})()
│        @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:75
└ @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:112

@kbarros
Copy link
Contributor Author

kbarros commented Jun 20, 2024

Here is another error that eventually appeared after a lot of interaction (but again, I can't easily reproduce...)

┌ Warning: Error in window event callback
│   exception =
│    type Nothing has no field attributes
│    Stacktrace:
│      [1] getproperty(x::Nothing, f::Symbol)
│        @ Base ./Base.jl:37
│      [2] (::Makie.var"#1320#1321"{DataInspector, Scene})()
│        @ Makie ~/.julia/dev/Makie/src/interaction/inspector.jl:307
│      [3] lock(f::Makie.var"#1320#1321"{DataInspector, Scene}, l::ReentrantLock)
│        @ Base ./lock.jl:229
│      [4] on_hover
│        @ ~/.julia/dev/Makie/src/interaction/inspector.jl:301 [inlined]
│      [5] (::Makie.var"#1312#1316"{DataInspector})(::Tuple{Float64, Float64})
│        @ Makie ~/.julia/dev/Makie/src/interaction/inspector.jl:281
│      [6] #invokelatest#2
│        @ ./essentials.jl:892 [inlined]
│      [7] invokelatest
│        @ ./essentials.jl:889 [inlined]
│      [8] notify
│        @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
│      [9] setindex!(observable::Observable, val::Any)
│        @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123
│     [10] (::WGLMakie.var"#58#60"{Dict{Any, Any}, Scene, Events})()
│        @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:57
└ @ WGLMakie ~/.julia/dev/Makie/WGLMakie/src/events.jl:112

@SimonDanisch
Copy link
Member

For the first you should look in the js console if there's an error there.
For the second I have an idea!

@kbarros
Copy link
Contributor Author

kbarros commented Aug 6, 2024

On the latest master versions of WGLMakie and Bonito, I'm no longer observing these crashes. Some nice bug fixes must have landed! I will report back here if I encounter something again.

@SimonDanisch
Copy link
Member

Great! :) Best open a new issue with js console output etc, when something comes up again ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug interaction anything event related WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants