Skip to content

Conversation

@p11primera
Copy link

Fixes #1085

Fixed a critical race condition where the nativeTheme event listener was not properly removed when the window closed on macOS. This caused the app to crash when the OS automatically switched between light/dark modes while the app was running in the background without a window.

Changes:

  • Changed onThemeChange from higher-order function to direct function reference to allow proper event listener removal
  • Added null and isDestroyed checks in sendToRenderer to prevent accessing webContents on destroyed windows
  • Added comprehensive unit tests for theme.ts and sendToRenderer.ts (20 tests total)

The bug occurred because:

  1. On macOS, the app stays running when all windows are closed
  2. The nativeTheme listener was never removed due to function reference mismatch
  3. When macOS auto-switched themes, the event fired with null window
  4. Attempting to access window.webContents caused the crash

Fixes Dygmalab#1085

Fixed a critical race condition where the nativeTheme event listener
was not properly removed when the window closed on macOS. This caused
the app to crash when the OS automatically switched between light/dark
modes while the app was running in the background without a window.

Changes:
- Changed onThemeChange from higher-order function to direct function
  reference to allow proper event listener removal
- Added null and isDestroyed checks in sendToRenderer to prevent
  accessing webContents on destroyed windows
- Added comprehensive unit tests for theme.ts and sendToRenderer.ts
  (20 tests total)

The bug occurred because:
1. On macOS, the app stays running when all windows are closed
2. The nativeTheme listener was never removed due to function
   reference mismatch
3. When macOS auto-switched themes, the event fired with null window
4. Attempting to access window.webContents caused the crash

Signed-off-by: Dustin Bone <dustinbone1@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bazecor crashing

1 participant