[GH-ISSUE #1434] [Crash] System.NullReferenceException at RemoveRoutedEventHandlers when exporting with Gifski #1051

Open
opened 2026-02-26 09:33:24 +03:00 by kerem · 3 comments
Owner

Originally created by @Poppypy on GitHub (Feb 10, 2026).
Original GitHub issue: https://github.com/NickeManarin/ScreenToGif/issues/1434

Originally assigned to: @NickeManarin on GitHub.

Describe the bug
I am experiencing a consistent crash when exporting a GIF using the Gifski encoder. The crash occurs during the export process.

To Reproduce

  1. Record a screen area.
  2. Go to the Editor.
  3. Export using the "Gifski" encoder.
  4. The application crashes with the error below.

Error Log / Stack Trace
Title: Removing event handlers
Version: 2.42.1
Date: 02/10/2026
Message: Object reference not set to an instance of an object.
Type: System.NullReferenceException
Source: ScreenToGif
TargetSite: Void RemoveRoutedEventHandlers(System.Windows.UIElement, System.Windows.RoutedEvent)
StackTrace:
at ScreenToGif.Util.Other.RemoveRoutedEventHandlers(UIElement element, RoutedEvent routedEvent) in R:\Source\ScreenToGif\ScreenToGif\Util\Other.cs:line 350

Environment

  • OS: Windows
  • Version: 2.42.1
  • Encoder: Gifski (External/Internal)

Additional context
It seems to happen multiple times as shown in the repeated logs. I have tried replacing the gifski.dll but the issue persists.

26_02_10.txt

Originally created by @Poppypy on GitHub (Feb 10, 2026). Original GitHub issue: https://github.com/NickeManarin/ScreenToGif/issues/1434 Originally assigned to: @NickeManarin on GitHub. **Describe the bug** I am experiencing a consistent crash when exporting a GIF using the Gifski encoder. The crash occurs during the export process. **To Reproduce** 1. Record a screen area. 2. Go to the Editor. 3. Export using the "Gifski" encoder. 4. The application crashes with the error below. **Error Log / Stack Trace** Title: Removing event handlers Version: 2.42.1 Date: 02/10/2026 Message: Object reference not set to an instance of an object. Type: System.NullReferenceException Source: ScreenToGif TargetSite: Void RemoveRoutedEventHandlers(System.Windows.UIElement, System.Windows.RoutedEvent) StackTrace: at ScreenToGif.Util.Other.RemoveRoutedEventHandlers(UIElement element, RoutedEvent routedEvent) in R:\Source\ScreenToGif\ScreenToGif\Util\Other.cs:line 350 **Environment** - OS: Windows - Version: 2.42.1 - Encoder: Gifski (External/Internal) **Additional context** It seems to happen multiple times as shown in the repeated logs. I have tried replacing the gifski.dll but the issue persists. [26_02_10.txt](https://github.com/user-attachments/files/25197791/26_02_10.txt)
Author
Owner

@pawlos commented on GitHub (Feb 23, 2026):

@Poppypy Tried to repro this today but no luck. I've looked at this part of the code and there's a try-catch so if any exception happening there should not caused the crash. The log might be there as it is being logged but the crash I think does not originate from there. Any extra steps during the process that might be causing this issue?

<!-- gh-comment-id:3945206115 --> @pawlos commented on GitHub (Feb 23, 2026): @Poppypy Tried to repro this today but no luck. I've looked at this part of the code and there's a try-catch so if any exception happening there should not caused the crash. The log might be there as it is being logged but the crash I think does not originate from there. Any extra steps during the process that might be causing this issue?
Author
Owner

@Poppypy commented on GitHub (Feb 24, 2026):

Hi @pawlos , thanks for looking into this.
To help you investigate further, I have uploaded a .zip archive containing a video recording of the crash process and the complete logs. The video demonstrates the exact steps I took before the crash occurred. Please let me know if this helps pinpoint the issue or if you need any further information.

Logs.zip

<!-- gh-comment-id:3952828342 --> @Poppypy commented on GitHub (Feb 24, 2026): Hi @pawlos , thanks for looking into this. To help you investigate further, I have uploaded a .zip archive containing a video recording of the crash process and the complete logs. The video demonstrates the exact steps I took before the crash occurred. Please let me know if this helps pinpoint the issue or if you need any further information. [Logs.zip](https://github.com/user-attachments/files/25523263/Logs.zip)
Author
Owner

@pawlos commented on GitHub (Feb 25, 2026):

@Poppypy thanks for the files. I'll check the logs to see if there's anything interesting. But checking the video I don't see any crash. Is that the correct one?

<!-- gh-comment-id:3962412531 --> @pawlos commented on GitHub (Feb 25, 2026): @Poppypy thanks for the files. I'll check the logs to see if there's anything interesting. But checking the video I don't see any crash. Is that the correct one?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ScreenToGif#1051
No description provided.