Electron build doesn't work properly

See original GitHub issue

Hi, not sure if I’m doing something wrong on my end but when I try to build my Electron C++ addon with CMake.js I end up with some weird issues. The biggest one is that the app instatnly crashes when I call args[0]->IsString() during function argument validation. There doesn’t seem to be a problem with the other validation methods like IsNumber() or IsStringObject(). After I toggled on the --enable-logging flag in Electron I was able to figure out that this is the error Electron crashes on: [13508:1016/202149.533:ERROR:crashpad_client_win.cc(799)] not connected.

Another weird behavior is that when I’m logging something with std::cout it only actually gets printed when compiling in Debug mode. Neither of these issues appeared when I tried building with node-gyp.

My CMakeLists.txt file is just the very basic configuration:

cmake_minimum_required (VERSION 3.5)
set(CMAKE_CXX_STANDARD 17)
project(test)

include_directories(${CMAKE_JS_INC})
add_library(${PROJECT_NAME} SHARED main.cpp ${CMAKE_JS_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries (${PROJECT_NAME} ${CMAKE_JS_LIB})

and this is my setup in package.json:

"cmake-js": {
    "runtime": "electron",
    "runtimeVersion": "10.1.3",
    "arch": "x64"
}

Am I missing something or is this some sort of internal CMake.js issues? Thanks.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:19

github_iconTop GitHub Comments

2reactions
vadim-termiuscommented, Nov 24, 2020

For Electron 9+ V8_31BIT_SMIS_ON_64BIT_ARCH should be defined.

For Electron 9+ for arm64 and for x64 V8_COMPRESS_POINTERS should also be defined.

For Electron 11+ V8_REVERSE_JSARGS should also be defined.

2reactions
vadim-termiuscommented, Nov 10, 2020

Since Electron 9 it uses the patch to enable pointer compression in v8 and its node.js: https://github.com/electron/electron/pull/21468/files

Now all native node modules should be built with the V8_COMPRESS_POINTERS macro defined only on 64-bit platforms and the V8_31BIT_SMIS_ON_64BIT_ARCH macro defined on all platforms (which seems counterintuitive, but in the patch this is defined by default)

Those macros don’t affect node-addon-abi, that is why it works fine.

cc @unbornchikken @mastergberry

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron js app not working after building
i create small app with electron js and sqlite with knex it work purfuctyl when i run npm start but when i try...
Read more >
Multi Platform Build - electron-builder
Build performed in parallel, so, it is highly recommended to not use npm task per platform (e.g. npm run dist:mac && npm run...
Read more >
A Comprehensive Guide to Building and Packaging an ...
Electron -forge only packages for your current platform, so it doesn't really work for packaging cross platform apps unless you own each of...
Read more >
Building your First App
If you are on a Windows machine, please do not use Windows Subsystem for Linux (WSL) when following this tutorial as you will...
Read more >
electron builder not allowed to load local resource
I am working on an electron application and trying to build a package using electron-builder . Everything seems to be working fine for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found