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: crash on nativeImage on Windows on ARM #25396

Merged
merged 3 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,11 @@ if (is_mac) {
"/DELAYLOAD:api-ms-win-core-winrt-string-l1-1-0.dll",
]

if (target_cpu == "arm64") {
configs -= [ "//build/config/win:cfi_linker" ]
ldflags += [ "/guard:cf,nolongjmp" ]
}

# This is to support renaming of electron.exe. node-gyp has hard-coded
# executable names which it will recognise as node. This module definition
# file claims that the electron executable is in fact named "node.exe",
Expand Down
17 changes: 4 additions & 13 deletions spec/api-native-image-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,7 @@ describe('nativeImage module', () => {
const imageB = nativeImage.createFromBitmap(imageA.toBitmap(), imageA.getSize());
expect(imageB.getSize()).to.deep.equal({ width: 538, height: 190 });

let imageC;
// TODO fix nativeImage.createFromBuffer from bitmaps on WOA. See https://github.com/electron/electron/issues/25069
if (process.platform === 'win32' && process.arch === 'arm64') {
imageC = nativeImage.createFromBuffer(imageA.toPNG(), { ...imageA.getSize(), scaleFactor: 2.0 });
} else {
imageC = nativeImage.createFromBuffer(imageA.toBitmap(), { ...imageA.getSize(), scaleFactor: 2.0 });
}
const imageC = nativeImage.createFromBuffer(imageA.toBitmap(), { ...imageA.getSize(), scaleFactor: 2.0 });
expect(imageC.getSize()).to.deep.equal({ width: 269, height: 95 });
});

Expand All @@ -192,8 +186,7 @@ describe('nativeImage module', () => {
});
});

// TODO fix nativeImage.createFromBuffer on WOA. See https://github.com/electron/electron/issues/25069
ifdescribe(!(process.platform === 'win32' && process.arch === 'arm64'))('createFromBuffer(buffer, options)', () => {
describe('createFromBuffer(buffer, options)', () => {
it('returns an empty image when the buffer is empty', () => {
expect(nativeImage.createFromBuffer(Buffer.from([])).isEmpty()).to.be.true();
});
Expand Down Expand Up @@ -347,8 +340,7 @@ describe('nativeImage module', () => {
});

describe('createFromPath(path)', () => {
// TODO fix nativeImage.createFromPath on WOA. See https://github.com/electron/electron/issues/25069
ifit(!(process.platform === 'win32' && process.arch === 'arm64'))('returns an empty image for invalid paths', () => {
it('returns an empty image for invalid paths', () => {
expect(nativeImage.createFromPath('').isEmpty()).to.be.true();
expect(nativeImage.createFromPath('does-not-exist.png').isEmpty()).to.be.true();
expect(nativeImage.createFromPath('does-not-exist.ico').isEmpty()).to.be.true();
Expand Down Expand Up @@ -520,8 +512,7 @@ describe('nativeImage module', () => {
});

describe('addRepresentation()', () => {
// TODO fix nativeImage.createFromBuffer on WOA. See https://github.com/electron/electron/issues/25069
ifit(!(process.platform === 'win32' && process.arch === 'arm64'))('does not add representation when the buffer is too small', () => {
it('does not add representation when the buffer is too small', () => {
const image = nativeImage.createEmpty();

image.addRepresentation({
Expand Down