From 17f175d30ab85159b48ccb4e1e4dc6704779cd38 Mon Sep 17 00:00:00 2001 From: Kaan0029 Date: Mon, 14 Jul 2025 20:05:27 +0200 Subject: [PATCH 1/5] Fix ARM64 crash in ThemeManager on macOS - Add try/catch around themeWindowManager.install() to handle RuntimeException - Prevents crash when native libraries are incompatible with ARM64 architecture - Fixes #13536 --- .../src/main/java/org/jabref/gui/theme/ThemeManager.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java index d5300c82362..c5cce62909c 100644 --- a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java +++ b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java @@ -121,8 +121,12 @@ private void applyDarkModeToWindow(Stage stage, boolean darkMode) { return; } - themeWindowManager.setDarkModeForWindowFrame(stage, darkMode); - LOGGER.debug("Applied {} mode to window: {}", darkMode ? "dark" : "light", stage); + try { + themeWindowManager.setDarkModeForWindowFrame(stage, darkMode); + LOGGER.debug("Applied {} mode to window: {}", darkMode ? "dark" : "light", stage); + } catch (RuntimeException e) { + LOGGER.error("Failed to set dark mode for window frame (likely due to native library compatibility issues on ARM64)", e); + } } private void applyDarkModeToAllWindows(boolean darkMode) { From 77c3d976409b6b980a520f8e73fad93e2de2d359 Mon Sep 17 00:00:00 2001 From: Kaan0029 Date: Mon, 14 Jul 2025 20:21:55 +0200 Subject: [PATCH 2/5] fix try catch error --- jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java index c5cce62909c..cee4304bfe4 100644 --- a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java +++ b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java @@ -123,10 +123,10 @@ private void applyDarkModeToWindow(Stage stage, boolean darkMode) { try { themeWindowManager.setDarkModeForWindowFrame(stage, darkMode); - LOGGER.debug("Applied {} mode to window: {}", darkMode ? "dark" : "light", stage); - } catch (RuntimeException e) { + } catch (UnsatisfiedLinkError | RuntimeException e) { LOGGER.error("Failed to set dark mode for window frame (likely due to native library compatibility issues on ARM64)", e); } + LOGGER.debug("Applied {} mode to window: {}", darkMode ? "dark" : "light", stage); } private void applyDarkModeToAllWindows(boolean darkMode) { From be8e789055ccd3b7e1025320882b9f693ee54b86 Mon Sep 17 00:00:00 2001 From: Kaan0029 Date: Mon, 14 Jul 2025 20:29:02 +0200 Subject: [PATCH 3/5] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22db2799aeb..47ada18d3f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -197,6 +197,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where libraries would sometimes be hidden when closing tabs with the Welcome tab open. [#12894](https://github.com/JabRef/jabref/issues/12894) - We fixed an issue with deleting entries in large libraries that caused it to take a long time. [#8976](https://github.com/JabRef/jabref/issues/8976) - We fixed an issue where "Reveal in file explorer" option was disabled for newly saved libraries until reopening the file. [#12722](https://github.com/JabRef/jabref/issues/12722) +- We fixed an issue where JabRef crashed on startup on Apple Silicon Macs due to native library compatibility issues in the theme manager. [#13536](https://github.com/JabRef/jabref/issues/13536) ### Removed From 822c98235725c0d61ccb2f9c84fd6c104f094296 Mon Sep 17 00:00:00 2001 From: Kaan0029 Date: Mon, 14 Jul 2025 20:32:39 +0200 Subject: [PATCH 4/5] adjusted changelog entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47ada18d3f1..7312da4e74b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - When creating a library, if you drag a PDF file containing only a single column, the dialog will now automatically close. [#13262](https://github.com/JabRef/jabref/issues/13262) - We fixed an issue where the tab showing the fulltext search results would appear blank after switching library. [#13241](https://github.com/JabRef/jabref/issues/13241) - Enhanced field selection logic in the Merge Entries dialog when fetching from DOI to prefer valid years and entry types. [#12549](https://github.com/JabRef/jabref/issues/12549) +- We fixed an issue where JabRef crashed on startup on Apple Silicon Macs due to native library compatibility issues in the theme manager. [#13536](https://github.com/JabRef/jabref/issues/13536) ### Removed @@ -197,7 +198,6 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where libraries would sometimes be hidden when closing tabs with the Welcome tab open. [#12894](https://github.com/JabRef/jabref/issues/12894) - We fixed an issue with deleting entries in large libraries that caused it to take a long time. [#8976](https://github.com/JabRef/jabref/issues/8976) - We fixed an issue where "Reveal in file explorer" option was disabled for newly saved libraries until reopening the file. [#12722](https://github.com/JabRef/jabref/issues/12722) -- We fixed an issue where JabRef crashed on startup on Apple Silicon Macs due to native library compatibility issues in the theme manager. [#13536](https://github.com/JabRef/jabref/issues/13536) ### Removed From dfe4aa69a150a438d9f748b2a5b1428e9992fafc Mon Sep 17 00:00:00 2001 From: Kaan0029 Date: Mon, 14 Jul 2025 21:07:15 +0200 Subject: [PATCH 5/5] Added try catch also for instantiations in constructor --- .../org/jabref/gui/theme/ThemeManager.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java index cee4304bfe4..f09d93052be 100644 --- a/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java +++ b/jabgui/src/main/java/org/jabref/gui/theme/ThemeManager.java @@ -73,7 +73,13 @@ public ThemeManager(WorkspacePreferences workspacePreferences, this.workspacePreferences = Objects.requireNonNull(workspacePreferences); this.fileUpdateMonitor = Objects.requireNonNull(fileUpdateMonitor); this.updateRunner = Objects.requireNonNull(updateRunner); - this.themeWindowManager = ThemeWindowManagerFactory.create(); + ThemeWindowManager tempThemeWindowManager = null; + try { + tempThemeWindowManager = ThemeWindowManagerFactory.create(); + } catch (UnsatisfiedLinkError | RuntimeException e) { + LOGGER.error("Failed to create ThemeWindowManager (likely due to native library compatibility issues on ARM64)", e); + } + this.themeWindowManager = tempThemeWindowManager; this.baseStyleSheet = StyleSheet.create(Theme.BASE_CSS).get(); this.theme = workspacePreferences.getTheme(); @@ -121,10 +127,12 @@ private void applyDarkModeToWindow(Stage stage, boolean darkMode) { return; } - try { - themeWindowManager.setDarkModeForWindowFrame(stage, darkMode); - } catch (UnsatisfiedLinkError | RuntimeException e) { - LOGGER.error("Failed to set dark mode for window frame (likely due to native library compatibility issues on ARM64)", e); + if (themeWindowManager != null) { + try { + themeWindowManager.setDarkModeForWindowFrame(stage, darkMode); + } catch (UnsatisfiedLinkError | RuntimeException e) { + LOGGER.error("Failed to set dark mode for window frame (likely due to native library compatibility issues on ARM64)", e); + } } LOGGER.debug("Applied {} mode to window: {}", darkMode ? "dark" : "light", stage); }