Skip to content
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

Refresh display #178

Open
ghost opened this issue Aug 18, 2019 · 1 comment
Open

Refresh display #178

ghost opened this issue Aug 18, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 18, 2019

How to cause images to be drawn in the midst of computations? (To show the evolving images as computations progress.) Where's a Matlab-style drawnow? The only way I've found to do this is inserting a sleep after imshow (or the sam after a push! into a Signal—not very “reactive” those signals). The sleep of course slows down computations and does not do anything in a Distributed thread (that would run on another CPU core and thus not significantly affect the computations) to have the drawing process in the background. It seems that the only way to force a redraw is to make Julia completely idle.

@ghost
Copy link
Author

ghost commented Aug 19, 2019

After some further hunting through the sources of ImageView/Gtk/GtkReactive, my hunch is that something is preventing notify_realize within Gtk/cairo.jl from being called. It turns out that one only needs to sleep once in the beginning after the widgets and canvases have been created. It is not necessary to sleep after each animation frame, they are redrawn just fine, as long as that initial sleep is performed. My guess is that this somehow allows things to switch over to Gtk… but to a Thread or a Task, I don't know, things seem very weird how Gtk has its own main loop that should not in anyway to my knowledge be compatible with Julia's Tasks, at most Threads. Indeed a simple yield is not sufficient, only a sleep works. But the main difference between those is that sleep will call system pause if there are no Julia internal Tasks to run.

Based on comments in the source of GtkReactive/graphics_interaction.jl, maybe relevant: JuliaGraphics/Gtk.jl#368 and #153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants