Skip to content

Fix/tethering transient ptp - #22919

Open
rtmongold wants to merge 3 commits into
darktable-org:masterfrom
rtmongold:fix/tethering-transient-ptp
Open

rtmongold wants to merge 3 commits into
darktable-org:masterfrom
rtmongold:fix/tethering-transient-ptp

Conversation

@rtmongold

Copy link
Copy Markdown
Contributor

Summary

Leaving tether mode did not join the camera event or live-view threads, so teardown could race and leave the USB device claimed. Enabling live view on Canon (tested on EOS 7D Mark II and 1300D) could hit PTP Device Busy and be treated as a lost connection, forcing a remount. Tether leave now stops and joins those threads cleanly, unplug uses full gphoto teardown, and Device Busy during live view no longer kills the session; camera-driven property updates are not written back to the camera.

Checklist

  • I have read CONTRIBUTING.md and the coding style.
  • I have not merged master into the topic branch.
  • The pull request is one logical change, and every commit compiles on its own. You may use git rebase --exec 'cmake --build build' master to check this.
  • I ran the relevant tests: unit tests, src/tests/integration/ where the pixelpipe is touched, or darktable-cli as a headless smoke test.
  • New user-visible strings use _(), new preferences are registered in data/darktableconfig.xml.in.
  • A RELEASE_NOTES.md entry was added (only needed if fixing an issue in a release). Do not reference GitHub issues.

Test instructions

Manual tests with a tether-capable camera (Canon EOS 7D Mark II and 1300D
here), darktable -d camctl.

These are the checks that show the old behavior was wrong. A plain
enter/leave without live view often looks fine on master too — that is
not the regression.

A. Live view remount (Device Busy) — main user-visible break

  1. Mount camera → tether → enable live view.
  2. master: often gets PTP Device Busy, then “needs to be remounted” /
    tether bails even though frames may have started.
  3. this PR: live view keeps running; no remount from Device Busy.
    -d camctl may log ignoring transient PTP error instead of tearing
    the session down.

B. Leave tether with live view still on — thread shutdown

  1. Mount → tether → enable live view → leave tether without turning
    LV off first.
  2. master: can hang, leave messy, or leave workers running (no join;
    LV only clears a flag).
  3. this PR: returns cleanly. Log order should be roughly:
    disabling tether mode → Stopping live view →
    exiting camera thread → unlock. No hang.

C. Remount in the same session after tether

  1. Do a tether session (with or without LV), leave cleanly.
  2. Unmount/remount (or unplug/replug) and mount again in darktable
    without restarting the app.
  3. master: camera sometimes stays unusable until restart (incomplete
    teardown / claimed device).
  4. this PR: remount and enter tether again in the same session.

Smoke only (not a before/after proof): enter/leave tether with LV off.
That path often “works” on master; do not treat it as evidence the fix
is a no-op.

Not verified: non-Canon bodies; automated tests for this path.

Leaving tether mode only cleared flags and never joined the event
thread, and live view could be orphaned the same way. Stop live view
first while the event thread can still release the preview handshake,
then join the event thread, drain leftover jobs, and use full gphoto
destroy when a mounted camera disappears so the device is released.
Canon bodies often return 0x2019 while live view is opening and
properties settle. Treating every PTP-tagged error as a dead connection
forced a remount. Ignore Device Busy, block property combobox write-back
when the camera itself pushed the change, and skip no-op property sets.
@TurboGit TurboGit added this to the 5.8 milestone Nov 2, 2026
@TurboGit TurboGit added the bugfix pull request fixing a bug label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants