Repository navigation
fix(reports): detect perceptually blank screenshots - #44034
rebenitez1802 merged 8 commits into
Conversation
Code Review Agent Run #d71270Actionable Suggestions - 0Additional Suggestions - 3
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #44034 +/- ##
==========================================
+ Coverage 79.88% 79.90% +0.02%
==========================================
Files 2915 2916 +1
Lines 170737 170845 +108
Branches 39566 39578 +12
==========================================
+ Hits 136391 136519 +128
+ Misses 31829 31811 -18
+ Partials 2517 2515 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ptually-blank-reports # Conflicts: # superset/utils/webdriver.py
| perceptually_blank = ( | ||
| near_white_ratio >= SCREENSHOT_BLANK_NEAR_WHITE_PIXEL_RATIO | ||
| and luminance_stddev <= SCREENSHOT_BLANK_MAX_LUMINANCE_STDDEV | ||
| and entropy <= SCREENSHOT_BLANK_MAX_ENTROPY | ||
| ) |
There was a problem hiding this comment.
Suggestion: The perceptual rule classifies any image with fewer than 0.5% dark pixels as blank when its remaining pixels are near-white, rejecting legitimate sparse charts or thin text. [incorrect condition logic]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/utils/screenshot_utils.py
**Line:** 186:190
**Comment:**
*Incorrect Condition Logic: The perceptual rule classifies any image with fewer than 0.5% dark pixels as blank when its remaining pixels are near-white, rejecting legitimate sparse charts or thin text.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Addressed in 6a9011b. Blankness is no longer decided by near-white coverage alone: the revised detector requires low luminance variance and low entropy at both 256px and 1024px sampling scales, plus either high mean luminance or exact uniformity. Capture rejection is also DOM-state-aware, so terminal empty/error states are accepted. Added realistic readable empty-state, sparse-content, tall-report, and RGB 239 background regression cases.
| page.bring_to_front() | ||
| page.evaluate( | ||
| """() => { | ||
| window.scrollBy(0, 1); | ||
| window.scrollBy(0, -1); | ||
| return new Promise(resolve => requestAnimationFrame( | ||
| () => requestAnimationFrame(resolve) | ||
| )); | ||
| }""" | ||
| ) |
There was a problem hiding this comment.
Suggestion: page.evaluate() waits for two animation frames without a timeout, so a wedged page can block standard screenshot retries beyond the report deadline. [api mismatch]
Assessment: 🟠 Major · 🔁 Occurrence: Sometimes
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** superset/utils/webdriver.py
**Line:** 324:333
**Comment:**
*Api Mismatch: `page.evaluate()` waits for two animation frames without a timeout, so a wedged page can block standard screenshot retries beyond the report deadline.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fixThere was a problem hiding this comment.
Addressed in 6a9011b. The standard repaint no longer returns a Promise from page.evaluate(). It schedules a completion flag and waits with page.wait_for_function() using a five-second timeout capped by the remaining report deadline and post-capture reserve. Playwright repaint failures are logged, while report-budget and Celery soft-time-limit exceptions propagate. Added bounded-timeout and SoftTimeLimitExceeded regression tests.
|
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR). Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
rebenitez1802
left a comment
There was a problem hiding this comment.
Approve — thorough, well-tested fix that closes the reported multi-tone blank-PDF incident. I verified the incident raster (stddev 2.53 / entropy 0.803 / mean 253.61) now classifies blank via the new path, CI is green, and the security model is untouched. I ran a multi-lens review (correctness / control-flow / false-positive / tests / perf) with adversarial verification of each finding — nothing blocking.
Three non-blocking medium items left inline for you to decide on; they all revolve around the fail-closed path's false-positive surface (legit sparse/light reports) and its test coverage. There are also a few low nits I intentionally kept out of the PR (repaint except type differs between the two paths; standard path fails-open on a content-probe error while the tiled path fails-closed; dark-theme blanks aren't detected; getcolors(maxcolors=pixel_count) drops the old fast-bail; the retry/repaint loop is duplicated across the two paths; dataclasses.replace for the frozen-dataclass rebuild) — happy to drop those in a follow-up comment if useful. Your call on all of it.
| luminance_stddev <= SCREENSHOT_BLANK_MAX_LUMINANCE_STDDEV | ||
| and entropy <= SCREENSHOT_BLANK_MAX_ENTROPY | ||
| ) | ||
| perceptually_blank = low_information and ( |
There was a problem hiding this comment.
🟡 Medium (non-blocking — your call): this fail-closed rejection can deterministically fail a narrow class of legitimate light/sparse reports, with no operator opt-out. perceptually_blank = (stddev≤8 and entropy≤1.5) and (mean≥250 or dominant≥0.995) — common charts survive (line/scatter with axes, Big Number, bordered tables, all verified), but genuinely sparse low-chrome near-white content (a sparse scatter with minimal axes, a borderless text table, a very-light pastel area chart) reads blank at both sample scales → 3 retries over identical pixels → ScreenshotBlankCaptureError → ReportScheduleScreenshotFailedError on every run, and there's no config flag to turn perceptual rejection off. Worth considering a config/feature flag as a safety valve, and/or gating on a resolution-independent ink fraction rather than the DPI-sensitive global stddev/entropy. Not blocking the approval.
There was a problem hiding this comment.
Addressed the false-positive surface in 0c283b8 without adding a global opt-out. The classifier now measures structural edge density at both sampling scales, so light/thin chart and table marks prevent a blank classification even when global luminance variance and entropy remain low. The actual incident raster remains classified blank (stddev=2.525, entropy=0.801, structural_edge_ratio=0.00000). I’m intentionally not adding a bypass flag because disabling validation would restore silent blank delivery; the more targeted classifier correction preserves fail-closed behavior.
| log_context=log_context, | ||
| ) | ||
|
|
||
| if report_execution_context and contentful_tiles_captured: |
There was a problem hiding this comment.
🟡 Medium (non-blocking): the combined-image check gates only on contentful_tiles_captured, not on what fraction of the page is actually content. A tall / sparse-ink dashboard (a few real charts among empty / spacer / markdown tiles, or many low-chrome charts) can wash out at the 1024px downsample so the combined image scores blank and raises here — even though every tile individually passed its per-tile check. This is new behavior (base master just returned the combined image). Consider basing the combined decision on aggregate non-near-white ink (or on the per-tile results already computed), or making the combined check advisory/log-only once tiles have individually passed. Your call.
There was a problem hiding this comment.
Fixed in 0c283b8. Once contentful tiles have individually passed capture validation, the combined-image classification is now advisory/log-only (report_capture_blank_combined_retained) rather than a second rejection gate. This avoids a 1024px composite downsample overriding stronger per-tile evidence on tall or sparse dashboards.
|
|
||
| assert is_blank is False | ||
|
|
||
| def test_tall_sparse_report_with_content_is_not_blank(self): |
There was a problem hiding this comment.
🟡 Medium (non-blocking): this "sparse" test passes only because its strokes are thick and black — swap them to thin/light and it flips to is_blank=True. Together with _create_chart_like_tile (a dense ~60%-colored block), the suite has no fixture asserting that a realistic light thin-stroke line/scatter or a sparse table at report resolution is not blank — so the false-positive class flagged on screenshot_utils.py line 190 would ship green. Worth adding light thin-stroke line/scatter + sparse-table fixtures at ~3000×1200 (and pixel_density=2) that assert is_blank is False, and using them to calibrate the thresholds. Your call.
There was a problem hiding this comment.
Addressed in 0c283b8. Added 3000x1200 fixtures for a light, thin-stroke line/scatter-style chart and a sparse light table. Both exercise the new structural-edge signal and assert non-blank classification. The actual customer blank raster was also rechecked and still classifies blank.
|
@rebenitez1802 Thanks — I went through the remaining low nits as well. Implemented in
Intentionally left unchanged:
Validation: 129 affected utility tests pass; Ruff and mypy pass. The actual incident raster remains classified blank with |
rebenitez1802
left a comment
There was a problem hiding this comment.
LGTM 🎉 Re-reviewed 0c283b88. The structural-edge signal resolves the sparse/light false-positive cleanly (realistic charts with any chrome now read non-blank, while the incident raster and hard/smooth near-white blanks stay caught), the combined-image check is now advisory, and the exception/SoftTimeLimitExceeded handling and dataclasses.replace cleanups look good. I also went through your deferrals — all reasonable; agreed that keeping getcolors at full enumeration is correct (a 256-colour fast-bail would actually miss high-dominant near-white blanks), and that a dark-theme heuristic should wait for a real failure raster.
Non-blocking nit for whenever: the new except SoftTimeLimitExceeded: raise guards the outer handler, but the two inner except Exception blocks around the page.evaluate calls (screenshot_utils.py ~1125 and ~1333) can still swallow a soft-timeout that fires during those windows — a one-line except SoftTimeLimitExceeded: raise before each would fully close the propagation guarantee. Not a blocker. Nice work.
|
Bito Automatic Review Skipped – PR Already Merged |
SUMMARY
Hardens scheduled report screenshot validation after a real blank PDF bypassed the existing exact-color heuristic. The incident artifact contained multiple near-white backgrounds, so no single RGB value reached the old 99.5% threshold even though the page contained no meaningful content.
This change:
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable; backend screenshot validation and logging only.
TESTING INSTRUCTIONS
Coverage includes:
Local focused result: 82 passed. Ruff 0.9.7 formatting/check and mypy passed. The real incident PDF raster is classified blank with dominant ratio 0.76750, near-white ratio 1.0, mean luminance 253.61, standard deviation 2.53, and entropy 0.803.
ADDITIONAL INFORMATION