Fix electron stability
Closed this issue · 0 comments
Me again. As a follow up to #173 I wasn't able run this module in a stable fashion from inside electron. Besides immediate crashes I came as far a having a first successful render but a crash of the render process afterwards.
After reading a lot of documentation, source code, tutorials and howtos, I came to the conclusion that the used nan module to create the native addon is discouraged now and we better should use node-addon-api. This is because the latter is at least independend of any volatile interface like the v8 types, makes addon initialization safe for multithreaded environments and also reentrant, etc.
So I reworked the addon using that said module and now it works. So far so good.
But: I am using the latest version of node-addon-api (3.0.2 of 2020-09-18 at this point) and using an interface introduced in that release (namely Napi::Addon). I am not quite sure how backwards compatiblity is affected by my choice. Especially I could not find out the minimum required node version for my change.
Anyway, I'll prepare a PR. Feel free to ignore it if my choice isn't in your interest.