Linked Questions

Popular Questions

Electron desktop UI issue only on Mac

Asked by At

I have a Spring boot application which is packaged with Electron as a binary.

This app binary is working on Windows but not on Mac. The issue with Mac is when I double click the electron built application binary then it's not rendering the application on Electron UI rather if I start the server in the background then it is ok.

JS code snippet

const { app, BrowserWindow } = require('electron');

let window;
let appUrl = 'http://localhost:8080';
let appName = 'TEST';
let appHome = process.resourcesPath + '\\' + 'test.jar';

serverProcess = require('child_process').spawn('java', ['-jar', appHome], { detached: false });

serverProcess.stdout.on('data', function (data) {
    console.log('stdout' + data);
});
serverProcess.stderr.on('data', function (data) {
    console.log('stderr' + data);
});


function createWindow() {
    window = new BrowserWindow({ width: 600, height: 600, title: appName });
    window.loadURL(appUrl);

    window.on('closed', () => {
        window = null;
    })
}

const startUp = function () {
    const requestPromise = require('minimal-request-promise');
    requestPromise.get(appUrl).then(function (response) {
        createWindow();
    }, function (response) {
        console.log('Starting the MQUtility instance...');
        setTimeout(function () {
            startUp();
        }, 600);
    });
};

startUp();

Package code snippet

{
  "name": "Test-tool",
  "version": "0.0.1-SNAPSHOT",
  "description": "A minimal Electron application",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "package": "electron-packager ./ Test --all --out ~/Desktop/Test --app-version 0.0.1-SNAPSHOT --asar=true --overwrite"
  },
  "repository": "https://github.com/electron/electron-quick-start",
  "keywords": [
    "Electron",
    "quick",
    "start",
    "tutorial",
    "demo"
  ],
  "author": "GitHub",
  "license": "CC0-1.0",
  "devDependencies": {
    "electron": "^3.0.13",
    "electron-packager": "^13.0.1"
  },
  "dependencies": {
    "find-process": "^1.2.1",
    "minimal-request-promise": "^1.5.0",
    "tree-kill": "^1.2.1"
  }
}

I guess I am missing something on Mac. Can anyone suggest?

Related Questions