-
Notifications
You must be signed in to change notification settings - Fork 3
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
SEGFAULT
and/or SEGABRT
with GtkCanvas
#87
Comments
My solution for our UI package for now will be to have something akin to: mutable struct CairoMakieCanvas
canvas::GtkCanvas
figure::CairoMakie.Figure
end
function draw(fig::Figure, canvas::CairoMakieCanvas)
canvas.figure = fig
@guarded draw(canvas.canvas) do widget
# ... CairoMakie.cairo_draw and so
end
end
and update the figure and draw |
When the canvas is resized, the Alternatively, could you call |
I'm not sure if I understand the situation correctly. The replacement due to resize would happen in either case right? And also with the the workaround I mentioned in my comment? In the MWE the stacktrace seemed to only be printed in the case without the I played around a bit more with the workaround I posted and so far I wasn't able to crash the GUI again. I'll only be able to a do proper stress test on monday with live image reconstructions and multiple sensor readings in parallel |
Ah okay I see the issue with having to redraw the surface now. What is still unclear to me why we get an issue when we construct the figure locally and don't have an outside reference to it. Maybe that issue is not being reproduced by the MWE correctly. For the reference issue we could try an approach with a package extension on CairoMakie and using ScopedValues. In the extension we could define a new draw method as follows: const figure_cache = ScopedValue(CairoMakie.Figure)()
function Gtk4.draw(fig::CairoMakie.Figure, canvas::GtkCanvas)
@with figure_cache => fig begin
@guarded draw(canvas) do widget
f = figure_cache[]
screen = CairoMakie.Screen(f.scene, config, Gtk4.cairo_surface(canvas))
CairoMakie.resize!(f.scene, Gtk4.width(widget), Gtk4.height(widget))
CairoMakie.cairo_draw(screen, f.scene)
end
end
end And then I think each instance of this function call should have its own figure_cache. I haven't tried it out yet (because Julia is broken on my PC atm), but once I do I can make a PR if I see that helping us with our problem |
For me the stacktraces appear whether or not the Do the crashes occur more when you use multiple threads? |
Yes so with the CairoMakie figures we would get a few assertion errors for Makie where the surface was a C_NULL. If we had a lot of drawing updates either because we had many plots being updated "at the same time" or updates with a quick succession we had our segfaults. Those two cases I can test tomorrow more thoroughly with the In those cases we also always have more than two threads, but I think most updates to the drawing function happen within The issue where I tested my workaround I could reproduce by opening two windows with I think 5 GtkCanvases each. That just SEGFAULT/SEBARBT reliably recently and it happened with just one thread too. All the data and code one would need for that is open-source, so I can give you a reproducer for that, but it's not a small MWE |
Oh and we just added a reference to the figure, not to the surface. Now I'm unsure if that actually fixed it for us or if we just dont encounter our race condition anymore |
Hello,
for I think a few years now, we've had sporadic segmenation faults in our Gtk4.jl GUI. With recent versions we've been able to somewhat reliably produce the error and it looked like the CairoSurfaces of the GtkCanvas were somtimes garbage collected.
Usually we didnt't see any Julia-level errors or assertions about that. Today we tried to change our GtkCanvas printing from Cairo.jl to CairoMakie.jl and there we got some more Julia stacktraces and log messages.
I've been able to produce this MWE:
which prints a stacktrace if the surface access is illegal. So on the hand the "bug" is partially in the user code, because the figure isn't referenced and thus can be garbage collected.
But I'm not sure why that garbage collection triggers the CairoSurface to be also destroyed. I think that part might be an issue in Gtk4.jl. With this MWE I've also not managed to create a segfault, so something "regenerates" the cairo surface?
I saw here that the canvas get be reinitialized when resized, so maybe it happens there
The text was updated successfully, but these errors were encountered: