Makie `convert_arguments`

So I am trying to extend Makie plotting to some types of my own. According to the (very terse) online documentation it is sufficient to define a new method for convert_arguments:

using GLMakie
using StaticArrays

struct Foo; end

v = SVector{2, Float64}[[0,0],[1,0],[0,1]]
f = [1 2 3]

# let's define both methods just to be sure
Makie.convert_arguments(::Type{<:Makie.Mesh},::Foo) = (v,f,)
Makie.convert_arguments(::Foo) = (v,f,)

mesh(convert_arguments(Mesh, Foo())...) # works fine
mesh(Foo()) # should this not be equivalent to the above?

throws the following:

ERROR: MethodError: no method matching isfinite(::SVector{2, Float64})
Closest candidates are:
  isfinite(::Integer) at float.jl:454
  isfinite(::Complex) at complex.jl:135
  isfinite(::Missing) at missing.jl:101
  ...
Stacktrace:
  [1] (::StaticArrays.var"#315#316"{typeof(isfinite)})(x::SVector{2, Float64})
    @ StaticArrays ~/.julia/packages/StaticArrays/OWJK7/src/mapreduce.jl:262
  [2] macro expansion
    @ ~/.julia/packages/StaticArrays/OWJK7/src/mapreduce.jl:140 [inlined]
  [3] _mapfoldl
    @ ~/.julia/packages/StaticArrays/OWJK7/src/mapreduce.jl:115 [inlined]
  [4] _mapreduce
    @ ~/.julia/packages/StaticArrays/OWJK7/src/mapreduce.jl:113 [inlined]
  [5] #all#314
    @ ~/.julia/packages/StaticArrays/OWJK7/src/mapreduce.jl:262 [inlined]
  [6] all
    @ ~/.julia/packages/StaticArrays/OWJK7/src/mapreduce.jl:262 [inlined]
  [7] _isfinite(x::Point3{Any})
    @ Makie ~/.julia/packages/Makie/Riyar/src/layouting/data_limits.jl:29
  [8] extrema_nan(itr::Base.Generator{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, Type{Point3{T} where T}, Tuple{Vector{SVector{2, Float64}}, Matrix{Int64}, Int64}}, Makie.var"#606#607"{typeof(identity)}})
    @ Makie ~/.julia/packages/Makie/Riyar/src/layouting/data_limits.jl:44
  [9] xyz_boundingbox(transform_func::Function, xyz::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2}, Nothing, Type{Point3{T} where T}, Tuple{Vector{SVector{2, Float64}}, Matrix{Int64}, Int64}})
    @ Makie ~/.julia/packages/Makie/Riyar/src/layouting/data_limits.jl:65
 [10] xyz_boundingbox
    @ ~/.julia/packages/Makie/Riyar/src/layouting/data_limits.jl:81 [inlined]
 [11] xyz_boundingbox(transform_func::Function, x::Vector{SVector{2, Float64}}, y::Matrix{Int64})
    @ Makie ~/.julia/packages/Makie/Riyar/src/layouting/data_limits.jl:80
 [12] atomic_limits(x::Mesh{Tuple{Vector{SVector{2, Float64}}, Matrix{Int64}}})
    @ Makie ~/.julia/packages/Makie/Riyar/src/layouting/data_limits.jl:25
 [13] data_limits
    @ ~/.julia/packages/Makie/Riyar/src/layouting/data_limits.jl:9 [inlined]
 [14] push!(scene::Scene, plot::Mesh{Tuple{Vector{SVector{2, Float64}}, Matrix{Int64}}})
    @ Makie ~/.julia/packages/Makie/Riyar/src/scenes.jl:354
 [15] plot!(scene::Scene, P::Type{Mesh{Tuple{Foo}}}, attributes::Attributes, input::Tuple{Observable{Foo}}, args::Observable{Tuple{Vector{SVector{2, Float64}}, Matrix{Int64}}})
    @ Makie ~/.julia/packages/Makie/Riyar/src/interfaces.jl:478
 [16] plot!(scene::Scene, P::Type{Mesh{ArgType} where ArgType}, attributes::Attributes, args::Foo; kw_attributes::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:show_axis,), Tuple{Bool}}})
    @ Makie ~/.julia/packages/Makie/Riyar/src/interfaces.jl:387
 [17] plot(P::Type{Mesh{ArgType} where ArgType}, args::Foo; axis::NamedTuple{(), Tuple{}}, figure::NamedTuple{(), Tuple{}}, kw_attributes::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie ~/.julia/packages/Makie/Riyar/src/figureplotting.jl:28
 [18] plot
    @ ~/.julia/packages/Makie/Riyar/src/figureplotting.jl:18 [inlined]
 [19] #mesh#37
    @ ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:31 [inlined]
 [20] mesh(args::Foo)
    @ MakieCore ~/.julia/packages/MakieCore/S8PkO/src/recipes.jl:31
 [21] top-level scope
    @ REPL[20]:1

I read a recent question on the same topic but my case is even simpler and that question did not help.

I read a recent question on the same topic but my case is even simpler and that question did not help.

The solution is the same though, either call convert_arguments on the output or convert to a GeometryBasics.Mesh which is the final output Makie.mesh expects.

The solution is the same though, either call convert_arguments on the output

This is among the things I tried:

Makie.convert_arguments(T::Type{<:Makie.Mesh},::Foo) =
  convert_arguments(T, (v,f,))

This produces the same error as the previous attempt.

or convert to a GeometryBasics.Mesh which is the final output Makie.mesh expects.

Is this (and the similar behaviour for PointBased) documented anywhere?

Maybe it needs to be Makie.convert_arguments in the function?

Is this (and the similar behaviour for PointBased) documented anywhere?

Not that I know of. I think the idea is that you chain another convert_arguments. With that you should be able to use most signatures. If you want to figure out the final type you could check conversions.jl.

Ooooh, I found it! I put an extra Tuple in there; it should have been: convert_arguments(T, v, f)