nut.js icon indicating copy to clipboard operation
nut.js copied to clipboard

Big Sur Segmentation Fault when retrieving window title

Open dwighthouse opened this issue 3 years ago • 8 comments

Version Node v17.0.1 nut.js v2.0.1

Short overview Trying to retrieve title of any window results in Seg Fault and no other information, program ends immediately.

Issue occurs on

  • [ ] Virtual machine
  • [ ] Docker container
  • [x] Dev/Host system

Detailed error description Seg fault is occurring on Big Sur any time I attempt to find a window title, either through getWindows or getActiveWindow.

Steps to reproduce error Run this script:

import { getActiveWindow } from '@nut-tree/nut-js';

(async () => {
    const window = await getActiveWindow();
    const title = await window.title;
    console.log(title);
})();

Expected Result: Terminal

Actual Result: zsh: segmentation fault node index.js

dwighthouse avatar Feb 25 '22 02:02 dwighthouse

Observation: Reproducibly segfaults when executed in Terminal.app, no matter which window is currently active. Runs fine in e.g. iTerm, though

Edit: This was due to my setup. Reproducibly segfaults in any terminal

s1hofmann avatar Mar 03 '22 21:03 s1hofmann

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 26 '22 02:04 github-actions[bot]

Still open

s1hofmann avatar Apr 28 '22 19:04 s1hofmann

I also see this error regardless of the terminal used. Tried in iTerm and got the same error.

mwarger avatar May 04 '22 20:05 mwarger

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jun 04 '22 02:06 github-actions[bot]

Can confirm this issue is happening on Mac M1 using Terminal and iTerm for accessing window titles.

jzombie avatar Jun 12 '22 16:06 jzombie

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jul 13 '22 02:07 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 27 '22 02:07 github-actions[bot]

image Crashing for me too

sublimator avatar Sep 19 '22 07:09 sublimator

Status update:

This issue had me banging my head for several months now. I might have finally tracked down the root cause 💪

Still WIP

s1hofmann avatar Sep 19 '22 21:09 s1hofmann

Great to hear. Liking the lib so far.

sublimator avatar Sep 20 '22 01:09 sublimator

Root cause: Reading the kCGWindowName property requires an application to be given Screen Recording permissions. If this is not the case, it'll just return nil which caused the segfault.

Fixed in release 2.3.0 that just went live.

s1hofmann avatar Sep 22 '22 09:09 s1hofmann

Yay!

sublimator avatar Sep 22 '22 10:09 sublimator