fix(screenshots): report the PNG comparison memory allowance (#15217)

* fix(screenshots): report the PNG comparison memory allowance

* style(screenshots): format memory allowance assertion
This commit is contained in:
HolyDEEW authored and GitHub committed 2026-11-30 19:08:39 +08:00
1 parent 60de294646
commit 6ec105be6d
4 files changed
+36 -5

No files matched your search

@@ -280,6 +280,13 @@
"reason": "`fixedNativeAllowance` relays the allowance its caller names."
}
},
"src/domain/pngVisualDiff.ts": {
"\"The screenshot comparison working-memory allowance\"": {
"class": "pending",
"issue": 14234,
"reason": "The 256 MiB PNG comparison memory estimate is an REA policy without a per-call control; this refusal previously had only prose recovery."
}
},
"src/domain/xmlDocument.ts": {
"XML_ELEMENT_DEPTH_ALLOWANCE.name": {
"class": "representation",
@@ -16,7 +16,6 @@
"src/desktop/BuildComputerController.ts": 2,
"src/domain/apiContract/GraphqlInventory.ts": 1,
"src/domain/apiContract/parseApiContract.ts": 1,
"src/domain/pngVisualDiff.ts": 1,
"src/hopper/HopperCallerReconciliation.ts": 1,
"src/il2cpp/Il2cppMetadataProvider.ts": 2,
"src/javascript/analysis/JavaScriptAnalysisTransfer.ts": 1,
+18
View File
@@ -8,6 +8,7 @@ import {
AnalysisResourceConstraintError,
AnalysisTargetFailureError,
} from "./analysisErrorCore.js";
import { projectAnalysisError } from "./analysisErrorProjection.js";
import {
compareWebScreenshotsInputSchema,
createWebScreenshotArtifact,
@@ -243,6 +244,23 @@ describe("PNG comparison memory budget", () => {
after_dimensions: { width: 0x7fffffff, height: 1 },
},
});
if (!(cause instanceof AnalysisResourceConstraintError)) throw cause;
const projected = projectAnalysisError(cause);
expect(projected.retryable).toBe(false);
expect(projected.details?.refusal).toEqual({
kind: "fixed_ceiling",
operation: "compare_web_screenshots",
allowance: "The screenshot comparison working-memory allowance",
allowance_kind: "bytes",
limit: 256 * 1024 * 1024,
unit: "bytes",
narrowing:
"Capture smaller screenshots or reduce their viewport dimensions.",
});
expect(projected.remediation.action).toContain("fixed byte allowance");
expect(projected.remediation.action).toContain(
"Capture smaller screenshots",
);
}
});
});
+11 -4
View File
@@ -16,6 +16,7 @@ import {
readPngIhdrFacts,
} from "./pngHeader.js";
import { BinaryReader } from "./binaryContainer.js";
import { fixedAllowanceOptions } from "./fixedAllowanceRemediation.js";
interface DecodedPng {
readonly width: number;
@@ -340,10 +341,16 @@ const pngWorkingMemoryError = (
after_dimensions:
after === null ? null : { width: after.width, height: after.height },
},
{
remediationAction:
"Compare smaller screenshots or reduce their viewport dimensions before capture.",
},
fixedAllowanceOptions(
"The screenshot comparison working-memory allowance",
"bytes",
{
limit: PNG_COMPARISON_WORKING_MEMORY_BYTES,
unit: "bytes",
narrowing:
"Capture smaller screenshots or reduce their viewport dimensions.",
},
),
);
const inflatePng = (compressed: Buffer, maxOutputLength: number): Buffer => {