Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Include swiftshader directory when creating installer for Electron 10+ #375

Merged
merged 12 commits into from
Feb 10, 2021

Conversation

niik
Copy link
Contributor

@niik niik commented Jan 20, 2021

This is a continuation of #367 with the intention of including the swiftshader directory (present in Electron 10+) as well as the vk_swiftshader_icd.json file. These paths are required in order for electron to be able to run on systems where GPU acceleration is unavailable.

See #367 (comment):

👋 We (the GitHub Desktop team) is looking into upgrading to Electron 11 and came upon this issue which made us a tad bit nervous as it seems like it would affect Electon 11 as well (right?).

We'd be happy to help in any way we can to get this over the finish line but it's not immediately obvious how.

I haven't looked in detail, but I suspect that this change will fail with older versions of Electron that do not contain the swiftshader files. This module doesn't currently specify the versions of Electron that it supports, so it effectively supports pretty much all versions. If we restrict that, this will require a major version bump. Otherwise the change will need to be fixed so that it works for versions without these files.

@malept Do you have a sense of what your preferred approach would be?

In case the approach would be to special case versions prior to Electron 10 do you envision having two different nuspecttemplate files and conditionally including one or the other?

let templateData = await fs.readFile(path.join(__dirname, '..', 'template.nuspectemplate'), 'utf8');

Or would you rather attempt to add the entries to the existing template at runtime?

And last question (for now), what method would you prefer for detecting whether these files need to be included? Should we just check whether they exist in the appDirectory or would you like to specifically check the bundled electron version?

@malept Is the approach taken here in line with what you'd expect?

Closes #367.

@niik niik changed the title Conditionally include swiftshader directory fix: Include swiftshader directory when creating installer for Electron 10+ Jan 20, 2021
@niik
Copy link
Contributor Author

niik commented Jan 20, 2021

I believe #376 will allow the test-mac build to pass as well.

Copy link
Member

@malept malept left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this.

Can the fixtures be zero-sized like the others?

Comment on lines 44 to 58

log('Verifying contents of .nupkg');
const sevenZipPath = path.join(__dirname, '..', 'vendor', '7z.exe');
let cmd = sevenZipPath;
const args = ['l', nupkgPath];

if (process.platform !== 'win32') {
args.unshift(cmd);
const wineExe = process.arch === 'x64' ? 'wine64' : 'wine';
cmd = wineExe;
}

const packageContents = await spawn(cmd, args);
t.true(packageContents.includes('lib\\net45\\vk_swiftshader_icd.json'));
t.true(packageContents.includes('lib\\net45\\swiftshader\\libEGL.dll'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if there was a test that didn't add the swiftshader files as well, to prevent regressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'll take a stab at it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encountered an issue where the two tests caused a race condition trying to delete the Squirrel.exe file in the beforeEach so I tweaked the approach to always copying the fixture app directory to a temporary location before packaging.

@niik
Copy link
Contributor Author

niik commented Jan 20, 2021

Can the fixtures be zero-sized like the others?

I just copied one of other binary fixtures here which I guess wasn't zero sized. Looking at the fixtures directory there seems to be a mix of empty files and binary-like files. I'll empty them tho!

@niik niik requested a review from malept January 20, 2021 17:47
Copy link
Member

@malept malept left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine now, I just have some suggestions about temporary directory naming.

spec/installer-spec.ts Outdated Show resolved Hide resolved
Comment on lines 14 to 16
return process.platform !== 'win32'
? spawn(process.arch === 'x64' ? 'wine64' : 'wine', [sevenZipPath, ...args])
: spawn(sevenZipPath, args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I'd ask to refactor this to look a bit more like how it's done elsewhere in the module (I do not agree with multi-line ternary statements), but I have a PR to drastically refactor how spawn works in #373 so it's kind of a moot point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I tried to stay true to the current coding style but old habits die hard, I'll extract the wine binary name into a variable.

spec/installer-spec.ts Outdated Show resolved Hide resolved
@niik niik requested a review from malept January 22, 2021 09:43
@niik niik mentioned this pull request Jan 22, 2021
5 tasks
@sergiou87
Copy link

Hi @malept!

Did you have a chance to take a look at @niik's changes? This PR is blocking desktop/desktop#11142, so please let me know if there is anything I can do to help getting this merged! 🙏

Thank you! ❤️

Copy link
Member

@malept malept left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience, this will go out in a new release shortly.

@malept malept merged commit 7aacb15 into electron:master Feb 10, 2021
@electron-bot
Copy link

🎉 This PR is included in version 4.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants