capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
318 stars 58 forks source link

Pointer lost from Web to Native #197

Open EmilioSalimo opened 1 year ago

EmilioSalimo commented 1 year ago

Describe the bug I want to fill an Uint8Array from a Native Node Module, without Coping Data (share the resource). With plane Electron, I can share the Pointer from the Array to the native code and write directly in it. I tried the same Implementation with electron & capacitor, but the Array stays empty.

To Reproduce Steps to reproduce the behaviour:

Expected behaviour I want to be able to access the same Variables as the Frontend does.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context I see an IPC call happening. I guess this is the Copy step. Is there a way to run everything in the same Thread? (stay in the Electron render thread)

jdgjsag67251 commented 1 year ago

I believe this is impossible with the way that Electron works. If you want to know for sure you could open an issue in the Electron repository.

JuliusSkrisa commented 1 year ago

I think might be possible in versions 1.x of capacitor-community/electron where it used older electron versions. and nodeIntegration was on (even though might not be the best idea to do that even there). But I think its not possible in the latest version, since its serializing all data exchanged between main and renderer process. And it uses channels to exchange data between processes. In my case I had to refactor the code since 1.x version, because I was passing callback from renderer process to the main process. To trigger from there. But that was no longer possible in the latest version.