-
Notifications
You must be signed in to change notification settings - Fork 27
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
Makie embedding improvements #171
base: master
Are you sure you want to change the base?
Conversation
This seems to very slightly help load times.
If concerned about deviating from ImGui's style, you could avoid explicitly exposing a delete_figure! method. However, whether using the figure itself as a key or an ID as a key, the originally passed figure would persist - though this allows new figures to be passed in, unlike previous implementations. Alternatively, we could maintain the ImGuiID approach: during each frame, compare whether the incoming figure matches the figure associated with its ID. If they differ, refresh the makie_context while purging the original figure. This ensures that even with repeated new figure submissions, the makie_context's memory footprint won't grow indefinitely. if !haskey(makie_context, id) || f != makie_context[id]
f != makie_context[id] && delete_figure!(makie_context[id])
window = ig.current_window()
makie_window = ImMakieWindow(window)
screen = GLMakie.Screen(; window=makie_window, start_renderloop=false)
makie_context[id] = ImMakieFigure(f, screen)
scene = Makie.get_scene(f)
scene.events.window_open[] = true
display(screen, f)
end |
Hmmm that was my original plan but I decided against it for some reason. But now I can't remember why 🙃 I'll think it over, if it works then yeah let's do that. EDIT: now I remember, to do this garbage collection automatically we still need to figure out if a user wants to display the same figure again. Which we can't know in general since users may create an arbitrary number of figures with arbitrary IDs. |
I think we can simply remove the figure from makie_context without actively purging its contents. If users require garbage collection, they can handle it within their own context stack, without worrying about lingering internal references preventing proper cleanup - since the detachment ensures no internal retention would block resource release |
@FaresX, any opinions on 86ddf0a? I'm a little torn about the internal state thing since it doesn't really match ImGui style. On the other hand I want it to be possible for people who don't dynamically create many plots (which I'm guessing is a majority) to show them with minimal hassle.