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
=== modified file 'src/Widgets/MprisGui.vala'
--- src/Widgets/MprisGui.vala 2016-07-15 16:49:59 +0000
+++ src/Widgets/MprisGui.vala 2016-09-28 20:52:38 +0000
@@ -149,11 +149,23 @@
149 btn.clicked.connect (()=> {149 btn.clicked.connect (()=> {
150 Idle.add (()=> {150 Idle.add (()=> {
151 if (client.player.can_go_previous) {151 if (client.player.can_go_previous) {
152 try {152 if(!Thread.supported ()) {
153 client.player.previous ();153 warning ("Threading is not supported. DBus timeout could be blocking UI");
154 } catch (Error e) {154 try {
155 warning ("Could not go to previous track: %s", e.message);155 client.player.previous();
156 }156 } catch (Error e) {
157 warning ("Going to previous track probably failed (faulty MPRIS interface): %s", e.message);
158 }
159 } else {
160 new Thread <void*> ("wingpanel_indicator_sound_dbus_backward_thread", () => {
161 try {
162 client.player.previous();
163 } catch (Error e) {
164 warning ("Going to previous track probably failed (faulty MPRIS interface): %s", e.message);
165 }
166 return null;
167 });
168 }
157 }169 }
158 return false;170 return false;
159 });171 });
@@ -165,15 +177,22 @@
165 play_btn = btn;177 play_btn = btn;
166 btn.clicked.connect (()=> {178 btn.clicked.connect (()=> {
167 Idle.add (()=> {179 Idle.add (()=> {
168 try {180 if(!Thread.supported ()) {
169 if (client != null) {181 warning ("Threading is not supported. DBus timeout could be blocking UI");
170 client.player.play_pause ();182 try {
171 } else {183 client.player.play_pause();
172 launched_by_indicator = true;184 } catch (Error e) {
173 ainfo.launch (null, null);185 warning ("Playing/Pausing probably failed (faulty MPRIS interface): %s", e.message);
174 }186 }
175 } catch (Error e) {187 } else {
176 warning ("Could not play/pause: %s", e.message);188 new Thread <void*> ("wingpanel_indicator_sound_dbus_backward_thread", () => {
189 try {
190 client.player.play_pause();
191 } catch (Error e) {
192 warning ("Playing/Pausing probably failed (faulty MPRIS interface): %s", e.message);
193 }
194 return null;
195 });
177 }196 }
178 return false;197 return false;
179 });198 });
@@ -185,10 +204,22 @@
185 btn.clicked.connect (()=> {204 btn.clicked.connect (()=> {
186 Idle.add (()=> {205 Idle.add (()=> {
187 if (client.player.can_go_next) {206 if (client.player.can_go_next) {
188 try {207 if(!Thread.supported ()) {
189 client.player.next ();208 warning ("Threading is not supported. DBus timeout could be blocking UI");
190 } catch (Error e) {209 try {
191 warning ("Could not go to next track: %s", e.message);210 client.player.next();
211 } catch (Error e) {
212 warning ("Going to next track probably failed (faulty MPRIS interface): %s", e.message);
213 }
214 } else {
215 new Thread <void*> ("wingpanel_indicator_sound_dbus_forward_thread", () => {
216 try {
217 client.player.next();
218 } catch (Error e) {
219 warning ("Going to next track probably failed (faulty MPRIS interface): %s", e.message);
220 }
221 return null;
222 });
192 }223 }
193 }224 }
194 return false;225 return false;
@@ -273,7 +304,23 @@
273 try {304 try {
274 close ();305 close ();
275 if (client != null && client.player.can_raise) {306 if (client != null && client.player.can_raise) {
276 client.player.raise ();307 if(!Thread.supported ()) {
308 warning ("Threading is not supported. DBus timeout could be blocking UI");
309 try {
310 client.player.raise();
311 } catch (Error e) {
312 warning ("Raising the player probably failed (faulty MPRIS interface): %s", e.message);
313 }
314 } else {
315 new Thread <void*> ("wingpanel_indicator_sound_dbus_backward_thread", () => {
316 try {
317 client.player.raise();
318 } catch (Error e) {
319 warning ("Raising the player probably failed (faulty MPRIS interface): %s", e.message);
320 }
321 return null;
322 });
323 }
277 } else if (ainfo != null) {324 } else if (ainfo != null) {
278 ainfo.launch (null, null);325 ainfo.launch (null, null);
279 }326 }

Subscribers

People subscribed via source and target branches

to all changes: