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 window is blank in sandbox

See original GitHub issue

The app is on Electron with react

electron: 1.6.11
electron-packager: 8.7.2
react: 15.4.2
electron-osx-sign: 0.4.7

I create and sign my build with

electron-packager . --ignore=./.gitignore --ignore=./.node_modules --ignore=./webpack.config.js --platform=mas --arch=all --icon='./electron.icns' --app-bundle-id=com.smarterback.desktop --helper-bundle-id=com.smarterback.desktop.helper --app-category-type=public.app-category.utilities --overwrite --asar=true --app-version=1.0.5 --build-version=666 --electronVersion=1.6.11 --out=release-builds && electron-osx-sign release-builds/SmarterBack-mas-x64/SmarterBack.app --entitlements=parent.plist --entitlements-inherit=mas.inherit.default.entitlements --identity='3rd Party Mac Developer Application: JENGO LLC (63UV74H5Q5)' --platform='mas' --embedded-binary=release-builds/SmarterBack-mas-x64/SmarterBack.app/Contents/Resources/app.asar

parent.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.app-sandbox</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.temporary-exception.sbpl</key>
    <array>
        <string>(allow mach-lookup (global-name-regex #"^org.chromium.Chromium.rohitfork.[0-9]+$"))</string>
        <string>(allow mach-register (global-name-regex #"^org.chromium.Chromium.rohitfork.[0-9]+$"))</string>
    </array>
  </dict>
</plist>

mas.inherit.default.entitlements

<?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.scripting-targets</key>
    <true/>
    <key>com.apple.security.inherit</key>
    <true/>
    <key>com.apple.security.device.firewire</key>
    <true/>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.device.camera</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-only</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
    <key>com.apple.security.temporary-exception.sbpl</key>
    <array>
        <string>(allow mach-lookup (global-name-regex #"^org.chromium.Chromium.rohitfork.[0-9]+$"))</string>
        <string>(allow mach-register (global-name-regex #"^org.chromium.Chromium.rohitfork.[0-9]+$"))</string>
    </array>
</dict>
</plist>

And after i sign my app I start to get blank screen on my browser window and nothing can load. After some debugging I notice that I can’t use require to import my js, css in my index.html . I started to research more and I found that I had to use “sandbox: true” in my window

window = new BrowserWindow({
    webPreferences: {
        sandbox: true,
        nodeIntegration: false
    }
})

I even tried to use preload.js to the webPreferences

var hostProcess = process;
var hostRequire = require;

process.once('loaded', function(){

  global.host = {
    process: hostProcess,
    crash: function () {
      hostProcess.crash();
    },
  };

  global.host.ipc = hostRequire('ipc');
  global.host.ipc = hostRequire('fs');
});

My Index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' http://platform.linkedin.com ">
    <title>SmarterBack Preferences</title>
    <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="quill.snow.css">
    <link rel="stylesheet" type="text/css" href="Main.css">
</head>

<body>
    <div id="main"></div>
</body>

<script src="js/libs/createjs/preloadjs-0.6.2.min.js"></script>
<script src="js/BRFv4Demo.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="./Main.js"></script>
</html>

For now I think I’ve tried everything, but nothing seems to work. The app works perfect if it’s not in sandbox mode, but then I can’t submit it to the apple store. After I sign it everything in the index.html stops working. At some cases I got error “helper not found” when I started the app. I think the main problem is the signing, because it a lot of topics on this issue people said that they fixed the problem with a simple signing…

Any kind of help will be appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:51 (25 by maintainers)

github_iconTop GitHub Comments

2reactions
Alexandra1337commented, Sep 27, 2017

@sethlu Okay I will submit it now. Will give you the feedback as soon as I get it.

1reaction
maleptcommented, Oct 4, 2017

Don’t put native modules in the asar, use asar.unpackDir to exclude them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

electron browser window gets white screen in sandbox mode
When the app is in sandbox mode I can't use any node processes and my html can't require anything so I just end...
Read more >
Process Sandboxing | Electron
When renderer processes in Electron are sandboxed, they behave in the same way as a regular Chrome renderer would. A sandboxed renderer won't...
Read more >
Building a desktop app with Electron and Create React App
A step-by-step tutorial explaining how to create a desktop application using Create React App (CRA) and Electron.
Read more >
Blank screen on ubuntu 21.10 and Fedora 35 KDE/GNOME ...
I don't think insync is using electron but that could be a similar bug than the one affecting electron users due to a...
Read more >
Linux desktop app only showing menu bar and blank screen
The --no-sandbox flag is used to [fix the Electron framework issue as posted here](Error “The SUID sandbox helper binary was found…
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