-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Problem OSX(Catalina) plugin and NodeJS12+ #1981
Comments
I don't think we have have enough information to be helpful here. Your screen.c isn't addon code, is it printing those values in c++ or is that what's returning to JavaScript somewhere in main.cpp? |
Thank you for your comment @rvagg I've updated my main post |
Would it be possible to put this code into a Travis CI test or a GitHub Actions test? |
OK, this is pretty interesting, can confirm that something is screwy. My minimal repro: package.json: {
"name": "addon",
"gypfile": true,
"dependencies": {
"node-addon-api": "~2.0.0"
}
} binding.gyp: {
'targets': [{
'target_name': 'testlib',
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
},
'include_dirs': [
'<!@(node -p "require(\'node-addon-api\').include")',
],
'dependencies': ["<!(node -p \"require('node-addon-api').gyp\")"],
'conditions': [
['OS == "mac"', {
'include_dirs': [
'System/Library/Frameworks/ApplicationServices.framework/Headers'
],
'link_settings': {
'libraries': [
'-framework ApplicationServices',
]
}
}],
],
'sources': [
'main.cpp',
]
}]
} main.cpp: #include <napi.h>
#include <ApplicationServices/ApplicationServices.h>
Napi::Object getScreenSize(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::Object obj = Napi::Object::New(env);
CGDirectDisplayID displayID = CGMainDisplayID();
obj.Set("width", CGDisplayPixelsWide(displayID));
obj.Set("height", CGDisplayPixelsHigh(displayID));
fflush(stdout);
return obj;
}
Napi::Object InitAll(Napi::Env env, Napi::Object exports) {
return Napi::Function::New(env, getScreenSize);
}
NODE_API_MODULE(NODE_GYP_MODULE_NAME, InitAll) Test with: Rebuild with On Node 10.x it prints out a proper resolution, on 13.x it prints out Minimal direct application to sanity check: run.cpp #include <stdio.h>
#include <ApplicationServices/ApplicationServices.h>
int main() {
CGDirectDisplayID displayID = CGMainDisplayID();
printf("{ width: %lu, height: %lu }\n", CGDisplayPixelsWide(displayID), CGDisplayPixelsHigh(displayID));
fflush(stdout);
return 0;
} compile with: @nodejs/addon-api @nodejs/n-api anyone care to take a poke at this one? I'm not sure where to go. Related to how we build Node now, with the libnode setup perhaps? Or is there some flag we're setting now that is changing the build enough for this to be different? The only stand-out difference I can see in common.gypi is |
I was actually creating the repository but thank you @rvagg this is exactly the problem I have. I just want to add that it is working fine on linux with node 12+ and the following code Display *display = XGetMainDisplay();
const int screen = DefaultScreen(display);
return MMSizeMake((size_t)DisplayWidth(display, screen),
(size_t)DisplayHeight(display, screen)); |
Doing a
And the Then there's this: if I compile the addon with 13.x and run it against both 13.x and 10.x, it works with 10.x but doesn't with 13.x. So I guess that places the blame in Node itself, and/or how it's built:
|
@NickNaso Any thought on that one? |
Alas, I think this requires an OSX laptop, which I do not have 🙁 |
Hi everybody,
|
Travis CI and GitHub Actions both have Macs... Can we create a test that fails there? |
@cclauss Here's a reproducible example with the travis tests failing on node 12+ |
Confirmed issue related to libuv/libuv#2566. It could be reproduced on Node.js v10 by setting the |
This was fixed a while ago in libuv (or fixed... it wasn't really a libuv issue to start with but that aside) so I'm going to close this out. |
I have a problem when using a C++ native module on Nodejs 12 and above, the function always returns 0 instead of the expected value
Binding.gyp:
screen.c:
main.cpp:
Output 11 and below:
Output Nodejs 12+:
I've added more information about the code, this might be helpful.
I don't really know if it is a problem about
node-gyp
ornapi
Any ideas?
PS: It is working well on linux with a X11 code
Regards
The text was updated successfully, but these errors were encountered: