Closed jakobvogel closed 2 years ago
The fact it's loading your HTML file from app.asar
implies a manual path resolution issue somewhere in your code or electron-builders code. loadFile
does relative path resolution and shouldn't search app.asar
automatically.
You could try working around this by doing path resolution yourself with path.resolve(__dirname, 'index.html')
Many thanks for your comment @MarshallOfSound — manual path resolution via __dirname
really fixes the issue. (Yeah! 😊) Your help is greatly appreciated! 🙇♂️
Hello! First of all, many thanks for your work on Electron and its many sub-projects. We appreciate this a lot.
Disclaimer: I am aware that earlier issues relating to different asar files have been discussed before, but I did not find this particular case (or a solution) and decided to open a new issue. (Particularly pull-request #34 seems to tackle a very similar – if not the same – problem.)
TL;DR
When the universal app ends up with a "switch"
app.asar
and two architecture-specific filesapp-arm64.asar
andapp-x64.asar
, the app will attempt to load files (for instance duringwindow.loadFile('index.html')
withwindow
aBrowserWindow
) fromapp.asar
rather than the architecture-specific file, leading to a loading failure.For a minimal example based on the quick-start example and using
electron-builder
, see: https://github.com/jakobvogel/universal-electron-testBackground
In our app, we use
keytar
for password storage. Its prebuilt binaries are architecture specific. They end up in theapp.asar
files, causing the SHAs to differ while everything else contained in the two files is the same. Therefore, the universal build includes the architecture-specific switch, and the universal app is able to load, including thekeytar
dependency. However, when attempting to load a local HTML file for rendering the app, the app attempts to read from the (virtually empty) switchapp.asar
while the data is containedapp-arm64.asar
andapp-x64.asar
. The two original architecture-specific apps both work.I am wondering whether there is a simple solution to this.
app.asar
, while architecture-specific dependencies remain inapp-arm64.asar
andapp-x64.asar
?The only other alternative would be to build a universal
keytar.node
(hopefully) causing the two asar files to be equal again, correct? (Assuming that node files can be universal after all, and that the build system could be forced to use a universal build while creating the two original architecture-specific apps.)Thanks again for your input.