GtkProgressBar pulsing broken in Ubuntu 18.04?

I have already asked this question on Stack Overflow and have not received a response, so I figured I would try my luck here instead: I have a GTK application that depends on pulsing a GtkProgressBar to notify the user that the program is running. This action works perfectly on Ubuntu 16.04 (GTK version 3.20.8) but I am noticing that pulsing does not work correctly – and quickly fails altogether – on Ubuntu 18.04 (GTK version 3.22.30). I am thinking that this is a bug in GTK itself, but I can’t seem to find any information anywhere, and if it is indeed a bug, it seems like a big one. I was hoping to get some clarification from the community. The minimal example C code is as follows:

#include <gtk/gtk.h> #include <gdk/gdk.h> #include <glib.h> #include <glib/gprintf.h>  GtkBuilder* builder; gboolean CONTINUE_PULSING = TRUE; guint pulsing;                      // The ID returned by g_timeout_add  gboolean pulse_progress_bar(__attribute__((unused)) gpointer user_data) {   GtkProgressBar * pbar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "pbar"));   gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(pbar), 0.1); // Sets the fraction of total progress bar length to move   gtk_progress_bar_pulse(GTK_PROGRESS_BAR(pbar));    return CONTINUE_PULSING; }  void run_press_event(__attribute__((unused)) GtkWidget * widget, __attribute__((unused)) GdkEventButton * event, __attribute__((unused)) gpointer user_data) {   // Start the progress bar going   GtkProgressBar * pbar = GTK_PROGRESS_BAR(gtk_builder_get_object(builder, "pbar"));    // g_timeout_add will call pulse_progress_bar every 100ms (to keep it moving)   pulsing = g_timeout_add(100, pulse_progress_bar, GTK_PROGRESS_BAR(pbar)); }  void stop_press_event(__attribute__((unused)) GtkWidget * widget, __attribute__((unused)) GdkEventButton * event) {   // Stop the progress bar going   g_source_remove(pulsing); }  void main_window_destroy(__attribute__((unused)) GtkWidget *widget, __attribute__((unused)) gpointer data) {   gtk_main_quit (); }  int main(int argc, char *argv[]) {   GtkWidget * window ;   GError * err = NULL ;    gtk_init(&argc, &argv);    builder = gtk_builder_new();    gtk_builder_add_from_file(builder, "pulse.glade", &err);    if (err != NULL)   {     fprintf(stderr, "Unable to read glade file: %s\n", err -> message);     g_error_free(err);      return 1;   }    window = GTK_WIDGET(gtk_builder_get_object(builder, "window_main"));    gtk_builder_connect_signals(builder, builder);    gtk_widget_show_all(window);    gtk_main();    return 0; } 

And the glade file XML definition to be read into GtkBuilder is:

<?xml version="1.0" encoding="UTF-8"?> <!-- Generated with glade 3.20.0 --> <interface>   <requires lib="gtk+" version="3.20"/>   <object class="GtkWindow" id="window_main">     <property name="can_focus">False</property>     <property name="window_position">center-always</property>     <signal name="destroy" handler="main_window_destroy" swapped="no"/>     <child>       <object class="GtkBox">         <property name="visible">True</property>         <property name="can_focus">False</property>         <property name="orientation">vertical</property>         <child>           <object class="GtkProgressBar" id="pbar">             <property name="visible">True</property>             <property name="can_focus">False</property>             <property name="fraction">0.10000000000000001</property>           </object>           <packing>             <property name="expand">False</property>             <property name="fill">True</property>             <property name="position">0</property>           </packing>         </child>         <child>           <object class="GtkButton" id="run_button">             <property name="label" translatable="yes">RUN</property>             <property name="visible">True</property>             <property name="can_focus">True</property>             <property name="receives_default">True</property>             <signal name="clicked" handler="run_press_event" swapped="no"/>           </object>           <packing>             <property name="expand">False</property>             <property name="fill">True</property>             <property name="position">1</property>           </packing>         </child>         <child>           <object class="GtkButton" id="stop_button">             <property name="label" translatable="yes">STOP</property>             <property name="visible">True</property>             <property name="can_focus">True</property>             <property name="receives_default">True</property>             <signal name="clicked" handler="stop_press_event" swapped="no"/>           </object>           <packing>             <property name="expand">False</property>             <property name="fill">True</property>             <property name="position">2</property>           </packing>         </child>       </object>     </child>   </object> </interface> 

Name the C file “pbar.c” and the glade file “pulse.glade”, then compile using:

gcc -Wall -Wextra -o pbar pbar.c $  (pkg-config gtk+-3.0 --cflags --libs) -rdynamic -lm 

If you are on Ubuntu 16.04 you will notice that the pulse on the progress bar is consistent and does not decay by removing the source ID (i.e. hitting the stop button), but on Ubuntu 18.04 the progress bar starts off fine, but as soon as the source ID is removed, and the pulsing is started again, the pulsing becomes choppy and starts to decay, to the point that several combinations of RUN/STOP cause the progress bar to fail to pulse at all. I cannot determine the cause of this, and it’s a big problem for porting my GTK application over to Ubuntu 18.04. Any help would be appreciated. Thanks!