Skip to content

Retake visual screenshots that differ from the baseline or are new - #59408

Open
robhogan wants to merge 4 commits into
mainfrom
robhogan/visual-retake
Open

robhogan wants to merge 4 commits into
mainfrom
robhogan/visual-retake

Conversation

@robhogan

Copy link
Copy Markdown
Collaborator

System UI can briefly cover the app during visual capture. On iOS 26 that's the Apple Intelligence notification shown shortly after boot, which got published as a baseline on main and failed #58945 with a diff it had nothing to do with. Two more baselines were spoiled by flows racing the UI. I've deleted all three by hand.

This retakes, once, any screenshot that differs from the nearest baseline or has none, before upload:

  • A changed screenshot is replaced only if its retake matches the baseline, so real changes still fail.
  • A new screenshot is marked unstable unless both captures are identical. The report says so, and it isn't published as a baseline.

Screenshots that already match aren't retaken, so a clean run costs nothing extra.

Changelog: [Internal]

Test plan:
New unit tests. Ran the retake step against the real bucket with Maestro stubbed, with one spoiled and two new screenshots, and it replaced, kept and flagged them as above. First CI run is this PR's own Test All.

System UI can briefly cover the app during capture, for example the Apple Intelligence notification iOS shows shortly after boot. A covered screenshot published as the baseline from `main` fails every PR based on that commit, and three baselines on `main` were spoiled this way or by flows racing the UI.

After capture, `capture.js` now finds the nearest baseline over the public bucket URL and reruns, once and after a short delay, only the flows whose screenshots differ from it or have no baseline:

- A changed screenshot is replaced by its retake only if the retake matches the baseline, so a real change still fails.
- A new screenshot is unstable unless both captures are identical. The manifest marks it, the report says so, and compare doesn't publish it as the baseline.

Screenshots that already matched are never retaken. The step is skipped without a baseline or `VISUAL_PUBLIC_BASE_URL`.

Changelog: [Internal]
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 23, 2026
@robhogan
robhogan requested a review from cortinico October 23, 2026 15:27
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 23, 2026

@cortinico cortinico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@robhogan Minor comment but code looks good as is 👍

if (baseline == null) {
return {
unstable: [],
lines: [`No baseline for \`${environmentKey}\`, so nothing was retaken.`],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't we retake pictures even if the baseline is empty? That would make sure we don't accidentally pollute the baseline with flaky screenshots

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah agreed - tbh I thought this was covered already. Done now.

@cortinico

Copy link
Copy Markdown
Contributor

@robhogan CI is red

@robhogan

robhogan commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

@robhogan CI is red

I think that's unrelated. open-example.yml has been failing on main since #59488, and the others are failures to download Hermes artefacts from repo.reactnative.dev.

I've incorporated a fix for open-example.yml into this branch to test CI but it probably ought to be fixed separately.

This branch has not been deployed

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants