GNOME Bugzilla – Bug 783543
Async operation does not complete, resulting in sub-main-context iteration
Last modified: 2017-06-12 18:57:09 UTC
Given this code: https://git.gnome.org/browse/gnome-builder/tree/plugins/vala-pack/ide-vala-index.vala#n151 public async void add_files (ArrayList<GLib.File> files, GLib.Cancellable? cancellable) { Ide.ThreadPool.push (Ide.ThreadPoolKind.COMPILER, () => { lock (this.code_context) { Vala.CodeContext.push (this.code_context); foreach (var file in files) this.add_file (file); Vala.CodeContext.pop (); GLib.Idle.add(add_files.callback); } }); yield; } I'm seeing a poll() loop like this: (gdb) bt
+ Trace 237558
Which means I can't exit builder because it never returns to the main loop to exit when g_application_quit() is called.
Just to make sure. Did this work at some point, so is this a regression of vala?
Ok, this should be working for --target-glib=2.44 Therefore the compat-layer for glib 2.36-2.42 seems to be the culprit. See https://git.gnome.org/browse/vala/commit/?id=a27219c5da0f622e148a3e6927a3ea8cefa337d8
Created attachment 353409 [details] Simple reproducer * Works with 0.34 * Works with 0.36 (without passing target-glib) * Works while passing --target-glib=2.44
Thanks for tracking this down! For now, I just made Builder specify --target-glib=2.52.
Created attachment 353606 [details] [review] codegen: Make the task_complete flag for <2.44 more similar to >=2.44 According to the g_task_get_completed() docs (which we rely on for glib >=2.44 targets): "This changes from FALSE to TRUE after the task's callback is invoked, and will return FALSE from inside the callback". So to make the code paths most similar to >= 2.44 (when g_task_get_completed is available), wrap the GAsyncReadyCallback with one of our own, that just invokes the nested callback (if any) and turns on the flag. Also remove the code turning on the flag on finish(), it's superfluous now and there are no guarantees that it will be invoked.
Created attachment 353607 [details] [review] codegen: Make the task_complete flag for <2.44 more similar to >=2.44 According to the g_task_get_completed() docs (which we rely on for glib >=2.44 targets): "This changes from FALSE to TRUE after the task's callback is invoked, and will return FALSE from inside the callback". So to make the code paths most similar to >= 2.44 (when g_task_get_completed is available), wrap the GAsyncReadyCallback with one of our own, that just invokes the nested callback (if any) and turns on the flag. Also remove the code turning on the flag on finish(), it's superfluous now and there are no guarantees that it will be invoked.
commit be27b9e6d1b7cb590dcda6be6621d707887c87cb Author: Carlos Garnacho <carlosg@gnome.org> Date: Mon Jun 12 17:19:05 2017 +0200 codegen: Make the task_complete flag for < 2.44 more similar to >= 2.44