ActivityWatch / ActivityWatch/aw-watcher-window

macOS jxa strategy: multiprocessing child processes crash with unrecognized arguments, killing the watcher

Offen
#133 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
129
Forks
81
Ø Merge
2 T. 10 Std.
Gemergte PRs (30 T.)
4

Beschreibung

## Description

On macOS, when using the `jxa` strategy mentioned in [#1141](https://github.com/ActivityWatch/activitywatch/issues/1141) (or `applescript`), the `aw-client` library spawns child processes via Python's `multiprocessing` module. These child processes inherit the parent's command-line arguments, which include multiprocessing-specific flags like `--multiprocessing-fork tracker_fd=7 pipe_handle=9` and `-B -S -I -c from multiprocessing.resource_tracker import main;main(6)`.

`aw-watcher-window`'s argparse rejects these unrecognized arguments, causing the child processes to crash. This eventually corrupts or kills the parent process, causing the window watcher to stop collecting data entirely.

## To Reproduce

1. Set `strategy_macos = "jxa"` in `aw-watcher-window.toml`
2. Start ActivityWatch
3. Observe that aw-watcher-window starts and sends heartbeats
4. After ~15 minutes, aw-watcher-window stops (crashed by multiprocessing child process failure)

## Expected behavior

The watcher should either:
- Ignore unrecognized arguments in multiprocessing child processes
- Use `spawn` multiprocessing context instead of `fork` (which doesn't inherit argv)
- Or handle this in `aw-client`'s queued client implementation

## Actual behavior

The child processes crash with:
```
usage: aw-watcher-window [-h] [--host HOST] [--port PORT] [--testing]
[--exclude-title]
[--exclude-titles EXCLUDE_TITLES [EXCLUDE_TITLES ...]]
[--verbose] [--poll-time POLL_TIME]
[--strategy {jxa,applescript,swift}]
aw-watcher-window: error: unrecognized arguments: --multiprocessing-fork tracker_fd=7 pipe_handle=9
aw-watcher-window: error: unrecognized arguments: -B -S -I -c from multiprocessing.resource_tracker import main;main(6)
```

## Environment

- **OS**: macOS Sequoia 15.x
- **ActivityWatch version**: v0.13.2
- **Strategy**: jxa (also affects applescript)

## Additional context

This blocks the workaround for #121 (swift exclude_title/exclude_titles). The jxa fallback crashes due to this multiprocessing bug, making title exclusion impossible on macOS.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.