question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

electron crashed on osx 12.4

See original GitHub issue

Electron-Builder Version: 23.0.3 Node Version: v16.15.0 Electron Version: v17.1.0 Electron Type (current, beta, nightly): current Target: OSX 12.4 Monterey / MacBook Pro12, 1 processor: intel core i5

our past version engine is electron 15. we updated version to 17.

1.we change the specific node-packages ( some dependency packages cannot support “@electorn/remote” <= it’s added on 17 ) so we fixed node-packages with patch-package on postinstall.

<patch-package>

custom-electron-titlebar : 3.2.7

diff --git a/node_modules/custom-electron-titlebar/menu/menuitem.js b/node_modules/custom-electron-titlebar/menu/menuitem.js
index c9b4aec..5abcb2e 100644
--- a/node_modules/custom-electron-titlebar/menu/menuitem.js
+++ b/node_modules/custom-electron-titlebar/menu/menuitem.js
@@ -11,7 +11,7 @@
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.CETMenuItem = void 0;
 const dom_1 = require("../common/dom");
-const electron_1 = require("electron");
+const remote = require("@electron/remote");
 const menu_1 = require("./menu");
 const keyCodes_1 = require("../common/keyCodes");
 const lifecycle_1 = require("../common/lifecycle");
@@ -21,7 +21,7 @@ class CETMenuItem extends lifecycle_1.Disposable {
         super();
         this.item = item;
         this.options = options;
-        this.currentWindow = electron_1.remote.getCurrentWindow();
+        this.currentWindow = remote.getCurrentWindow();
         this.closeSubMenu = closeSubMenu;
         this.menuContainer = menuContainer;
         // Set mnemonic
diff --git a/node_modules/custom-electron-titlebar/menubar.js b/node_modules/custom-electron-titlebar/menubar.js
index c8d7325..0400bb3 100644
--- a/node_modules/custom-electron-titlebar/menubar.js
+++ b/node_modules/custom-electron-titlebar/menubar.js
@@ -10,7 +10,7 @@
  *-------------------------------------------------------------------------------------------------------*/
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.escape = exports.Menubar = void 0;
-const electron_1 = require("electron");
+const remote = require("@electron/remote");
 const dom_1 = require("./common/dom");
 const menu_1 = require("./menu/menu");
 const keyboardEvent_1 = require("./browser/keyboardEvent");
@@ -194,7 +194,7 @@ class Menubar extends lifecycle_1.Disposable {
     onClick(menuIndex) {
         let electronEvent;
         const item = this.menuItems[menuIndex].menuItem;
-        const browserWindow = electron_1.remote.getCurrentWindow();
+        const browserWindow = remote.getCurrentWindow();
         item.click(electronEvent, browserWindow, browserWindow.webContents);
     }
     get onVisibilityChange() {
diff --git a/node_modules/custom-electron-titlebar/titlebar.js b/node_modules/custom-electron-titlebar/titlebar.js
index c734687..62eb04d 100644
--- a/node_modules/custom-electron-titlebar/titlebar.js
+++ b/node_modules/custom-electron-titlebar/titlebar.js
@@ -14,7 +14,7 @@ const platform_1 = require("./common/platform");
 const color_1 = require("./common/color");
 const dom_1 = require("./common/dom");
 const menubar_1 = require("./menubar");
-const electron_1 = require("electron");
+const remote = require("@electron/remote");
 const themebar_1 = require("./themebar");
 const INACTIVE_FOREGROUND_DARK = color_1.Color.fromHex('#222222');
 const ACTIVE_FOREGROUND_DARK = color_1.Color.fromHex('#333333');
@@ -28,7 +28,7 @@ const defaultOptions = {
     backgroundColor: color_1.Color.fromHex('#444444'),
     iconsTheme: themebar_1.Themebar.win,
     shadow: false,
-    menu: electron_1.remote.Menu.getApplicationMenu(),
+    menu: remote.Menu.getApplicationMenu(),
     minimizable: true,
     maximizable: true,
     closeable: true,
@@ -45,7 +45,7 @@ class Titlebar extends themebar_1.Themebar {
                 this.menubar.blur();
             }
         };
-        this.currentWindow = electron_1.remote.getCurrentWindow();
+        this.currentWindow = remote.getCurrentWindow();
         this._options = Object.assign(Object.assign({}, defaultOptions), options);
         this.registerListeners();
         this.createTitlebar();
@@ -388,7 +388,7 @@ class Titlebar extends themebar_1.Themebar {
             this.updateStyles();
         }
         else {
-            electron_1.remote.Menu.setApplicationMenu(menu);
+            remote.Menu.setApplicationMenu(menu);
         }
     }
     /**

electron-is-dev : 2.0.0

diff --git a/node_modules/electron-is-dev/index.js b/node_modules/electron-is-dev/index.js
index c8f2fd4..06918c5 100644
--- a/node_modules/electron-is-dev/index.js
+++ b/node_modules/electron-is-dev/index.js
@@ -7,5 +7,5 @@ if (typeof electron === 'string') {
 
 const isEnvSet = 'ELECTRON_IS_DEV' in process.env;
 const getFromEnv = Number.parseInt(process.env.ELECTRON_IS_DEV, 10) === 1;
-
-module.exports = isEnvSet ? getFromEnv : !electron.app.isPackaged;
+let isPackaged = typeof electron.app === 'undefined' ? false : electron.app.isPackaged;
+module.exports = isEnvSet ? getFromEnv : !isPackaged;

electron-tabs: 0.15.0

diff --git a/node_modules/electron-tabs/index.d.ts b/node_modules/electron-tabs/index.d.ts
index aca81c8..2b67f8c 100644
--- a/node_modules/electron-tabs/index.d.ts
+++ b/node_modules/electron-tabs/index.d.ts
@@ -39,6 +39,7 @@ declare namespace ElectronTabs {
     webviewAttributes?: {[key: string]: any};
     visible?: boolean;
     active?: boolean;
+    preload?: string;
     ready?: (tab: Tab) => void;
   }
 
diff --git a/node_modules/electron-tabs/index.js b/node_modules/electron-tabs/index.js
index 8b79863..64e7883 100644
--- a/node_modules/electron-tabs/index.js
+++ b/node_modules/electron-tabs/index.js
@@ -181,6 +181,7 @@ class Tab extends EventEmitter {
     this.webviewAttributes = args.webviewAttributes || {};
     this.webviewAttributes.src = args.src;
     this.tabElements = {};
+    this.preload = args.preload;
     TabPrivate.initTab.bind(this)();
     TabPrivate.initWebview.bind(this)();
     if (args.visible !== false) {
@@ -423,6 +424,10 @@ const TabPrivate = {
 
   initWebview: function () {
     const webview = this.webview = document.createElement("webview");
+    //필요한 설정을 여기에서 하도록 한다.
+    // preload, allowpopups
+    webview.preload = this.preload;
+    webview.allowpopups = true;
 
     const tabWebviewDidFinishLoadHandler = function (e) {
       this.emit("webview-ready", this);

patched files

patch-package.zip

2.we add audio recording permission to package.json

"mac": {
  "target": [
    "default"
  ],
  "icon": "./resources/installer/icon_lspworld.icns",
  "entitlements": "entitlements.mac.plist",
  "gatekeeperAssess": false,
  "hardenedRuntime": true,
  "extendInfo": {
    "NSMicrophoneUsageDescription": "This app requires microphone access to record audio."
  }
},

entitlements.mac.plist

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
   <dict>
       <key>com.apple.security.cs.allow-jit</key>
       <true/>
       <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
       <true/>
       <!-- https://github.com/electron-userland/electron-builder/issues/3940 -->
       <key>com.apple.security.cs.disable-library-validation</key>
       <true/>
       <key>com.apple.security.device.audio-input</key>
       <true/>
    </dict>
  </plist>

3. build method we deploy app on js script

node ./deploy_mac.js

let builder = require('electron-builder');
builder.build({
            x64: true,
        });

4.execute we unzip dmg and move electronApp to Application category when start it, BrowserWindow shown for a while. but it shutdown after a while.

crash report t_044de63127f9.txt

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
yujingxiacaicommented, Jun 16, 2022

Maybe I have the same problem as you, I have the config below as i need to access System Microphone,

	"target": [
				"dmg"
			],
			"hardenedRuntime": true,
			"entitlements": "assets/entitlements.mac.plist",
			"entitlementsInherit": "assets/entitlements.mac.plist",
			"gatekeeperAssess": false,
			"category": "public.app-category.developer-tools",
			"extendInfo": {
     "NSMicrophoneUsageDescription":"This app requires microphone access to record audio."
			}
		},

Operator System: macOS Monterey 12.2.1 Xcode Version: 13.3 (13E113) electron-builder: ^22.14.13 electron: ^15.1.0

Phenomenon of my app

  • install my app 🎉 normal…

  • open my app 🎉Automatically recall MacOS Security&Privacy Setting Then I choose to allow my app to access the microphone, and reopen.

  • reopen 😭 my checkMacAudio logic crash & white screen ⚠️

  • open app Contents find the info.plist, and open it with Xcode, Press the shortcut Command + S to save it (No modification required)

  • reopen my checkMacAudio logic executes fine, app works fine

  • 😵 why???


Electron-Builder Version: 23.0.3 Node Version: v16.15.0 Electron Version: v17.1.0 Electron Type (current, beta, nightly): current Target: OSX 12.4 Monterey / MacBook Pro12, 1 processor: intel core i5

our past version engine is electron 15. we updated version to 17.

1.we change the specific node-packages ( some dependency packages cannot support “@electorn/remote” <= it’s added on 17 ) so we fixed node-packages with patch-package on postinstall.

<patch-package>

custom-electron-titlebar : 3.2.7

diff --git a/node_modules/custom-electron-titlebar/menu/menuitem.js b/node_modules/custom-electron-titlebar/menu/menuitem.js
index c9b4aec..5abcb2e 100644
--- a/node_modules/custom-electron-titlebar/menu/menuitem.js
+++ b/node_modules/custom-electron-titlebar/menu/menuitem.js
@@ -11,7 +11,7 @@
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.CETMenuItem = void 0;
 const dom_1 = require("../common/dom");
-const electron_1 = require("electron");
+const remote = require("@electron/remote");
 const menu_1 = require("./menu");
 const keyCodes_1 = require("../common/keyCodes");
 const lifecycle_1 = require("../common/lifecycle");
@@ -21,7 +21,7 @@ class CETMenuItem extends lifecycle_1.Disposable {
         super();
         this.item = item;
         this.options = options;
-        this.currentWindow = electron_1.remote.getCurrentWindow();
+        this.currentWindow = remote.getCurrentWindow();
         this.closeSubMenu = closeSubMenu;
         this.menuContainer = menuContainer;
         // Set mnemonic
diff --git a/node_modules/custom-electron-titlebar/menubar.js b/node_modules/custom-electron-titlebar/menubar.js
index c8d7325..0400bb3 100644
--- a/node_modules/custom-electron-titlebar/menubar.js
+++ b/node_modules/custom-electron-titlebar/menubar.js
@@ -10,7 +10,7 @@
  *-------------------------------------------------------------------------------------------------------*/
 Object.defineProperty(exports, "__esModule", { value: true });
 exports.escape = exports.Menubar = void 0;
-const electron_1 = require("electron");
+const remote = require("@electron/remote");
 const dom_1 = require("./common/dom");
 const menu_1 = require("./menu/menu");
 const keyboardEvent_1 = require("./browser/keyboardEvent");
@@ -194,7 +194,7 @@ class Menubar extends lifecycle_1.Disposable {
     onClick(menuIndex) {
         let electronEvent;
         const item = this.menuItems[menuIndex].menuItem;
-        const browserWindow = electron_1.remote.getCurrentWindow();
+        const browserWindow = remote.getCurrentWindow();
         item.click(electronEvent, browserWindow, browserWindow.webContents);
     }
     get onVisibilityChange() {
diff --git a/node_modules/custom-electron-titlebar/titlebar.js b/node_modules/custom-electron-titlebar/titlebar.js
index c734687..62eb04d 100644
--- a/node_modules/custom-electron-titlebar/titlebar.js
+++ b/node_modules/custom-electron-titlebar/titlebar.js
@@ -14,7 +14,7 @@ const platform_1 = require("./common/platform");
 const color_1 = require("./common/color");
 const dom_1 = require("./common/dom");
 const menubar_1 = require("./menubar");
-const electron_1 = require("electron");
+const remote = require("@electron/remote");
 const themebar_1 = require("./themebar");
 const INACTIVE_FOREGROUND_DARK = color_1.Color.fromHex('#222222');
 const ACTIVE_FOREGROUND_DARK = color_1.Color.fromHex('#333333');
@@ -28,7 +28,7 @@ const defaultOptions = {
     backgroundColor: color_1.Color.fromHex('#444444'),
     iconsTheme: themebar_1.Themebar.win,
     shadow: false,
-    menu: electron_1.remote.Menu.getApplicationMenu(),
+    menu: remote.Menu.getApplicationMenu(),
     minimizable: true,
     maximizable: true,
     closeable: true,
@@ -45,7 +45,7 @@ class Titlebar extends themebar_1.Themebar {
                 this.menubar.blur();
             }
         };
-        this.currentWindow = electron_1.remote.getCurrentWindow();
+        this.currentWindow = remote.getCurrentWindow();
         this._options = Object.assign(Object.assign({}, defaultOptions), options);
         this.registerListeners();
         this.createTitlebar();
@@ -388,7 +388,7 @@ class Titlebar extends themebar_1.Themebar {
             this.updateStyles();
         }
         else {
-            electron_1.remote.Menu.setApplicationMenu(menu);
+            remote.Menu.setApplicationMenu(menu);
         }
     }
     /**

electron-is-dev : 2.0.0

diff --git a/node_modules/electron-is-dev/index.js b/node_modules/electron-is-dev/index.js
index c8f2fd4..06918c5 100644
--- a/node_modules/electron-is-dev/index.js
+++ b/node_modules/electron-is-dev/index.js
@@ -7,5 +7,5 @@ if (typeof electron === 'string') {
 
 const isEnvSet = 'ELECTRON_IS_DEV' in process.env;
 const getFromEnv = Number.parseInt(process.env.ELECTRON_IS_DEV, 10) === 1;
-
-module.exports = isEnvSet ? getFromEnv : !electron.app.isPackaged;
+let isPackaged = typeof electron.app === 'undefined' ? false : electron.app.isPackaged;
+module.exports = isEnvSet ? getFromEnv : !isPackaged;

electron-tabs: 0.15.0

diff --git a/node_modules/electron-tabs/index.d.ts b/node_modules/electron-tabs/index.d.ts
index aca81c8..2b67f8c 100644
--- a/node_modules/electron-tabs/index.d.ts
+++ b/node_modules/electron-tabs/index.d.ts
@@ -39,6 +39,7 @@ declare namespace ElectronTabs {
     webviewAttributes?: {[key: string]: any};
     visible?: boolean;
     active?: boolean;
+    preload?: string;
     ready?: (tab: Tab) => void;
   }
 
diff --git a/node_modules/electron-tabs/index.js b/node_modules/electron-tabs/index.js
index 8b79863..64e7883 100644
--- a/node_modules/electron-tabs/index.js
+++ b/node_modules/electron-tabs/index.js
@@ -181,6 +181,7 @@ class Tab extends EventEmitter {
     this.webviewAttributes = args.webviewAttributes || {};
     this.webviewAttributes.src = args.src;
     this.tabElements = {};
+    this.preload = args.preload;
     TabPrivate.initTab.bind(this)();
     TabPrivate.initWebview.bind(this)();
     if (args.visible !== false) {
@@ -423,6 +424,10 @@ const TabPrivate = {
 
   initWebview: function () {
     const webview = this.webview = document.createElement("webview");
+    //필요한 설정을 여기에서 하도록 한다.
+    // preload, allowpopups
+    webview.preload = this.preload;
+    webview.allowpopups = true;
 
     const tabWebviewDidFinishLoadHandler = function (e) {
       this.emit("webview-ready", this);

patched files

patch-package.zip

2.we add audio recording permission to package.json

"mac": {
  "target": [
    "default"
  ],
  "icon": "./resources/installer/icon_lspworld.icns",
  "entitlements": "entitlements.mac.plist",
  "gatekeeperAssess": false,
  "hardenedRuntime": true,
  "extendInfo": {
    "NSMicrophoneUsageDescription": "This app requires microphone access to record audio."
  }
},

entitlements.mac.plist

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
   <dict>
       <key>com.apple.security.cs.allow-jit</key>
       <true/>
       <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
       <true/>
       <!-- https://github.com/electron-userland/electron-builder/issues/3940 -->
       <key>com.apple.security.cs.disable-library-validation</key>
       <true/>
       <key>com.apple.security.device.audio-input</key>
       <true/>
    </dict>
  </plist>

3. build method we deploy app on js script

node ./deploy_mac.js

let builder = require('electron-builder');
builder.build({
            x64: true,
        });

4.execute we unzip dmg and move electronApp to Application category when start it, BrowserWindow shown for a while. but it shutdown after a while.

crash report t_044de63127f9.txt

0reactions
bechurchcommented, Jun 29, 2022

Having this issue as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

electron mac build crashing on startup (signed and notarized)
im using electron @5.0.0 and electron-builder@21.1.1. im having issues in trying to get an electron app to start. i have no problems signing ......
Read more >
Apps Crashing on macOS Ventura? Here's the Fix
Apps Crashing on macOS Ventura? Here's the Fix · 1. Force Quit the App and Restart It · 2. Update Your App ·...
Read more >
Any macOS Target - electron-builder
Be aware that your app may crash if the right entitlements are not set like com.apple.security.cs.allow-jit for example on arm64 builds with Electron...
Read more >
Outlook keeps crashing after update to Monterey 12.4
Running Mac with Monterey 12.4 - Need help with this issue - have just paid for Microsoft 365 subscription yet Outlook keeps crashing...
Read more >
Different apps stopped working after updating to Monterey ...
If this were my mac, here's the steps I would take. ... one until you discover the source of the delayed start /...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found