Electron window is blank in sandbox
See original GitHub issueThe 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:
- Created 6 years ago
- Comments:51 (25 by maintainers)
Top GitHub Comments
@sethlu Okay I will submit it now. Will give you the feedback as soon as I get it.
Don’t put native modules in the asar, use
asar.unpackDir
to exclude them.