Skip to content
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

Making robotjs context-aware #640

Closed
wants to merge 2 commits into from
Closed

Making robotjs context-aware #640

wants to merge 2 commits into from

Conversation

Maltroth
Copy link

@Maltroth Maltroth commented Jan 9, 2021

Issue

This is an attempt to fix #580 and make robotjs context-aware and usable in the latest versions of Electron:

[1] (node:82611) Electron: Loading non-context-aware native module in renderer: '[...]/electron-app/node_modules/robotjs/build/Release/robotjs.node'. This is deprecated, see https://github.com/electron/electron/issues/18397.

Reproduceble just by requiring robotjs anywhere in an Electron >= 9.0.0 app.

Electron and native apps

  • Electron 9 switched app.allowRendererProcessReuse to true by default, making robotjs throw a deprecated error when instantiated (workaround is to put this value to false)
  • Electron 10 will deprecate the ability to switch manually this value
  • Electron 12 will remove the ability to switch manually this value

This means robotjs will simply stop working on Electron in the future.

Source: electron/electron#18397

Changes

Context-awareness was added to node since version 10, to keep robotjs backward-compatible, I've put the new initialization in a version condition.

Tests

I tested on an Electron 9.4.0 app: it got rid of the error and I was able to use robotjs.


Disclaimer: I'm not a C or C++ developer at all, I would need review so I'm not introducing something unwanted. Based myself on https://nodejs.org/api/addons.html#addons_context_aware_addons.

@Maltroth
Copy link
Author

Maltroth commented Jan 9, 2021

Seems to have outdated dependencies, there are a lot of errors or deprecated warnings on TravisCi for node.h and v8.h. Fail only on latest stable node 15.5.1 on linux.

Seems the case on all recent pull requests.

@malandles malandles closed this by deleting the head repository Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

This module is not context aware and requires allowRendererProcessReuse= false
3 participants