Resize! error in 1.11

I tried out the old example code from 2018 at this link for some real time plotting.

It errored in 1.11.1 with a resize! error. When I tried it in 1.10.6 it worked fine. I am assuming there should be a new method written for resize?

The error is:

julia> gplot = testanimplot()
ERROR: MethodError: no method matching resize!(::Memory{UInt8}, ::Int64)
The function `resize!` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  resize!(::Gtk.GtkWindow, ::Integer, ::Integer)
   @ Gtk C:\Users\jakez\.julia\packages\Gtk\oo3cW\src\windows.jl:18
  resize!(::BitVector, ::Integer)
   @ Base bitarray.jl:814
  resize!(::Vector, ::Integer)
   @ Base array.jl:1436

Are there more lines in the error message that you did not paste? I miss a reference to the function that calls resize!, since the code of example that you link does not contain it.

In any event, it seems that the problem is in some function belonging to Gtk.jl, which might be using some non-API feature of Julia no longer working in 1.11.

Unfortunately, the Github of Gtk.jl tells that that package is no longer maintained. Perhaps modifying the example (from a very old, 2018 post) to make it work with Gtk4.jl may help.

I thought there might be other places the resize!(::Memory{UInt8}, ::Int64) command is used so that there might need to be a method for this, perhaps I am wrong?

The complete stacktrace is shown.

julia> show(err)
1-element ExceptionStack:
MethodError: no method matching resize!(::Memory{UInt8}, ::Int64)
The function `resize!` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  resize!(::Gtk.GtkWindow, ::Integer, ::Integer)
   @ Gtk C:\Users\jakez\.julia\packages\Gtk\oo3cW\src\windows.jl:18
  resize!(::BitVector, ::Integer)
   @ Base bitarray.jl:814
  resize!(::Vector, ::Integer)
   @ Base array.jl:1436

Stacktrace:
  [1] string_formatted(v::Float64, fmt::NumericIO.IOFormattingReal; showexp::Bool)
    @ NumericIO C:\Users\jakez\.julia\packages\NumericIO\dwKCe\src\NumericIO.jl:395
  [2] formatted(v::Float64, fmt::NumericIO.IOFormattingReal; showexp::Bool)
    @ NumericIO C:\Users\jakez\.julia\packages\NumericIO\dwKCe\src\NumericIO.jl:427
  [3] render_ticklabel(ctx::Cairo.CairoContext, val::Float64, pt::InspectDR.Point2D, font::InspectDR.Font, align::InspectDR.CAlignment, fmt::InspectDR.TickLabelFormatting, ::InspectDR.LinScale{1})
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\cairo_axes.jl:135
  [4] render_yticks(ctx::Cairo.CairoContext, rstrip::InspectDR.RStrip2D, lyt::InspectDR.PlotLayout, ylines::InspectDR.GridLines)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\cairo_axes.jl:206
  [5] render_ticks(ctx::Cairo.CairoContext, rstrip::InspectDR.RStrip2D, lyt::InspectDR.PlotLayout, xticklabels::Bool)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\cairo_axes.jl:272
  [6] render_axes
    @ C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\cairo_axes.jl:283 [inlined]
  [7] render_axes(ctx::Cairo.CairoContext, rplot::InspectDR.RPlot2D, plot::InspectDR.Plot2D)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\cairo_top.jl:27
  [8] render(bplot::InspectDR.CairoBufferedPlot, plot::InspectDR.Plot2D, bb::Graphics.BoundingBox, refreshdata::Bool)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\cairo_top.jl:105
  [9] render(pwidget::InspectDR.PlotWidget; refreshdata::Bool)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_base.jl:302
 [10] render
    @ C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_base.jl:287 [inlined]
 [11] InspectDR.PlotWidget(plot::InspectDR.Plot2D)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_top.jl:239
 [12] InspectDR.PlotWidget(gplot::InspectDR.GtkPlot, plot::InspectDR.Plot2D)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_top.jl:245
 [13] sync_subplots(gplot::InspectDR.GtkPlot)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_top.jl:258
 [14] InspectDR.GtkPlot(mp::InspectDR.Multiplot)
    @ InspectDR C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_top.jl:328
 [15] #GtkPlot#113
    @ C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_top.jl:351 [inlined]
 [16] GtkPlot
    @ C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_top.jl:348 [inlined]
 [17] display
    @ C:\Users\jakez\.julia\packages\InspectDR\hCnVD\src\gtk_top.jl:397 [inlined]
 [18] buildanimplot()
    @ Main .\REPL[9]:24
 [19] testanimplot()
    @ Main .\REPL[11]:8
 [20] top-level scope
    @ REPL[12]:1
julia>

Memory is a new type in Julia 1.11 which is the new fundamental memory allocation type. It doesn’t have a resize! function. It looks like NumericIO.jl is accessing some internal field that used to be a Vector (which supports resize!) but is now a Memory. But that’s just a guess.

2 Likes

The offending function around line 395 is

#One-off solution to formatting individual values:
function string_formatted(v::Real, fmt::IOFormattingReal; showexp::Bool=true)
	s = IOBuffer()
	print_formatted(s, v, fmt, showexp=showexp)
	d = s.data
	resize!(d, s.size)
	return String(d)
end

I have opened an issue for NumericIO.jl.

3 Likes