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
Electron overriding High DPI support on macOS with SDL #20656
Comments
I tried using the window = fork(require.resolve(this.module_path), [], {
env: { ELECTRON_RUN_AS_NODE: 1 },
}); I noticed the child process does get the var: { ELECTRON_RUN_AS_NODE: '1', __CF_USER_TEXT_ENCODING: '0x1F5:0x0:0x0' } However, it still runs differently than if I just ran the program with node on its own instead via electron. Is this window we're creating inheriting something from the other windows? Some people have suggested that the window created by SDL is inheriting the window that is forking it in the first place -- taking all the Cocoa inherited properties with it. It's unclear to me why it still wouldn't work with high DPI though given that. |
Ok, I think I got to this bottom of this:
So, we have to find a way to pass the true process' path so the program can find the right bundle and Info.plist file such that when calling NSWindow in SDL2 it will display things at High DPI. It'd be nice if Electron handled this part where perhaps it would send the right path along with the fork'd call. macOS does not appear to default to high dpi. |
Solution: Whatever you set in the Info.plist for the main process, equivalently apply it to Electron Helper processes since they have their own Info.plist. We patched this via:
|
did you try loading the native module in the main process instead of the renderer? |
Yes |
Closed by #21872 (comment) |
Preflight Checklist
Issue Details
When running our C++ node addon in Electron high DPI settings/flags are not respected. The node addon on its own works fine until it's packaged with Electron.
Our node addon separately, in another process but called from within Electron, creates a new window with SDL that attempts to be DPI enabled via
SDL_WINDOW_ALLOW_HIGHDPI
We aren't using
new BrowserWindow
and expecting Chrome to resize in this case!Does not work in the following scenario:
electron .
The Key in Info.plist
High Resolution Capable
is set to YES -- electron appears to auto-generate a default info.plist with it. (We do not set anything on our own) nor are we setting--extend-info
Electron Version:
"electron-builder": "^21.2.0",
Operating System:
macOS - 10.14.6
Expected Behavior
The program should be displayed in High DPI mode and respect what is being passed to SDL
For example, we should receive a SDL_WINDOWEVENT that tells us to resize the texture at a new width and height.
Actual Behavior
When moving a program window (not Electron created window) over to a Retina screen (macbook pro), it doesn't receive a new renderer output to resize too and doesn't appear high DPI aware
When we run our node addon separately, moving the window reconfigures the texture each time as soon as we move the screen enough to a different DPI screen.
To Reproduce
Set the following up in SDL:
Questions
electron .
The text was updated successfully, but these errors were encountered: