lastfm / lastfm-windows-desktop

Last.fm Desktop app for Windows (3.0)
GNU General Public License v3.0
10 stars 1 forks source link

When quitting iTunes, it immediately re-opens (!) #24

Closed ben-xo closed 6 years ago

ben-xo commented 6 years ago

Expected:

I noticed in the Visual Studio debugger that it has thrown an exception: System.Runtime.InteropServices.COMException "the message filter indicated that the application is busy". Perhaps this is the exception to watch for to stop listening to iTunes…

ben-xo commented 6 years ago

iTunes Plugin successfully connected to iTunes COM library. iTunes Plugin checking media state... iTunes Plugin checking media state complete. Windows Media Player Plugin checking media state... Windows Media Plugin checking media state complete. iTunes Plugin successfully connected to iTunes COM library. iTunes Plugin checking media state... Exception thrown: 'System.Runtime.InteropServices.COMException' in DesktopScrobbler.exe Windows Media Player Plugin checking media state... Windows Media Plugin checking media state complete. Exception thrown: 'System.Runtime.InteropServices.COMException' in DesktopScrobbler.exe Exception thrown: 'System.Runtime.InteropServices.COMException' in mscorlib.dll An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))

'DesktopScrobbler.exe' (CLR v4.0.30319: DesktopScrobbler.exe): Loaded 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.dll'. The thread 0x2188 has exited with code 0 (0x0). The thread 0xf60 has exited with code 0 (0x0).

The thread 0x2544 has exited with code 0 (0x0). The thread 0x22c4 has exited with code 0 (0x0). Unhandled Exception: Windows Media Player Plugin checking media state... System.Runtime.InteropServices.COMException: The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER)) at iTunesLib.IiTunes.get_PlayerState() at ITunesScrobblePlugin.iTunesScrobblePlugin.<b__24_0>d.MoveNext() in C:\Users\datateam\Documents\GitHub\lastfm-windows-desktop\DesktopScrobbler\DesktopScrobbler\Embedded Plugins\iTunesScrobbleSource.cs:line 173 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_1(Object state) at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() The program '[5552] DesktopScrobbler.exe' has exited with code 0 (0x0).

VorTechS commented 6 years ago

Can't repro that 'starts again' issue. I can still replicate the 'scripting interface' thing, although it seems a bit better than before. BUT, I can't track what state the player is in, without connecting to the COM library. The exception shown relates to WMP, and trying to site it inside a Windows Form. (I've not dug into it any more than that, because it's working and the exception seems to affect nothing)

ben-xo commented 6 years ago

It still does this. Every time I shut down iTunes, i (first) get the scripting interface notification, and then after quitting, it immediately reopens. It's as if just asking iTunes for track information is enough to reopen it.

Seems to happen if you play a song and then quit, but not if you don't play a song.

ben-xo commented 6 years ago

cc @lauranolte

Latest commit (with the GC) seems to have helped, but it's not the whole story. (Now I can sometimes close iTunes on the first go, sometimes it takes 2 or 3 goes… but it does stay closed eventually.)

Perhaps, if paused, we need to reduce the poll rate (7 seconds?)

lauranolte commented 6 years ago

I'm still seeing this pretty much every time, also when I haven't played anything.

VorTechS commented 6 years ago

I've updated the poll rate and reduced it to 5 seconds. It's still entirely possible to repeat the same behaviour if the poll timer is about to fire and you close the window. And on my slow laptop, this happens more often now! Hopefully faster machines won't suffer from the problem as much.