Skip to content

Error getting focused window (macOS) #183

Closed
@0dm

Description

@0dm

I noticed that record & replay fail when in Google Meets, but this also extends to calls like Discord (with no video being sent)

To reproduce: I just got into an empty discord voice channel and ran NaiveReplay. This still occurs if I am "deafened" (no microphone or audio being transmitted)

An example of the message, followed by a segfault:

2023-05-27 01:36:14.192 | ERROR    | openadapt.window._macos:get_active_window:69 - Error getting focused window
zsh: segmentation fault  python3 -m openadapt.record "testing"

However, the recording still proceeds and stalls at this stage:

2023-05-27 01:36:15.198 | INFO     | __mp_main__:write_events:215 - event_type='window' starting
2023-05-27 01:36:15.221 | INFO     | __mp_main__:write_events:215 - event_type='screen' starting
2023-05-27 01:36:15.228 | INFO     | __mp_main__:write_events:215 - event_type='action' starting

I noticed my fans started spinning more aggressively after failed recordings, and received this from ps

  PID TTY           TIME CMD
2591 ttys000    0:00.13 -zsh
2651 ttys000    0:00.03 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.resource_tracker import main;main(12)
2652 ttys000   12:16.87 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
2653 ttys000   12:21.22 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
2654 ttys000   12:21.63 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
2682 ttys000    0:00.03 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.resource_tracker import main;main(9)
2683 ttys000   12:14.65 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
2684 ttys000   12:14.18 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
2685 ttys000   12:14.90 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
3279 ttys000    0:00.03 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.resource_tracker import main;main(9)
3280 ttys000    1:40.91 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
3281 ttys000    1:40.87 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
3282 ttys000    1:36.87 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
3390 ttys000    0:00.03 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.resource_tracker import main;main(9)
3391 ttys000    0:03.96 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
3392 ttys000    0:04.33 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra
3393 ttys000    0:04.17 /opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python -c from multiprocessing.spawn import spawn_main; spawn_main(tra

Uh oh
should pkill -f python
result:

/opt/homebrew/Cellar/python@3.10/3.10.11/Frameworks/Python.framework/Versions/3.10/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 17 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

(x4),
but processes are all still killed.

Workarounds:
Just leaving the call instantly resolves all issues, but this isn't the best approach.

Possible fixes:

  • Notify the user that something is wrong, and use a fall-back recording method without window states.
  • Kill the process via terminate() / SIGTERM if we failed to capture window state

Best solution would be to get around this entirely, but I'm not entirely sure what is actually causing this, since other actions like streaming music on spotify has no effect on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions