Skip to content

Cancel FFmpeg library work when the dialog closes - #136

Draft
Blackspirits wants to merge 1 commit into
audit/ffmpeg-libs-transactional-install-88f1from
audit/ffmpeg-libs-close-cancel-dd7e
Draft

Blackspirits wants to merge 1 commit into
audit/ffmpeg-libs-transactional-install-88f1from
audit/ffmpeg-libs-close-cancel-dd7e

Conversation

@Blackspirits

@Blackspirits Blackspirits commented Sep 15, 2026

Copy link
Copy Markdown
Owner

Purpose

Dependent lifecycle follow-up to #135 ("Install verified FFmpeg libraries transactionally").

#134 verifies the downloaded archive and #135 makes installation rollback-safe. This tranche closes the remaining dialog-lifetime gap: closing the FFmpeg libraries window through the title-bar X must cancel the same work as the explicit Cancel/Escape paths and must not leave a partial ZIP in the data folder.

Current upstream SubtitleEdit/subtitleedit main was rechecked at d6917286e355976da953d0ee22208b4bf9461699; its latest change is unrelated to this downloader.

Finding fixed

DownloadFfmpegLibsViewModel implements IClosingCleanup, but OnClosingCleanup() previously only stopped/disposed its polling timer.

Closing the window with the title-bar X could therefore leave the HTTP/hash task running, leave a partial/full ZIP in Se.DataFolder, and allow already-started unpack/install work to outlive the window.

Fix

  • make _done visible across timer/UI threads;
  • centralize cancellation in CancelPendingWork();
  • Cancel/Escape and window cleanup cancel the same token used by download/hash and Install verified FFmpeg libraries transactionally #135 installation;
  • make cleanup idempotent through an interlocked gate;
  • stop the indeterminate progress helper during cancellation;
  • refuse to start it after cancellation;
  • observe the download task asynchronously and delete the temp ZIP once its file handle is released;
  • retain Install verified FFmpeg libraries transactionally #135 rollback semantics if close lands during installation.

Normal successful close remains safe and idempotent.

Regression coverage

Tests pin that:

  • OnClosingCleanup() cancels a still-running service token;
  • temp cleanup waits for a pending task before deleting the ZIP;
  • faulted tasks are observed during cleanup and still have their ZIP removed;
  • the blocking wait in the lifecycle regression participates in xUnit cancellation, so this tranche adds no compiler/analyzer warning.

Scope / branch state

  • dependency/base PR: Install verified FFmpeg libraries transactionally #135
  • base HEAD: dd7e85e4319154aaf3105f85e745509ea902c4dc
  • HEAD: eed96e1a1c5f3c57411293fdd3ee56316c385ef0
  • 1 commit
  • 2 files
  • +142 / -11
  • current upstream main checked: d6917286e355976da953d0ee22208b4bf9461699
  • audit draft only; no merge/promotion intended

AI assistance: ChatGPT was used for adversarial window-close/timer/task lifecycle review, cancellation race modelling and temporary-file cleanup regression design.

Final CI

Authoritative run: SubtitleEdit#273 on eed96e1a1c5f3c57411293fdd3ee56316c385ef0

  • SeConv: 488 passed / 2 skipped / 0 failed
  • LibUiLogic: 905 passed / 0 skipped / 0 failed
  • LibSE: 2017 passed / 0 skipped / 0 failed
  • UI: 5240 passed / 9 skipped / 0 failed
  • build: 0 errors / 7 pre-existing warnings
  • retry step skipped
  • failure-artifact upload skipped

Final adversarial review was performed on this exact HEAD after CI; no blocker found.

@Blackspirits
Blackspirits force-pushed the audit/ffmpeg-libs-close-cancel-dd7e branch from f7a3ce3 to eed96e1 Compare September 15, 2026 20:31

@Blackspirits Blackspirits left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final adversarial review on eed96e1a1c5f3c57411293fdd3ee56316c385ef0 after CI SubtitleEdit#273: no blocker found. Verified X/Cancel/Escape converge on the same cancellation token; an already-running timer callback can no longer outlive the dialog without observing cancellation; temporary ZIP cleanup waits for the download task to release the file; #135 supplies rollback if cancellation lands during install. The earlier xUnit1051 warning was removed before this final run. No merge/promotion performed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant