Merge lp:~ev/compiz/call-apport-on-hangs into lp:compiz/0.9.8

Proposed by Evan
Status: Work in progress
Proposed branch: lp:~ev/compiz/call-apport-on-hangs
Merge into: lp:compiz/0.9.8
Diff against target: 181 lines (+68/-1)
7 files modified
cmake/base.cmake (+3/-0)
config.h.core.in (+3/-0)
gtk/config.h.gtk.in (+3/-0)
gtk/window-decorator/forcequit.c (+39/-0)
gtk/window-decorator/gtk-window-decorator.h (+2/-0)
plugins/fade/src/fade.cpp (+16/-1)
plugins/fade/src/fade.h (+2/-0)
To merge this branch: bzr merge lp:~ev/compiz/call-apport-on-hangs
Reviewer Review Type Date Requested Status
Sam Spilsbury Needs Information
Daniel van Vugt Needs Resubmitting
Francis Ginther Abstain
jenkins (community) continuous-integration Needs Fixing
Review via email: mp+113436@code.launchpad.net

Description of the change

This branch adds a USE_APPORT flag. If set, when faced with a hanging application, compiz will call apport with the --hanging option (in apport trunk; I'll be releasing shortly), rather than show its own dialog. It will also automatically show the dialog if the fade plugin triggers.

By calling into apport in this way, we can track application hangs as errors on http://errors.ubuntu.com

I'll happily take care of coordinating the upload to Ubuntu, if the branch is accepted and no one else beats me to it. :)

To post a comment you must log in.
lp:~ev/compiz/call-apport-on-hangs updated
3274. By Evan

Report the error if we cannot spawn apport-gtk.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

this looks okay, although the design feels a bit weird to me.

145 +#ifdef USE_APPORT
146 + Time serverTime;
147 +
148 + if (!window->alive () && !forceQuitTriggered) {
149 + serverTime = screen->getCurrentTime ();
150 + screen->toolkitAction (Atoms::toolkitActionForceQuitDialog, serverTime, window->id (), true, 0, 0);
151 + forceQuitTriggered = true;
152 + }
153 +#endif
154 + if (window->alive ())
155 + forceQuitTriggered = false;
156
157 value = fScreen->optionGetUnresponsiveBrightness ();
158 if (value != 100)
159 @@ -361,7 +375,8 @@
160 fadeTime (0),
161 opacityDiff (0),
162 brightnessDiff (0),
163 - saturationDiff (0)
164 + saturationDiff (0),
165 + forceQuitTriggered (false)

Currently it pops up the apport dialog as soon as the application becomes unresponsive. There are quite a few cases where applications can become temporarily unresponsive and it isn't a bug because the system is just under really heavy load and the UI thread of every application is starved. It doesn't make sense to report those.

I noticed that because of this, you need to have checks in both gtk-window-decorator and in the fade plugin to see if the apport dialog has already come up.

What I'd suggest is just showing the dialog when the force quit dialog normally comes up - except it might be better to add a checkbox which says "report this unresponsive application"

Then you can make the code slightly more modular too by delegating the call through a standard interface that all reporters might accept.

This way you only have check if the apport dialog has appeared once, because the user will be closing and reporting the hang at the same time.

Also, some indentation notes:

72 + app = wnck_window_get_application (win);
73 + if (!app)
74 + return FALSE;

You need a one-tab indent for the return FALSE;

76 + pid = wnck_application_get_pid (app);
77 + if (d->apport_dialog) {
78 + /* Is Apport already running? */
79 + if (kill (d->apport_dialog, 0) >= 0 && errno != ESRCH)
80 + return TRUE;
81 + }

pid is indented incorrectly, the brace should fall on the next line, return TRUE needs an indent (4 spaces)

85 + if (error) {
86 + g_printerr ("Could not spawn apport-gtk: %s\n", error->message);
87 + g_error_free (error);
88 + }

brace needs to fall on the next line.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

As above, please fix the formatting. Please also rethink as Sam says:

"Currently it pops up the apport dialog as soon as the application becomes unresponsive. There are quite a few cases where applications can become temporarily unresponsive and it isn't a bug because the system is just under really heavy load and the UI thread of every application is starved. It doesn't make sense to report those."

review: Needs Fixing
Revision history for this message
Evan (ev) wrote :

Matthew Paul Thomas is working on addressing this in the UI. I'll update the merge when we have something concrete.

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) wrote :

The jenkins failure above seems to be be related to us.archive.ubuntu.com connectivity issues :-/

Revision history for this message
Evan (ev) wrote :

On Wed, Jul 4, 2012 at 8:41 PM, Sam Spilsbury
<email address hidden> wrote:
> Also, some indentation notes:
>
> 72 + app = wnck_window_get_application (win);
> 73 + if (!app)
> 74 + return FALSE;
>
> You need a one-tab indent for the return FALSE;
>
> 76 + pid = wnck_application_get_pid (app);
> 77 + if (d->apport_dialog) {
> 78 + /* Is Apport already running? */
> 79 + if (kill (d->apport_dialog, 0) >= 0 && errno != ESRCH)
> 80 + return TRUE;
> 81 + }
>
> pid is indented incorrectly, the brace should fall on the next line, return TRUE needs an indent (4 spaces)

Does compiz mix tabs and spaces? If so, why?

Also, is there a codified coding style to be followed?

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> On Wed, Jul 4, 2012 at 8:41 PM, Sam Spilsbury
> <email address hidden> wrote:
> > Also, some indentation notes:
> >
> > 72 + app = wnck_window_get_application (win);
> > 73 + if (!app)
> > 74 + return FALSE;
> >
> > You need a one-tab indent for the return FALSE;
> >
> > 76 + pid = wnck_application_get_pid (app);
> > 77 + if (d->apport_dialog) {
> > 78 + /* Is Apport already running? */
> > 79 + if (kill (d->apport_dialog, 0) >= 0 && errno != ESRCH)
> > 80 + return TRUE;
> > 81 + }
> >
> > pid is indented incorrectly, the brace should fall on the next line, return
> TRUE needs an indent (4 spaces)
>
> Does compiz mix tabs and spaces? If so, why?

Yes, history (its how X11 does it, davidr was an X11 developer, that coding style got followed in compiz). Yes, its stupid. No we're not changing it (mucks up bzr histories etc, better to just be consistent).

>
> Also, is there a codified coding style to be followed?

I would point you to the compiz wiki, but it seems to be down again :(

Revision history for this message
Evan (ev) wrote :

On Fri, Jul 13, 2012 at 9:59 AM, Sam Spilsbury
<email address hidden> wrote:
>> Does compiz mix tabs and spaces? If so, why?
>
> Yes, history (its how X11 does it, davidr was an X11 developer, that coding style got followed in compiz). Yes, its stupid. No we're not changing it (mucks up bzr histories etc, better to just be consistent).

I'm sure "lets change it!" is the normal response, but I'm all for
staying consistent.
>>
>> Also, is there a codified coding style to be followed?
>
> I would point you to the compiz wiki, but it seems to be down again :(

I've fetched it out of Google's cache. Thanks!

Revision history for this message
Evan (ev) wrote :

Matthew has finished updating the specification to account for temporarily unresponsive applications:

https://wiki.ubuntu.com/ErrorTracker#app-hang

I'll get started on this now, but if there are concerns do let me know.

Revision history for this message
Tim Penhey (thumper) wrote :

Evan, I agree with you on the "change it" for mixed tabs and spaces (my emacs hates it). Personally I think history for that sake is more of a hindrance, and not something that couldn't be worked around when necessary, but hey, it isn't my project.

Revision history for this message
Francis Ginther (fginther) wrote :

Review was claimed by accident, please ignore.

review: Abstain
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

The branches have changed. Please resubmit targeting lp:compiz

Revision history for this message
Daniel van Vugt (vanvugt) :
review: Needs Resubmitting
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Is this still being worked on or can we drop it from the merge queue?

review: Needs Information
Revision history for this message
Evan (ev) wrote :

It's being worked on - slowly :)

Unmerged revisions

3274. By Evan

Report the error if we cannot spawn apport-gtk.

3273. By Evan

Put USE_APPORT in the right place so that forcequit.c picks it up.

3272. By Evan

Make apport dialog optional.

3271. By Evan

Initial commit of calling apport when applications hang under compiz.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmake/base.cmake'
--- cmake/base.cmake 2012-05-24 00:55:17 +0000
+++ cmake/base.cmake 2012-07-04 17:10:24 +0000
@@ -1,3 +1,5 @@
1option (BUILD_APPORT "Use apport instead of the built-in application hang dialog" ON)
2compiz_set (USE_APPORT ${BUILD_APPORT})
1set (USE_GCONF 1 CACHE BOOL "Install core GConf schemas")3set (USE_GCONF 1 CACHE BOOL "Install core GConf schemas")
24
3if (USE_GCONF)5if (USE_GCONF)
@@ -29,6 +31,7 @@
29 compiz_print_result_message ("gconf schemas" USE_GCONF)31 compiz_print_result_message ("gconf schemas" USE_GCONF)
30 compiz_print_result_message ("gnome" USE_GNOME)32 compiz_print_result_message ("gnome" USE_GNOME)
31 compiz_print_result_message ("kde4 window decorator" USE_KDE4)33 compiz_print_result_message ("kde4 window decorator" USE_KDE4)
34 compiz_print_result_message ("apport hang dialog" USE_APPORT)
3235
33 compiz_print_result_message ("protocol buffers" USE_PROTOBUF)36 compiz_print_result_message ("protocol buffers" USE_PROTOBUF)
34 compiz_print_result_message ("file system change notifications" HAVE_INOTIFY)37 compiz_print_result_message ("file system change notifications" HAVE_INOTIFY)
3538
=== modified file 'config.h.core.in'
--- config.h.core.in 2012-05-16 17:40:13 +0000
+++ config.h.core.in 2012-07-04 17:10:24 +0000
@@ -3,3 +3,6 @@
3#define PACKAGE "@_compiz_package@"3#define PACKAGE "@_compiz_package@"
44
5#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"5#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
6
7/* Define to 1 if Apport support is enabled */
8#cmakedefine USE_APPORT 1
69
=== modified file 'gtk/config.h.gtk.in'
--- gtk/config.h.gtk.in 2008-10-14 10:27:55 +0000
+++ gtk/config.h.gtk.in 2012-07-04 17:10:24 +0000
@@ -4,6 +4,9 @@
4/* Define to 1 if Gconf support is enabled */4/* Define to 1 if Gconf support is enabled */
5#cmakedefine USE_GCONF 15#cmakedefine USE_GCONF 1
66
7/* Define to 1 if Apport support is enabled */
8#cmakedefine USE_APPORT 1
9
7/* Define to 1 if you have the `wnck_window_has_name' function. */10/* Define to 1 if you have the `wnck_window_has_name' function. */
8#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 111#cmakedefine HAVE_WNCK_WINDOW_HAS_NAME 1
912
1013
=== modified file 'gtk/window-decorator/forcequit.c'
--- gtk/window-decorator/forcequit.c 2011-02-21 09:53:08 +0000
+++ gtk/window-decorator/forcequit.c 2012-07-04 17:10:24 +0000
@@ -23,6 +23,9 @@
23 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>23 * Authored By: Sam Spilsbury <sam.spilsbury@canonical.com>
24 */24 */
2525
26#ifdef HAVE_CONFIG_H
27#include <config.h>
28#endif
26#include "gtk-window-decorator.h"29#include "gtk-window-decorator.h"
2730
28static char *31static char *
@@ -127,6 +130,37 @@
127 }130 }
128}131}
129132
133gboolean
134show_apport_dialog (WnckWindow *win)
135{
136 WnckApplication *app;
137 GError *error = NULL;
138 gulong flags = G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL;
139 decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
140 int pid;
141 char pid_s[16];
142 gchar *argv[] = { "/usr/share/apport/apport-gtk", "--hanging", NULL, NULL };
143
144 app = wnck_window_get_application (win);
145 if (!app)
146 return FALSE;
147
148 pid = wnck_application_get_pid (app);
149 if (d->apport_dialog) {
150 /* Is Apport already running? */
151 if (kill (d->apport_dialog, 0) >= 0 && errno != ESRCH)
152 return TRUE;
153 }
154 sprintf (pid_s, "%d", pid);
155 argv[2] = pid_s;
156 g_spawn_async (NULL, argv, NULL, flags, NULL, NULL, &(d->apport_dialog), &error);
157 if (error) {
158 g_printerr ("Could not spawn apport-gtk: %s\n", error->message);
159 g_error_free (error);
160 }
161 return TRUE;
162}
163
130void164void
131show_force_quit_dialog (WnckWindow *win,165show_force_quit_dialog (WnckWindow *win,
132 Time timestamp)166 Time timestamp)
@@ -135,6 +169,11 @@
135 GtkWidget *dialog;169 GtkWidget *dialog;
136 gchar *str, *tmp;170 gchar *str, *tmp;
137171
172#ifdef USE_APPORT
173 if (show_apport_dialog(win))
174 return;
175#endif
176
138 if (d->force_quit_dialog)177 if (d->force_quit_dialog)
139 return;178 return;
140179
141180
=== modified file 'gtk/window-decorator/gtk-window-decorator.h'
--- gtk/window-decorator/gtk-window-decorator.h 2012-05-27 04:32:55 +0000
+++ gtk/window-decorator/gtk-window-decorator.h 2012-07-04 17:10:24 +0000
@@ -100,6 +100,7 @@
100#include <unistd.h>100#include <unistd.h>
101#include <sys/types.h>101#include <sys/types.h>
102#include <signal.h>102#include <signal.h>
103#include <errno.h>
103104
104#include <libintl.h>105#include <libintl.h>
105#define _(x) gettext (x)106#define _(x) gettext (x)
@@ -464,6 +465,7 @@
464 WnckWindowActions actions;465 WnckWindowActions actions;
465 XID prop_xid;466 XID prop_xid;
466 GtkWidget *force_quit_dialog;467 GtkWidget *force_quit_dialog;
468 int apport_dialog;
467 Bool created;469 Bool created;
468 void (*draw) (struct _decor *d);470 void (*draw) (struct _decor *d);
469} decor_t;471} decor_t;
470472
=== modified file 'plugins/fade/src/fade.cpp'
--- plugins/fade/src/fade.cpp 2011-06-27 13:32:58 +0000
+++ plugins/fade/src/fade.cpp 2012-07-04 17:10:24 +0000
@@ -23,6 +23,9 @@
23 * Author: David Reveman <davidr@novell.com>23 * Author: David Reveman <davidr@novell.com>
24 */24 */
2525
26#ifdef HAVE_CONFIG_H
27# include <config.h>
28#endif
26#include "fade.h"29#include "fade.h"
27#include <core/atoms.h>30#include <core/atoms.h>
2831
@@ -195,6 +198,17 @@
195 fScreen->optionGetDimUnresponsive ())198 fScreen->optionGetDimUnresponsive ())
196 {199 {
197 GLuint value;200 GLuint value;
201#ifdef USE_APPORT
202 Time serverTime;
203
204 if (!window->alive () && !forceQuitTriggered) {
205 serverTime = screen->getCurrentTime ();
206 screen->toolkitAction (Atoms::toolkitActionForceQuitDialog, serverTime, window->id (), true, 0, 0);
207 forceQuitTriggered = true;
208 }
209#endif
210 if (window->alive ())
211 forceQuitTriggered = false;
198212
199 value = fScreen->optionGetUnresponsiveBrightness ();213 value = fScreen->optionGetUnresponsiveBrightness ();
200 if (value != 100)214 if (value != 100)
@@ -361,7 +375,8 @@
361 fadeTime (0),375 fadeTime (0),
362 opacityDiff (0),376 opacityDiff (0),
363 brightnessDiff (0),377 brightnessDiff (0),
364 saturationDiff (0)378 saturationDiff (0),
379 forceQuitTriggered (false)
365{380{
366 if (window->isViewable ())381 if (window->isViewable ())
367 addDisplayModal ();382 addDisplayModal ();
368383
=== modified file 'plugins/fade/src/fade.h'
--- plugins/fade/src/fade.h 2012-01-18 16:26:45 +0000
+++ plugins/fade/src/fade.h 2012-07-04 17:10:24 +0000
@@ -94,6 +94,8 @@
94 int opacityDiff;94 int opacityDiff;
95 int brightnessDiff;95 int brightnessDiff;
96 int saturationDiff;96 int saturationDiff;
97
98 bool forceQuitTriggered;
97};99};
98100
99class FadePluginVTable :101class FadePluginVTable :

Subscribers

People subscribed via source and target branches