Expected Behavior
I can change the tray icon as often as i want.
Actual Behavior
After a certain amount of changes the app crashes. Granted in a normal use case i wouldn't expect anyone to reach this point 馃槃
Steps to Reproduce the Problem
Create an app that changes the tray icon every second or so and wait.
Code that Demonstrates the Problem
tray.Image = Icon.FromResource("breaktimer.Assets.tray.tray-" + icon + ".png");
Specifications
- Version: 2.4.1
- Platform(s): WPF
- Operating System(s): Windows 10
Stacktrace
A Generic Error occurred in GDI+
at System.Drawing.Bitmap.GetHicon()
at Eto.Wpf.WpfConversions.ToSDIcon(Image image)
at Eto.Wpf.Forms.TrayIndicatorHandler.set_Image(Image value)
at Eto.Forms.TrayIndicator.set_Image(Image value)
at breaktimer.MainForm.UpdateTrayIcon(Int32 currentTime, Int32 totalTime)
at breaktimer.MainForm.TimerOnTimerUpdate(Object sender, TimerEventArgs e)
at breaktimer.Timer.IntervalTimerElapsed(Object sender, EventArgs e)
at Eto.Forms.UITimer.OnElapsed(EventArgs e)
at Eto.Forms.UITimer.Callback.OnElapsed(UITimer widget, EventArgs e)
at Eto.Wpf.Forms.UITimerHandler.<.ctor>b__0_0(Object sender, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at Eto.Wpf.Forms.ApplicationHandler.Run()
at Eto.Forms.Application.Run(Form mainForm)
at breaktimer.Wpf.MainClass.Main(String[] args) in [...]breaktimer\breaktimer\breaktimer.Wpf\Program.cs:Line 16.
I found a Stackoverflow entry which seems to match this problem: https://stackoverflow.com/questions/12026664/a-generic-error-occurred-in-gdi-when-calling-bitmap-gethicon
I can confirm that the GDI objects increase by every icon change until reaching 10.000.
How i came to produce this error
I am creating a pomodoro timer app. The app lives in the tray icon area. The icon is basically a pie chart which gets filled out as time goes on. I was changing the icon every second. Resulting in the app crashing in less than an hour. Every icon change seems to increase the GDI objects by 3 to 5.
I changed my code to only change the icon if the icon actually needs to change resulting in way less changes.
Expected Behavior
I can change the tray icon as often as i want.
Actual Behavior
After a certain amount of changes the app crashes. Granted in a normal use case i wouldn't expect anyone to reach this point 馃槃
Steps to Reproduce the Problem
Create an app that changes the tray icon every second or so and wait.
Code that Demonstrates the Problem
Specifications
Stacktrace
A Generic Error occurred in GDI+
at System.Drawing.Bitmap.GetHicon()
at Eto.Wpf.WpfConversions.ToSDIcon(Image image)
at Eto.Wpf.Forms.TrayIndicatorHandler.set_Image(Image value)
at Eto.Forms.TrayIndicator.set_Image(Image value)
at breaktimer.MainForm.UpdateTrayIcon(Int32 currentTime, Int32 totalTime)
at breaktimer.MainForm.TimerOnTimerUpdate(Object sender, TimerEventArgs e)
at breaktimer.Timer.IntervalTimerElapsed(Object sender, EventArgs e)
at Eto.Forms.UITimer.OnElapsed(EventArgs e)
at Eto.Forms.UITimer.Callback.OnElapsed(UITimer widget, EventArgs e)
at Eto.Wpf.Forms.UITimerHandler.<.ctor>b__0_0(Object sender, EventArgs e)
at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at Eto.Wpf.Forms.ApplicationHandler.Run()
at Eto.Forms.Application.Run(Form mainForm)
at breaktimer.Wpf.MainClass.Main(String[] args) in [...]breaktimer\breaktimer\breaktimer.Wpf\Program.cs:Line 16.
I found a Stackoverflow entry which seems to match this problem: https://stackoverflow.com/questions/12026664/a-generic-error-occurred-in-gdi-when-calling-bitmap-gethicon
I can confirm that the GDI objects increase by every icon change until reaching 10.000.
How i came to produce this error
I am creating a pomodoro timer app. The app lives in the tray icon area. The icon is basically a pie chart which gets filled out as time goes on. I was changing the icon every second. Resulting in the app crashing in less than an hour. Every icon change seems to increase the GDI objects by 3 to 5.
I changed my code to only change the icon if the icon actually needs to change resulting in way less changes.