Makie Observable Bug

I can’t figure out how to squash this. I’ve never had this problem before when using Observables and Makie. What’s the secret. For a surface plot, when I update the x-vector and change its size, and update the Z vector and change it’s size to match. I use X.val= and Z[]= to do the updates, I get a black triangle that converges at 0,0,0 I think. When I use Vectors for X and Y, it converges to a line. When I use Matrices for X and Y it converges to 0,0,0 I think.

I think this is a minimally viable example:

using GLMakie
	z=rand(10,10)
	Z=Observable(z)
	x=1:10
	y=1:10
	X=Observable(x)
	Y=Observable(y)
	f=surface(X,Y,Z)
	x=1:5
	z=z[1:5,:]
	z=z.+1
	X.val=x
	Z[]=z


That big black mass shouldn’t be there.
It should look like this.

julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8 (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 12 × Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 12 default, 0 interactive, 6 GC (on 12 virtual cores)
Environment:


[e9467ef8] GLMakie v0.10.14

Anyone got a work around?

This is a bug with surface. Fix surface update & add test by ffreyer · Pull Request #4529 · MakieOrg/Makie.jl · GitHub fixes it.

You have to dig quite a bit to fix this manually. You have to find the render object for the surface in

screen = current_figure().scene.current_screens[1]
robj = screen.renderlist[idx_of_surface_renderobject][3]

The easiest way to identify the plot type is probably to check robj.vertexarray.program.shader for surface.vert. The you have to change the number of rectangles used to draw the surface

robj.postrenderfunction.main[] = (size(z, 1) - 1) * (size(z, 2) - 1)

and then trigger a redraw. Programmatically you can do that with screen.requires_update = true, normally you do that my adjusting some data or interacting with the figure.

1 Like

Whoa! you are fast! Well done! The easiest thing would be to wait for the update I guess.

More fitting to the title, I have been experiencing bugs with observables triggering multiple times after a single click. For some on() blocks, e.g. rectangle dragging and mouse location, I built in a time check to prevent a series of updates. For some other ones like Buttons, I did not have to do that, but since recently they trigger multiple times, e.g. launch a file picker twice.

What Makie version will this go in? I saw a new minor rev increase, but I still have the problem.