Alxandr / SpotiFire

A project to make a SpotifyClient in C#
http://nudoc.azurewebsites.net/SpotiFire
40 stars 19 forks source link

PlaylistContainer.complete() called more than once #51

Closed ZARk-be closed 10 years ago

ZARk-be commented 10 years ago

I'm having issues where at some point during playback the playlistcontainer loaded event fires again, resulting in a complete crash.

I mention the crash is during playback, to say that all my playlists have already been loaded and tracks added to a list for queueing.

How to reproduce ? I'm working on that right now. At the moment it's basically 'let it play and it'll crash at some point'. sometimes it'll play 5minutes, sometimes 20minutes. I'll try to give more info if i manage to pin it down.

Exception thrown :

System.InvalidOperationException occurred HResult=-2146233079 Message=An attempt was made to transition a task to a final state when it had already completed. Source=mscorlib StackTrace: at System.Threading.Tasks.TaskCompletionSource`1.SetResult(TResult result) at SpotiFire.PlaylistContainer.complete() in spotifire.libspotify\playlistcontainer.cpp:line 153 InnerException:

ZARk-be commented 10 years ago

Update !

I've just managed to reproduce the issue.

While my app is playing, i have spotify in the background (that is paused). If i create a new playlist, my breakpoint in PlaylistContainer::complete is called !!

To avoid crashes, i've replaced setResult by TrySetResult. This works. It's not clean off course, but now my music can play again :)

Alxandr commented 10 years ago

I figured it would be something like this. What I first want to make sure of is that the callback from libspotify actually happens more than once, and that it's not a matter of wrongly mapped callbacks. If indeed libspotify triggers playlistcontainer_loaded several times, TrySetResult is probably the way to go, though we'd also need to trigger an event so that clients can be informed. On Dec 19, 2013 12:46 PM, "ZARk-be" notifications@github.com wrote:

Update !

I've just managed to reproduce the issue.

While my app is playing, i have spotify in the background (that is paused). If i create a new playlist, my breakpoint in PlaylistContainer::complete is called !!

To avoid crashes, i've replaced setResult by TrySetResult. This works. It's not clean off course, but now my music can play again :)

— Reply to this email directly or view it on GitHubhttps://github.com/Alxandr/SpotiFire/issues/51#issuecomment-30922894 .