Skip to content

Commit ee23672

Browse files
committed
- check if MV is running with the correct JVM (Intel vs Apple Silicon) and issue warning if necessary
- use inheritance for tab placement reset
1 parent 59f2156 commit ee23672

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

src/main/java/mediathek/mac/MediathekGuiMac.kt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package mediathek.mac
22

33
import com.formdev.flatlaf.FlatClientProperties
44
import com.formdev.flatlaf.util.SystemInfo
5+
import mediathek.config.Konstanten
56
import mediathek.gui.actions.ShowAboutAction
67
import mediathek.gui.messages.DownloadFinishedEvent
78
import mediathek.gui.messages.DownloadStartEvent
@@ -13,6 +14,7 @@ import mediathek.tool.MessageBus
1314
import mediathek.tool.notification.INotificationCenter
1415
import mediathek.tool.notification.MacNotificationCenter
1516
import mediathek.tool.threads.IndicatorThread
17+
import mediathek.tool.timer.TimerPool
1618
import net.engio.mbassy.listener.Handler
1719
import org.apache.logging.log4j.LogManager
1820
import org.apache.logging.log4j.Logger
@@ -23,13 +25,50 @@ import java.awt.Taskbar
2325
import java.awt.desktop.QuitEvent
2426
import java.awt.desktop.QuitResponse
2527
import java.io.IOException
28+
import java.util.*
29+
import java.util.concurrent.TimeUnit
30+
import javax.swing.JOptionPane
2631
import javax.swing.JPanel
2732
import javax.swing.JToolBar
33+
import javax.swing.SwingUtilities
2834
import kotlin.io.path.absolutePathString
2935

30-
class MediathekGuiMac : MediathekGui() {
36+
class MediathekGuiMac : MediathekGui {
3137
private val powerManager = OsxPowerManager()
3238

39+
constructor() : super() {
40+
TimerPool.timerPool.schedule({checkForCorrectArchitecture()}, 15, TimeUnit.SECONDS)
41+
}
42+
43+
/**
44+
* Check if MV is running "old" intel application on a new Mac with ARM cpu.
45+
* Issue warning if true as we have a faster alternative.
46+
*/
47+
private fun checkForCorrectArchitecture() {
48+
logger.trace("Checking for correct JVM architecture on macOS...")
49+
val osName = System.getProperty("os.name").lowercase(Locale.getDefault())
50+
val osArch = System.getProperty("os.arch").lowercase(Locale.getDefault()) // native arch
51+
val jvmBinaryArch = System.getProperty("os.arch").lowercase(Locale.getDefault())
52+
53+
val isAppleSilicon = osName.contains("mac") && osArch.contains("aarch64")
54+
val isJVMIntel = jvmBinaryArch == "x86_64" || jvmBinaryArch == "amd64"
55+
56+
if (isAppleSilicon && isJVMIntel) {
57+
logger.warn("⚠️ Running an Intel JVM on Apple Silicon. Consider using a native ARM64 JVM for better performance.")
58+
SwingUtilities.invokeLater {
59+
val msg = "<html>Ihr Mac hat eine moderne Apple Silicon CPU.<br/>" +
60+
"Sie nutzen jedoch eine MediathekView Version für Intel Prozessoren.<br/><br/>" +
61+
"Um die Geschwindigkeit des Programms erheblich zu verbessern laden Sie bitte<br/>" +
62+
"die passende <b>MediathekView für Apple Silicon</b> herunter.</html>"
63+
JOptionPane.showMessageDialog(this,msg, Konstanten.PROGRAMMNAME, JOptionPane.WARNING_MESSAGE)
64+
}
65+
}
66+
}
67+
68+
override fun resetTabPlacement() {
69+
// do not reset tab placement as it is not necessary...
70+
}
71+
3372
override fun addQuitMenuItem() {
3473
//using native handler instead
3574
}

src/main/java/mediathek/mainwindow/MediathekGui.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,7 @@ public void onFailure(@NotNull Throwable t) {
272272
}, Daten.getInstance().getDecoratedPool());
273273
}
274274

275-
if (!SystemUtils.IS_OS_MAC_OSX) {
276-
// we need to re-setup tab-placement if the tabs are not in top position as toolbar is installed after tab creation
277-
MessageBus.getMessageBus().publishAsync(new TabVisualSettingsChangedEvent());
278-
}
275+
resetTabPlacement();
279276

280277
//setup Raven Notification library
281278
Notifications.getInstance().setJFrame(this);
@@ -292,6 +289,11 @@ public static MediathekGui ui() {
292289
return ui;
293290
}
294291

292+
protected void resetTabPlacement() {
293+
// we need to re-setup tab-placement if the tabs are not in top position as toolbar is installed after tab creation
294+
MessageBus.getMessageBus().publishAsync(new TabVisualSettingsChangedEvent());
295+
}
296+
295297
private void performAustrianVlcCheck() {
296298
//perform check only when we are not in download-only mode...
297299
if (!Config.shouldDownloadAndQuit()) {

0 commit comments

Comments
 (0)