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
Error with Electron and ffi-napi #238
Comments
same problem, electron 22.0.2 and ffi-napi 4.0.3 |
same problem, electron 22.0.3 and ffi-npi 4.0.3 |
I am seeing a similar stack trace using electron
|
Update: locking electron version to
|
same problem, electron 22.1.0 and ffi-napi 4.0.3 |
same problem, osx 13.2, electron 22 and ffi-napi 4.0.3 |
The same problem. I used template like @hatsune-miku {
"electron": "^22.2.0",
"ffi-napi": "^4.0.3",
"ref-napi": "^3.0.3",
} I also found out that the latest compatible Maybe this comparison will help knowledgeable people to understand the problem: |
I don't claim to be knowledgeable but I peeked at this out of curiosity. Whatever changed in Electron to make this behavior start, it would most likely be related to Node.js. The only issue that's related to Node.js is this: electron/electron#36626. |
same issue here when trying to upgrade from electron 18.2.3 to 20 all the way to 23 |
same issue on WIn10, npm 8.19.2, node 18.12.1 |
correct me if I am wrong, but is the below what we want?
|
Yes that seems to be the fix for the runtime error. |
how do i install that fix ? |
Thanks for pointing this out! Would love to see this merged and released in |
@Vitalii4as Would you kindly make the pull request to the official ref-napi repo for us? |
I'm in trouble too. I was wondering if there is another good library and I found this one. i will try. |
@ej-toita My fix didn't work( |
These two are working for me: https://www.npmjs.com/package/@lwahonen/ffi-napi For some reason I need to npm install twice on Windows, as the first build always poops out with "file in use" errors. Feel free to figure out why that happens. |
I can confirm these versions are working for me as well. Big thanks to @lwahonen -- but I would hope to see the fixes merged into the mainline |
i get this error when trying to install
|
As I said, you need to run npm install twice. Feel free to figure out what’s blocking the access to nothing.obj on the first go. |
i tried multiple times, but same result :\ |
For what it's worth, it appears to work in one go using pnpm @lwahonen |
any update? |
I don't think any updates are going to be happening. I patched the fix from @inigolabs enough that it works for us. If you look at the commit history on this repo, nobody has been working on node-ffi-napi for a long time. |
change to electron@15.4.0 & ffi-napi@4.0.3 can fix it |
The solution should not be to downgrade your electron. It is important to stay up to date with the latest electron for many reasons. |
same problem, electron 21.4.4 and ffi-napi 4.0.3 |
Same question "electron": "^24.1.3" I will change it to "electron": "20.0.2" Successfully run |
I finally got some time to try
myself, and it caused |
I got this working with @Breush 's packages. Now the problem is that when the electron app is packaged as an ASAR, any dependent DLLs inside cannot be loaded. I just get Win32 Error 126, which is related to not being able to load a library. node-ffi/node-ffi#294 (comment) The simplest way around this without having to hack node dependencies which package compiled libs to pieces.. is to use module.exports = {
packagerConfig: {
asar: false,
...
},
...
}
... |
@Breush can you prebuild for ia32 in your pkg? i try to prebuild, but throw error:
then i edit common.py from
ant i don't know how to fix it. can you help me |
No. I don't plan to maintain these projects, and plan to archive these. |
Electron 21 enabled V8 sandboxed pointers, following Chrome's decision to do the same in Chrome 103. This has some implications for native modules, namely ArrayBuffers which point to external ("off-heap") memory are no longer allowed. This breaks our `win-ca.ts` implementation. We're opting to use these forks as a short-term fix to allow us to upgrade to the latest version of electron as we evaluate a long-term fix. See the following links for more details: - https://www.electronjs.org/blog/v8-memory-cage - node-ffi-napi/node-ffi-napi#238 Signed-off-by: Phillip Rak <rak.phillip@gmail.com>
Electron 21 enabled V8 sandboxed pointers, following Chrome's decision to do the same in Chrome 103. This has some implications for native modules, namely ArrayBuffers which point to external ("off-heap") memory are no longer allowed. This breaks our `win-ca.ts` implementation. We're opting to use these forks as a short-term fix to allow us to upgrade to the latest version of electron as we evaluate a long-term fix. See the following links for more details: - https://www.electronjs.org/blog/v8-memory-cage - node-ffi-napi/node-ffi-napi#238 Signed-off-by: Phillip Rak <rak.phillip@gmail.com>
Electron 21 enabled V8 sandboxed pointers, following Chrome's decision to do the same in Chrome 103. This has some implications for native modules, namely ArrayBuffers which point to external ("off-heap") memory are no longer allowed. This breaks our `win-ca.ts` implementation. We're opting to use these forks as a short-term fix to allow us to upgrade to the latest version of electron as we evaluate a long-term fix. See the following links for more details: - https://www.electronjs.org/blog/v8-memory-cage - node-ffi-napi/node-ffi-napi#238 Signed-off-by: Phillip Rak <rak.phillip@gmail.com>
Electron 21 enabled V8 sandboxed pointers, following Chrome's decision to do the same in Chrome 103. This has some implications for native modules, namely ArrayBuffers which point to external ("off-heap") memory are no longer allowed. This breaks our `win-ca.ts` implementation. We're opting to use these forks as a short-term fix to allow us to upgrade to the latest version of electron as we evaluate a long-term fix. See the following links for more details: - https://www.electronjs.org/blog/v8-memory-cage - node-ffi-napi/node-ffi-napi#238 Signed-off-by: Phillip Rak <rak.phillip@gmail.com>
Since it doesnt seem likely to me that this problem is going to be solved, I have moved onto node-addon-api. |
I'm going through the same thing. After upgrading from Electron version 19 to version 27, |
As discussed in #248 and #255 this code only works on end-of-life versions on Node.js. |
Hi there, I am also facing same issue with electron upgrade and this library since its functionality is mandatory in the project I am working on. I think it would be great someone from electron/node-ffi-napi should provide an official fork/patch adding the commented fixes and some instructions/recommendations even if gets archived in order to avoid third party forks. So sticking to last electron compatible version 20.3.8 or trying out koffi package seem only ways for me who I am a 0 skills in C/C++ for writing my own node add-on. In addition a personal recommendation for anyone thinking about installing any of the mentioned forks/packages:
Even if these are working and they are not malicious code, you should be aware that these projects are not 100% github forks and their integrity is not guaranteed, in other words they do not share the same history with this repo. |
I don't have the time / motivation for this. Maybe @angelfraga could create the version you seek, instead of asking someone else? |
@angelfraga |
@lwahonen first of all thanks for your fork. I will give a try to manage your changes in order to integrated them in a real fork (as I said I have 0 knowledge of C/C++ but never is too late to get an new skill ) @Elendiar Thanks for let us know about your experience with koffi 👍 , probably next step I will do is giving a try to this, in short it seems to be the quick solution. So I will post back when trying out ia32. |
@angelfraga I used I managed to rewrite all these functions in koffi, but now I need to try to execute them on x86 OS, or by commenting codeblocks and assembling to understand where the problem is. At least the module that is responsible for registering the taskbar in the system works in x86 fine. |
I've eneded up replacing ffi-napi to koffi and i was finally able to upgrade electron from 19.x to 20.x |
Adding another recommendation for https://github.com/Koromix/koffi |
Hi there again , happy new year. First, thanks everyone for the feedback about Koffi. As my last words about that topic. As a team mate found out, here node-ffi-napi/ref-napi#64 looks like the right fix for ArrayBuffers which might be also the fix for Electron 20.3.9 issue https://www.electronjs.org/de/blog/v8-memory-cage I am wondering because that PR seems to pass all tests and it was already reviewed (like other PR in these two repos which are also not merged yet). So if you need to avoid new dependencies, I would recommend to give a try and check that branch from the PR since its history is aligned with the main branch. You might need to build in it your target arch. If you do not have these limitations, based on the other users comments https://github.com/Koromix/koffi seems to be the next step. |
Adding another recommendation for Koffi. It's been working well for me so far in the latest version of Electron, and it has pretty extensive documentation: https://koffi.dev (Before trying koffi I had tried using the @breush/ref-napi fork, which @stevenlafl got working on a newer electron version, however when I tried it I hit the same error that @ej-toita hit here.) But yeah; it's biggest benefit at the moment is simply that it's not abandoned, and has good documentation. Like @Elendiar mentioned, I also like its handling of structures and pointers -- I found it easier to figure out how to implement them properly. (due partly just to its documentation I guess) An example usage of koffi from my rewrite: export const Rect = koffi.struct("Rect", {left: "ulong", top: "ulong", right: "ulong", bottom: "ulong"});
export const LPRect = koffi.pointer("LPRect", "Rect");
// Leaving out the HWND def, since I'm a rebel and define it as `int64` for easier usage, rather than a proper pointer-type. How bad is this? XD
const lib = koffi.load("user32.dll");
export const user32 = {
GetWindowRect: lib.func("bool GetWindowRect(HWND hWnd, _Out_ LPRect lpRect)"),
//GetWindowRect: lib.func("GetWindowRect", "bool", [HWND, koffi.out(LPRect)]), // alternative syntax
};
export type RectShape = {left: number, top: number, right: number, bottom: number};
export function getWindowRect(handle) {
const rect = {} as RectShape;
var success = user32.GetWindowRect(handle, rect);
if (!success) return null;
return rect;
} While the node-ffi equivalent is about the same amount of code, I think the koffi API is a little more intuitive. (eg. not split into multiple libraries like ffi-napi + ref-napi + ref-struct-di, more standard name with |
|
@xjh1230 In your error log, please find the line that contains I sense you are running an old version of node-gyp. |
node -v v16.5.0 & node-gyp -v v9.0.0 |
For my As mentioned above, you will probably have more success with this fork https://github.com/lwahonen/node-ffi-napi |
error:
|
electron 版本切换到 20.0.0 The electron version is switched to 20.0.0 |
now for windwos.further maybe macoos |
Electron:
^22.0.3
Tried also with Electron
20.0.0
ffi-napi:
4.0.3
File index.js
File index.html
Error:
The text was updated successfully, but these errors were encountered: