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

Electron 8 & fix App Store submission #120

Merged
merged 11 commits into from
Jun 3, 2020

Conversation

cwillisf
Copy link
Contributor

I wasn't sure who would be best to review this. Please feel free to reassign if you don't have time!

Resolves

Resolves #118
Resolves #119

Proposed Changes

This PR represents a few different changes which ideally would be separated, but because test builds were made with these commits I'm presenting them here as-is.

The most important changes are:

Other changes include:

  • Upgrade dependencies, including an update to Electron 8.2.5
    • This required a few minor code changes
  • Add com.apple.security.cs.allow-dyld-environment-variables and com.apple.security.device.microphone to the entitlements for both mac and mas builds.
    • It's unclear to me if these are necessary, but Electron documentation recommends allow-dyld-environment-variables and Apple documentation seems to suggest that com.apple.security.device.microphone should be present if com.apple.security.device.audio-input is in use.
  • Use minilog instead of console.log for logging
  • Remove uglifyjs to fix a security complaint from npm audit
  • A few quality-of-life improvements to the build scripts

Reason for Changes

Fixing the mas-dev build allowed me to test locally. Primarily this was about adding the masDev section in electron-builder.yaml, but I also needed to build app-builder-bin locally with this as-yet-unreleased change: develar/app-builder#34. These two changes fixed #119, allowing me to reproduce the issue that the Mac App Store reviewers have been reporting.

Fixing #118 boiled down to just setting hardenedRuntime: false for the mas build, which is sort of embarrassing given how long it has taken to figure out the problem. In essence, it turns out that electron-builder (or one of its dependencies) doesn't work correctly if hardenedRuntime is enabled and the app's entitlements list includes com.apple.security.app-sandbox. The sandbox entitlement is required for Catalina compatibility, so the solution for now (and maybe forever) is to disable the hardened runtime for Mac App Store builds. See electron/electron#22656 for further discussion on this.

Test Coverage

There are effectively three things to test:

  1. Non-store build (mac target): this can be tested with npm start or, for a more strict test, npm run dist.
  2. Store build (mas target): we can't really test this locally. We can build it with npm run dist to create the build but only Apple can run it.
  3. Store-like development build (mas-dev target): adjust scripts/electron-builder-wrapper.js to build mas-dev instead of mas and run npm run dist, then run the application created in dist/mas-dev.

The build process for each of these requires various digital certificates and provisioning profiles, so practically speaking they can only really be done by a member of the Scratch Team.

I have done all three of these things locally and they all work for me. If you'd like to try this out yourself (and you're a Scratch Team member) I'd be happy to help.

Everyone else: hopefully this PR will help us get the Mac App Store version up to date soon!

Christopher Willis-Ford added 11 commits May 11, 2020 13:14
minor code changes required for uuid, eslint-config-scratch, and
uglifyjs-webpack-plugin
Hopefully these will help solve the crash that Mac App Store reviewers
are encountering...
Skipping notarization isn't strictly wrong, but needs a big warning
since the build probably won't run on Catalina.
apparently the `com.apple.security.app-sandbox` entitlement and the
`hardenedRuntime: true` setting are mututally exclusive with
`electron-builder`, so the hardened runtime is now only used by non-MAS
builds ('mac' but not 'mas' or 'mas-dev')
*
* @param {string} mediaType - one of Electron's media types, like 'microphone' or 'camera'
* @returns {boolean} - true if permission granted, false otherwise.
* @returns {boolean|Promise.<boolean>} - true if permission granted, false otherwise.
Copy link

Choose a reason for hiding this comment

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

Why not just always return a promise?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We talked about this separately but just to record it here: functionally this is fine because it's called with await, which hides the difference between returning a promise and returning a raw Boolean. To avoid possible future problems I will make a followup change where this function always returns a promise, especially since there's basically no down-side to doing so in this context. (This isn't performance-critical, no synchronous work is happening around this call, etc.)

Copy link

@kchadha kchadha left a comment

Choose a reason for hiding this comment

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

LGTM other than the question about the function that returns both a promise and a boolean. Seems like that could cause bugs later.

Regardless, I don't think that question has to block this PR

@cwillisf cwillisf merged commit 6d9ab11 into scratchfoundation:develop Jun 3, 2020
@cwillisf cwillisf deleted the electron-8 branch June 3, 2020 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mas-dev build won't run due to invalid code signature Crashing / no main window for Mac App Store reviewers
3 participants