Skip to content

Commit

Permalink
fix: crash on nativeImage on Windows on ARM (#25396)
Browse files Browse the repository at this point in the history
* fix: nativeImage on WOA

* Remove old ldflag

* maybe this will work ¯\_(ツ)_/¯
  • Loading branch information
jkleinsc committed Sep 10, 2020
1 parent dd781c4 commit acf5d48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
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

0 comments on commit acf5d48

Please sign in to comment.