Skip to content

fix(ffi): bound the region pixel diff by share and delta, not absolute counts - #15

Merged
lzwind merged 1 commit into
linuxdeepin:mainfrom
YangtseSu:fix/region-aa-tolerance
Oct 19, 2026
Merged

lzwind merged 1 commit into
linuxdeepin:mainfrom
YangtseSu:fix/region-aa-tolerance

Conversation

@YangtseSu

@YangtseSu YangtseSu commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

real_fixture_region_matches_full_page_and_preserves_cairo_ownership
(crates/rofd-ffi/tests/region.rs) pins the anti-aliasing difference between the
full-page and the region rendering to 32 channels with a per-channel delta of at most
2
. That bound only holds on the font stack it was written on:

environment rect channels differing max delta
Arch Linux, FreeType 2.13 129×71 36 636 21 2
ubuntu-24.04 (GitHub runner), same FreeType 129×71 36 636 42 8

So the test fails on a clean Debian build-dependency environment:

thread 'real_fixture_region_matches_full_page_and_preserves_cairo_ownership' panicked at crates/rofd-ffi/tests/region.rs:201:5:
42 differing channels, max delta 8, first Some((119, 4, 1))

The cause is the one the comment already names — Cairo changes curve edge coverage when
the target extents change — so the difference is anti-aliasing only, and its magnitude
depends on the font stack (fontconfig picks different faces, whose outlines change how
much coverage differs between the two target extents).

Change. Bound the difference by its share of the tile's channels (1 %) and a
per-channel delta of 16, instead of absolute numbers that only hold on one font stack. A
stitching or crop error moves whole pixels, which changes orders of magnitude more
channels with far larger deltas, so the check keeps its meaning; the exact geometric
stitching assertions stay in the renderer tests.

Verification

  • cargo test -p rofd-ffi --test region → ok on Arch; instrumented probe: rect 129×71,
    36 636 channels, 21 differing, max delta 2
  • The same test on a GitHub ubuntu-24.04 runner with the new bound: 42 differing
    channels of 36 636 (0.11 %) and max delta 8 — passes, where the old bound failed
  • cargo fmt --all -- --check clean

Summary by Sourcery

Adjust region rendering diff thresholds to validate meaningful image errors without depending on font-stack-specific anti-aliasing counts.

Bug Fixes:

  • Make the region rendering test robust across font stacks by allowing anti-aliasing differences within a 1% channel share and a per-channel delta of 16.

Enhancements:

  • Retain coverage for detecting substantial stitching or cropping errors while accommodating platform-dependent Cairo anti-aliasing variation.

…e counts

real_fixture_region_matches_full_page_and_preserves_cairo_ownership pins the
anti-aliasing difference between the full-page and the region rendering to 32
channels with a per-channel delta of at most 2, which only holds on the font
stack it was written on: Arch with FreeType 2.13 gives 21 differing channels
with delta <= 2, while ubuntu-24.04 with the same FreeType gives 42 channels
with delta <= 8, so a clean Debian build-dependency environment fails the test
(crates/rofd-ffi/tests/region.rs:201).

Bound the difference by its share of the tiles channels (1%) and a per-channel
delta of 16 instead. A stitching or crop error moves whole pixels, which changes
orders of magnitude more channels with far larger deltas, so the check keeps its
meaning; exact geometric stitching stays covered by the renderer tests.

Verified: cargo test -p rofd-ffi --test region ok on Arch (probe: rect 129x71,
36636 channels, 21 differing, max delta 2) and cargo fmt --all -- --check clean.
YangtseSu added a commit to YangtseSu/rofd that referenced this pull request Oct 15, 2026
The region test bounds an anti-aliasing difference with absolute numbers tuned to
Arch FreeType, so the ubuntu runner legitimately exceeds them (42 channels, delta 8
against a bound of 32 and 2). Run it as its own step with continue-on-error and keep
the rest of the suite gating; upstream PR linuxdeepin#15 turns the bound relative.
@sourcery-ai

sourcery-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the Cairo rendering regression assertion to tolerate environment-dependent anti-aliasing differences while still rejecting crop or stitching errors through a 1% differing-channel limit and a per-channel delta cap.

File-Level Changes

Change Details Files
Make the region-versus-full-page rendering comparison portable across font stacks by using relative and magnitude-based anti-aliasing tolerances.
  • Compute the tile's total channel count from its dimensions.
  • Allow at most 1% differing channels instead of a fixed count.
  • Allow per-channel differences up to 16 instead of 2, while retaining diagnostics and renderer-level stitching coverage.
crates/rofd-ffi/tests/region.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

Hi @YangtseSu. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="crates/rofd-ffi/tests/region.rs" line_range="208" />
<code_context>
     assert!(
-        differences.len() <= 32 && differences.iter().all(|v| v.2 <= 2),
-        "{} differing channels, max delta {}, first {:?}",
+        differences.len() * 100 <= channels && differences.iter().all(|v| v.2 <= 16),
+        "{} differing channels of {channels}, max delta {}, first {:?}",
         differences.len(),
</code_context>
<issue_to_address>
**Localized FFI defects pass**

When an FFI-side region, crop, or stitching regression changes no more than 1% of channels, with each delta at most 16, the `differences.len() * 100 <= channels` check accepts the regression, and `CairoRenderer`'s exact-pixel checks do not exercise this FFI comparison, so the integration test passes and the defect goes undetected.

Restore a tighter changed-channel and per-channel-delta bound so localized regressions fail the FFI test.

Also at `crates/rofd-ffi/tests/region.rs:209`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

assert!(
differences.len() <= 32 && differences.iter().all(|v| v.2 <= 2),
"{} differing channels, max delta {}, first {:?}",
differences.len() * 100 <= channels && differences.iter().all(|v| v.2 <= 16),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Localized FFI defects pass

When an FFI-side region, crop, or stitching regression changes no more than 1% of channels, with each delta at most 16, the differences.len() * 100 <= channels check accepts the regression, and CairoRenderer's exact-pixel checks do not exercise this FFI comparison, so the integration test passes and the defect goes undetected.

Restore a tighter changed-channel and per-channel-delta bound so localized regressions fail the FFI test.

Also at crates/rofd-ffi/tests/region.rs:209.

Prompt for AI agents
In `crates/rofd-ffi/tests/region.rs` at line 208:

**Localized FFI defects pass**

When an FFI-side region, crop, or stitching regression changes no more than 1% of channels, with each delta at most 16, the `differences.len() * 100 <= channels` check accepts the regression, and `CairoRenderer`'s exact-pixel checks do not exercise this FFI comparison, so the integration test passes and the defect goes undetected.

Restore a tighter changed-channel and per-channel-delta bound so localized regressions fail the FFI test.

Also at `crates/rofd-ffi/tests/region.rs:209`.

YangtseSu added a commit to YangtseSu/rofd that referenced this pull request Oct 15, 2026
Merging the workflow onto the release branch left its trigger on
ci/fork-checks, so nothing ran on the branch that actually ships (0 runs for
release/0.4.3-fork.1). Point push at release/* and make a release ref run
strict: no --skip and no continue-on-error steps, because a release branch
carries the fixes (PRs linuxdeepin#14, linuxdeepin#15) that make both upstream-red tests green, so
they gate like everything else. Non-release refs, reachable only through
workflow_dispatch, keep the loose mode: the two tests run as visible,
non-gating steps so a branch's own regressions still fail the run.
@YangtseSu

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

@lzwind
lzwind merged commit f6fb312 into linuxdeepin:main Oct 19, 2026
12 of 13 checks passed
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, YangtseSu

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

YangtseSu added a commit to YangtseSu/rofd that referenced this pull request Oct 19, 2026
…merged

Upstream `main` carries the decoder budget and the region tolerance (PRs linuxdeepin#14 and linuxdeepin#15), so neither previously red test is red anywhere any more and the dev-only distinction between strict and loose checking has no purpose left. The ref matrix loses its `strict` field, the two `continue-on-error` steps go, and FORK.md describes the single mode.
YangtseSu added a commit to YangtseSu/rofd that referenced this pull request Oct 19, 2026
…merged

Upstream `main` carries the decoder budget and the region tolerance (PRs linuxdeepin#14 and linuxdeepin#15), so neither previously red test is red anywhere any more and the dev-only distinction between strict and loose checking has no purpose left. The ref matrix loses its `strict` field, the two `continue-on-error` steps go, and FORK.md describes the single mode.
@YangtseSu
YangtseSu deleted the fix/region-aa-tolerance branch October 19, 2026 09:01
YangtseSu added a commit to YangtseSu/rofd that referenced this pull request Oct 20, 2026
…merged

Upstream `main` carries the decoder budget and the region tolerance (PRs linuxdeepin#14 and linuxdeepin#15), so neither previously red test is red anywhere any more and the dev-only distinction between strict and loose checking has no purpose left. The ref matrix loses its `strict` field, the two `continue-on-error` steps go, and FORK.md describes the single mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants