Merge lp:~parnold-x/wingpanel-indicator-sound/fix_1596270 into lp:~wingpanel-devs/wingpanel-indicator-sound/trunk

Proposed by Djax
Status: Merged
Merged at revision: 118
Proposed branch: lp:~parnold-x/wingpanel-indicator-sound/fix_1596270
Merge into: lp:~wingpanel-devs/wingpanel-indicator-sound/trunk
Diff against target: 115 lines (+65/-18)
1 file modified
src/Widgets/MprisGui.vala (+65/-18)
To merge this branch: bzr merge lp:~parnold-x/wingpanel-indicator-sound/fix_1596270
Reviewer Review Type Date Requested Status
WingPanel Devs Pending
Review via email: mp+307095@code.launchpad.net

Commit message

prevent freezing due to mpris players

Description of the change

The freeze comes due to the fact that many MPRIS interfaces do not give a proper answer after receiving patches. The Vala DBus library always waits the default timeout before continuing, which is 25 seconds. This means blocking the whole elementary UI for 25 seconds, which is really bad.

Since the response is not from use anyways and really many players fail, this fix should be merged instead of relying on patches in the players. The best solution would be allowing 0 timeout in vala, but this does not seem to be possible.

The branch threads the DBus calls to ensure an always responsive UI.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Widgets/MprisGui.vala'
2--- src/Widgets/MprisGui.vala 2016-07-15 16:49:59 +0000
3+++ src/Widgets/MprisGui.vala 2016-09-28 20:52:38 +0000
4@@ -149,11 +149,23 @@
5 btn.clicked.connect (()=> {
6 Idle.add (()=> {
7 if (client.player.can_go_previous) {
8- try {
9- client.player.previous ();
10- } catch (Error e) {
11- warning ("Could not go to previous track: %s", e.message);
12- }
13+ if(!Thread.supported ()) {
14+ warning ("Threading is not supported. DBus timeout could be blocking UI");
15+ try {
16+ client.player.previous();
17+ } catch (Error e) {
18+ warning ("Going to previous track probably failed (faulty MPRIS interface): %s", e.message);
19+ }
20+ } else {
21+ new Thread <void*> ("wingpanel_indicator_sound_dbus_backward_thread", () => {
22+ try {
23+ client.player.previous();
24+ } catch (Error e) {
25+ warning ("Going to previous track probably failed (faulty MPRIS interface): %s", e.message);
26+ }
27+ return null;
28+ });
29+ }
30 }
31 return false;
32 });
33@@ -165,15 +177,22 @@
34 play_btn = btn;
35 btn.clicked.connect (()=> {
36 Idle.add (()=> {
37- try {
38- if (client != null) {
39- client.player.play_pause ();
40- } else {
41- launched_by_indicator = true;
42- ainfo.launch (null, null);
43+ if(!Thread.supported ()) {
44+ warning ("Threading is not supported. DBus timeout could be blocking UI");
45+ try {
46+ client.player.play_pause();
47+ } catch (Error e) {
48+ warning ("Playing/Pausing probably failed (faulty MPRIS interface): %s", e.message);
49 }
50- } catch (Error e) {
51- warning ("Could not play/pause: %s", e.message);
52+ } else {
53+ new Thread <void*> ("wingpanel_indicator_sound_dbus_backward_thread", () => {
54+ try {
55+ client.player.play_pause();
56+ } catch (Error e) {
57+ warning ("Playing/Pausing probably failed (faulty MPRIS interface): %s", e.message);
58+ }
59+ return null;
60+ });
61 }
62 return false;
63 });
64@@ -185,10 +204,22 @@
65 btn.clicked.connect (()=> {
66 Idle.add (()=> {
67 if (client.player.can_go_next) {
68- try {
69- client.player.next ();
70- } catch (Error e) {
71- warning ("Could not go to next track: %s", e.message);
72+ if(!Thread.supported ()) {
73+ warning ("Threading is not supported. DBus timeout could be blocking UI");
74+ try {
75+ client.player.next();
76+ } catch (Error e) {
77+ warning ("Going to next track probably failed (faulty MPRIS interface): %s", e.message);
78+ }
79+ } else {
80+ new Thread <void*> ("wingpanel_indicator_sound_dbus_forward_thread", () => {
81+ try {
82+ client.player.next();
83+ } catch (Error e) {
84+ warning ("Going to next track probably failed (faulty MPRIS interface): %s", e.message);
85+ }
86+ return null;
87+ });
88 }
89 }
90 return false;
91@@ -273,7 +304,23 @@
92 try {
93 close ();
94 if (client != null && client.player.can_raise) {
95- client.player.raise ();
96+ if(!Thread.supported ()) {
97+ warning ("Threading is not supported. DBus timeout could be blocking UI");
98+ try {
99+ client.player.raise();
100+ } catch (Error e) {
101+ warning ("Raising the player probably failed (faulty MPRIS interface): %s", e.message);
102+ }
103+ } else {
104+ new Thread <void*> ("wingpanel_indicator_sound_dbus_backward_thread", () => {
105+ try {
106+ client.player.raise();
107+ } catch (Error e) {
108+ warning ("Raising the player probably failed (faulty MPRIS interface): %s", e.message);
109+ }
110+ return null;
111+ });
112+ }
113 } else if (ainfo != null) {
114 ainfo.launch (null, null);
115 }

Subscribers

People subscribed via source and target branches

to all changes: