Skip to content

BUG: Destroy binary dilate and erode progress reporter before final update - #7274

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:binary-morphology-progress-followup
Nov 30, 2026
Merged

hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
dzenanz:binary-morphology-progress-followup

Conversation

@dzenanz

@dzenanz dzenanz commented Nov 30, 2026

Copy link
Copy Markdown
Member

Destroy the BinaryDilate and BinaryErode progress reporter before the final UpdateProgress(1.0f), so its destructor no longer sends observers a second ProgressEvent at 1.0. Addresses hjmjohnson's post-approval review of #7258.

Details
  • PERF: Use scanline iterators in per-pixel filter loops #7258 switched both filters from ProgressReporter to TotalProgressReporter for every loop. Unlike ProgressReporter, it does not set progress to 1 when destroyed, which is why PERF: Use scanline iterators in per-pixel filter loops #7258 added UpdateProgress(1.0f). Its destructor still reports the pixels counted since its last update, and ProcessObject::IncrementProgress sends a ProgressEvent even when progress is already at its maximum.
  • The reporter is held in a std::optional and reset just before the final update. An inner block ending before that line would also work, but would re-indent about 375 lines in each filter.
  • The comment now says the border tracking stage does not report exactly its allotted pixels: in BinaryErode it can report more, so progress there can reach 1.0 before the final update and observers can still see more than one event at 1.0. Changing how that stage counts is left out of this PR.
  • Tests: both tests check that GetProgress() is 1.0 after Update(), and the BinaryDilate test checks that exactly one ProgressEvent arrives at 1.0. That check fails on main (2 events) and passes with this change. All 28 ITKBinaryMathematicalMorphology tests pass with MSVC.
AI assistance
  • Tool: Claude Code (claude-opus-5-5).
  • Role: confirmed the duplicate event with a test that fails on main, wrote the fix and tests from the review comments.
  • Built and tested locally, and reviewed by the author before pushing.

🤖 Generated with Claude Code

…pdate

~TotalProgressReporter() reports the pixels counted since its last
update. Running after UpdateProgress(1.0f), it sent observers a second
ProgressEvent at 1.0.

BinaryErode's border tracking stage can also report more pixels than it
was allotted, so progress there can reach 1.0 before the final update.
The tests check that progress ends at 1.0, and that BinaryDilate sends
one event at 1.0.
@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Filtering Issues affecting the Filtering module labels Nov 30, 2026
@dzenanz
dzenanz marked this pull request as ready for review November 30, 2026 17:09
@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Both filters now destroy TotalProgressReporter before calling UpdateProgress(1.0f), so leftover progress is reported before the final completion event.

  • Binary morphology filters send their final progress update after reporter cleanup.

Acknowledged limitation: dzenanz explicitly deferred changing the erosion border stage's pixel count. That stage can reach full progress early and still cause multiple completion events.

Reviews (1) · Last reviewed commit: "BUG: Destroy binary dilate and erode pro..." · Reviewed by Greptile

@hjmjohnson
hjmjohnson merged commit 29a2f6d into InsightSoftwareConsortium:main Nov 30, 2026
20 checks passed
@dzenanz
dzenanz deleted the binary-morphology-progress-followup branch November 30, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants