# Makie Observable Bug

**URL:** <https://discourse.julialang.org/t/makie-observable-bug/121724>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 25, 2024, 2:36am UTC](https://discourse.julialang.org/t/makie-observable-bug/121724 "2024-10-25T02:36:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [October 25, 2024, 2:36am UTC](https://discourse.julialang.org/t/makie-observable-bug/121724/1 "2024-10-25T02:36:52Z")

</div>

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:

```julia
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

```

 ![broken](https://global.discourse-cdn.com/julialang/original/3X/b/9/b959eaa60406f17ce85ac8e3c002677d412d354b.png)  
That big black mass shouldn’t be there.  
It should look like this.  
 ![correct](https://global.discourse-cdn.com/julialang/original/3X/0/3/03aa59e558c16f78def5d20f9187887bc5f9bf7c.png)

```julia
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?

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [October 25, 2024, 12:25pm UTC](https://discourse.julialang.org/t/makie-observable-bug/121724/2 "2024-10-25T12:25:22Z")

</div>

This is a bug with `surface`. [Fix surface update & add test by ffreyer · Pull Request #4529 · MakieOrg/Makie.jl · GitHub](https://github.com/MakieOrg/Makie.jl/pull/4529) fixes it.

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

```julia
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

```julia
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.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [October 25, 2024, 2:08pm UTC](https://discourse.julialang.org/t/makie-observable-bug/121724/3 "2024-10-25T14:08:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![oscarvdvelde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscarvdvelde/32/202157_2.png) [@oscarvdvelde](https://discourse.julialang.org/u/oscarvdvelde)\
**Post date:** [October 25, 2024, 5:29pm UTC](https://discourse.julialang.org/t/makie-observable-bug/121724/4 "2024-10-25T17:29:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Allan\_Baker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/allan_baker/32/42645_2.png) [@Allan\_Baker](https://discourse.julialang.org/u/Allan_Baker)\
**Post date:** [October 29, 2024, 9:27pm UTC](https://discourse.julialang.org/t/makie-observable-bug/121724/5 "2024-10-29T21:27:07Z")

</div>

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