aleab / toastify

:mega: TOASTIFY DEVELOPMENT HAS STOPPED | Toastify adds global hotkeys and toast notifications to Spotify
https://aleab.github.io/toastify
GNU General Public License v2.0
434 stars 48 forks source link

some exceptions and crash if Spotify could not be catched #13

Closed Vankog closed 7 years ago

Vankog commented 7 years ago

hehe, the new version added some exceptions.

First one I did not capture, but it was something like an exception while opening spotify after toastify start. It worked anyway. I'll have an eye on this.

The second one came, after removing progress bar check and saving (loosely translated, because it was given in German):

************** Exception message **************
System.InvalidOperationException: The requested information are not available, because the process was terminated.
   bei System.Diagnostics.Process.EnsureState(State state)
   bei System.Diagnostics.Process.get_MainWindowHandle()
   bei Toastify.Core.Spotify.GetMainWindowHandle()
   bei Toastify.View.ToastView.DisplayAction(SpotifyAction action)
   bei MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
   bei System.Windows.Controls.Primitives.ButtonBase.OnClick()
   bei System.Windows.Controls.Button.OnClick()
   bei System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   bei System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   bei System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   bei System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   bei System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   bei System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   bei System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   bei System.Windows.Input.InputManager.ProcessStagingArea()
   bei System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   bei System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   bei System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   bei System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   bei System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   bei System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   bei MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   bei System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   bei System.Windows.Window.ShowHelper(Object booleanBox)
   bei System.Windows.Window.ShowDialog()
   bei Toastify.View.SettingsView.Launch(ToastView toastView)
   bei System.Windows.Forms.MenuItem.OnClick(EventArgs e)
   bei System.Windows.Forms.MenuItem.MenuItemData.Execute()
   bei System.Windows.Forms.Command.Invoke()
   bei System.Windows.Forms.NotifyIcon.WndProc(Message& msg)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** loaded Assemblys **************
mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2110.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll.
----------------------------------------
Toastify
    Assembly-Version: 1.9.7.30415.
    Win32-Version: 1.9.7.30415.
    CodeBase: file:///C:/Program%20Files/Toastify/Toastify.exe.
----------------------------------------
PresentationFramework
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.dll.
----------------------------------------
WindowsBase
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll.
----------------------------------------
System.Core
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll.
----------------------------------------
System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2110.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
----------------------------------------
PresentationCore
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll.
----------------------------------------
System.Xaml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xaml/v4.0_4.0.0.0__b77a5c561934e089/System.Xaml.dll.
----------------------------------------
System.Xml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
ManagedWinapi
    Assembly-Version: 0.3.0.0.
    Win32-Version: 0.3.
    CodeBase: file:///C:/Program%20Files/Toastify/ManagedWinapi.DLL.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2110.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
Anonymously Hosted DynamicMethods Assembly
    Assembly-Version: 0.0.0.0.
    Win32-Version: 4.7.2110.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/mscorlib/v4.0_4.0.0.0__b77a5c561934e089/mscorlib.dll.
----------------------------------------
mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
----------------------------------------
System.Configuration
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll.
----------------------------------------
Microsoft.GeneratedCode
    Assembly-Version: 1.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
GoogleMeasurementProtocol
    Assembly-Version: 1.4.0.0.
    Win32-Version: 1.4.0.0.
    CodeBase: file:///C:/Program%20Files/Toastify/GoogleMeasurementProtocol.DLL.
----------------------------------------
System.Management
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll.
----------------------------------------
PresentationFramework.Aero2
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.Aero2/v4.0_4.0.0.0__31bf3856ad364e35/PresentationFramework.Aero2.dll.
----------------------------------------
PresentationCore.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationCore.resources/v4.0_4.0.0.0_de_31bf3856ad364e35/PresentationCore.resources.dll.
----------------------------------------
SpotifyAPI
    Assembly-Version: 1.0.0.0.
    Win32-Version: 1.0.0.0.
    CodeBase: file:///C:/Program%20Files/Toastify/SpotifyAPI.DLL.
----------------------------------------
ToastifyAPI
    Assembly-Version: 1.9.7.30415.
    Win32-Version: 1.9.7.30415.
    CodeBase: file:///C:/Program%20Files/Toastify/ToastifyAPI.DLL.
----------------------------------------
Windows.ApplicationModel
    Assembly-Version: 255.255.255.255.
    Win32-Version: 10.0.10011.16384.
    CodeBase: file:///C:/Windows/system32/WinMetadata/Windows.ApplicationModel.winmd.
----------------------------------------
System.Runtime
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll.
----------------------------------------
Windows.Foundation
    Assembly-Version: 255.255.255.255.
    Win32-Version: 10.0.10011.16384.
    CodeBase: file:///C:/Windows/system32/WinMetadata/Windows.Foundation.winmd.
----------------------------------------
Newtonsoft.Json
    Assembly-Version: 10.0.0.0.
    Win32-Version: 10.0.3.21018.
    CodeBase: file:///C:/Program%20Files/Toastify/Newtonsoft.Json.DLL.
----------------------------------------
System.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.resources.dll.
----------------------------------------
System.Numerics
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll.
----------------------------------------
System.Runtime.Serialization
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2112.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll.
----------------------------------------
System.Data
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2102.0 built by: NET47REL1LAST.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll.
----------------------------------------
Xceed.Wpf.Toolkit
    Assembly-Version: 3.1.0.0.
    Win32-Version: 3.1.0.0.
    CodeBase: file:///C:/Program%20Files/Toastify/Xceed.Wpf.Toolkit.DLL.
----------------------------------------
PresentationFramework-SystemXml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemXml/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemXml.dll.
----------------------------------------
PresentationFramework-SystemData
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemData/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemData.dll.
----------------------------------------
PresentationFramework.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework.resources/v4.0_4.0.0.0_de_31bf3856ad364e35/PresentationFramework.resources.dll.
----------------------------------------
UIAutomationTypes
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationTypes/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationTypes.dll.
----------------------------------------
PresentationFramework-SystemCore
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/PresentationFramework-SystemCore/v4.0_4.0.0.0__b77a5c561934e089/PresentationFramework-SystemCore.dll.
----------------------------------------
UIAutomationProvider
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/UIAutomationProvider/v4.0_4.0.0.0__31bf3856ad364e35/UIAutomationProvider.dll.
----------------------------------------
Accessibility
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.7.2046.0 built by: NET47REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------

************** JIT-Debugging **************

It still ran afterwards, but after enabling the progress bar again and saving, Toastify crashed.

On the next start (spotify closed again) no exception occured during startup.

But the saving did not crash neither.

aleab commented 7 years ago

Oh geez! I already saw this behaviour, but never in a Release build. 😞 The second exception and the crash are totally related to the first exception. The base cause, I think, is that somehow Toastify was not able to find the Spotify process (or it did found it, but didn't find its main window, that is used to check if Spotify is running – I might need to change this). It always happens when Toastify starts Spotify though, but yet it doesn't happen everytime – seems kinda random; my guess is that sometimes Spotify takes too long to start and there's some kind of timeout somewhere. 🤔

I have to investigate this.

aleab commented 7 years ago

Also, you say that it still ran after the second exception, but were you able to see the toast with Artist/Track info?

Vankog commented 7 years ago

Yeah, the toast even updated to hide or show the bar. Just showed me the exception on first save and crashed silently on the second save.

But I couldn't reproduce this exception since then. So, might it be a problem in the unofficial API you are contributing to?

Nice label btw ^^

aleab commented 7 years ago

Nah, It's definitely a problem with Toastify – I can feel it. I just didn't manage correctly the process of "launch Spotify > wait for it > show Toastify or show error".

I think the best thing to do is to make Toastify kill itself if such an error occurs and show an informational message asking to restart it, instead of letting it run to eventually crash randomly in the end.

Vankog commented 7 years ago

At least that's a valid workaround.

aleab commented 7 years ago

Should be definitely fixed in the new release, I hope. 🤞

Vankog commented 7 years ago

Hooray! So it was just the missing previous version. Nice catch! Sounds hard to find.

aleab commented 7 years ago

Nay, the missing previous version thing was the cause of another unrelated bug. This issue, instead, has been worked around by moving the startup tasks (launching Spotify and connecting to it) to a background thread that shows an error message and shuts down the app if it is not able to terminate within a time limit. Unfortunately, I couldn't test the changes thoroughly because I was not able to replicate the same exact behaviour, but I think it should be ok.

Vankog commented 7 years ago

only time will tell! :-)