From 840ef8935d5f94060e140577de3fb4bdb5af4e9b Mon Sep 17 00:00:00 2001 From: Anirudh Sevugan Date: Tue, 17 Jun 2025 17:06:21 -0500 Subject: [PATCH] Beta release - Prefer OpenGL on macOS and more --- simpliplay/main.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/simpliplay/main.js b/simpliplay/main.js index c763361..26e2b60 100644 --- a/simpliplay/main.js +++ b/simpliplay/main.js @@ -3,10 +3,14 @@ const path = require('path'); const fs = require('fs'); const os = require('os'); const { pathToFileURL } = require("url"); -var didRegisterShortcuts = false; +let didRegisterShortcuts = false; + +app.commandLine.appendSwitch('disable-features', 'Metal'); +app.commandLine.appendSwitch('use-gl', 'desktop'); let mainWindow; + // Handle file opening from Finder or File Explorer app.on('open-file', (event, filePath) => { event.preventDefault(); @@ -15,25 +19,25 @@ app.on('open-file', (event, filePath) => { const openFile = (filePath) => { app.whenReady().then(() => { + const fileURL = pathToFileURL(filePath).href; + if (mainWindow) { - const fileURL = pathToFileURL(filePath).href; // ✅ Convert and encode file path if (mainWindow.webContents.isLoading()) { mainWindow.webContents.once("did-finish-load", () => { mainWindow.webContents.send("play-media", fileURL); }); } else { - const fileURL = pathToFileURL(filePath).href; // ✅ Convert and encode file path mainWindow.webContents.send("play-media", fileURL); } } else { createWindow(() => { - const fileURL = pathToFileURL(filePath).href; // ✅ Convert and encode file path mainWindow.webContents.send("play-media", fileURL); }); } }); }; + const takeSnapshot = async () => { if (!mainWindow) return; @@ -81,6 +85,16 @@ const createWindow = (onReadyCallback) => { mainWindow.loadFile("index.html"); + mainWindow.webContents.on('did-finish-load', () => { + mainWindow.webContents.executeJavaScript("navigator.userAgent").then(ua => { + console.log("User Agent:", ua); + }); + + mainWindow.webContents.executeJavaScript("chrome.loadTimes ? chrome.loadTimes() : {}").then(loadTimes => { + console.log("GPU Info (legacy):", loadTimes); + }); +}); + mainWindow.once("ready-to-show", () => { if (onReadyCallback) onReadyCallback(); }); @@ -103,6 +117,7 @@ const setupContextMenu = () => { }); }; + // Set up application menu const setupMenu = () => { const menu = Menu.getApplicationMenu(); @@ -206,7 +221,7 @@ app.whenReady().then(() => { openFileSafely(filePath); }); - if (process.platform === "win32") { + if (["win32", "linux"].includes(process.platform)) { if (!app.requestSingleInstanceLock()) { app.quit(); } else { @@ -225,9 +240,8 @@ function openFileSafely(filePath) { hasOpenedFile = true; if (mainWindow?.webContents) { - mainWindow.webContents.once("did-finish-load", () => { - mainWindow.webContents.send("play-media", filePath); - }); + const winFileURL = pathToFileURL(filePath).href; // ✅ Convert and encode file path + mainWindow.webContents.send("play-media", winFileURL); } setTimeout(() => (hasOpenedFile = false), 1000); @@ -238,10 +252,6 @@ function isValidFileArg(arg) { return arg && !arg.startsWith('-') && !arg.includes('electron') && fs.existsSync(arg); } - - - - app.on("window-all-closed", () => { globalShortcut.unregisterAll(); app.quit();