Skip to content

fix(reports): wait for ECharts paint before capturing report screenshots - #43077

Merged
aminghadersohi merged 5 commits into
masterfrom
fix-reports-echarts-paint-readiness
Aug 18, 2026
Merged

aminghadersohi merged 5 commits into
masterfrom
fix-reports-echarts-paint-readiness

Conversation

@eschutho

@eschutho eschutho commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Scheduled dashboard reports (and the report screenshot path generally) can deliver an image with blank chart regions. The non-tiled readiness gate added in #42624 / #42253 treats a chart holder as rendered as soon as .slice_container is present with no .loading. But .slice_container mounts when the chart's data arrives — before the ECharts canvas is actually drawn — so a full_page capture can fire on an empty canvas.

There is no existing "render finished" signal for screenshots (see the comment in Echart.tsx that disables animation for exactly this reason). chartStatus === 'rendered' / onRenderSuccess both fire on loadable module-load, before paint. The only signal that guarantees the canvas is painted is ECharts' own finished event.

Fix

  • Frontend (plugin-chart-echarts/.../Echart.tsx): tag the canvas host with the runtime class echarts-host, and add echarts-render-finished only in the ECharts finished event (cleared before each setOption). Classes are used because production strips data-test.
  • Readiness gate (screenshot_utils.py): a holder that still contains an unpainted .echarts-host is non-terminal (new mounted_unpainted state) — the gate waits for it and fails loud on timeout rather than capturing blank. Applied to both the dashboard holder gate and the single chart-container gate.

Only ECharts hosts are gated. DOM/SVG vizzes paint synchronously on React commit, and non-ECharts canvas vizzes (deck.gl, mapbox, OpenLayers) have no .echarts-host, so they are unaffected (and the gate never waits on them — no risk of hanging those reports). Giving those canvas vizzes their own completion markers is a natural follow-up.

This is complementary to #42901 (which grows the viewport so off-screen holders mount): that ensures holders are present; this ensures they are painted before capture.

Testing

  • Added a unit test asserting the readiness predicates and diagnostics key on the paint marker.
  • The readiness predicate JS was verified in a headless browser against a synthetic DOM: an in-viewport unpainted ECharts host makes the report gate return false; a painted host passes; DOM/non-ECharts holders are unchanged; off-screen holders are still skipped.
  • The finished-means-painted premise was verified directly against echarts 5.6 (the finished event fires only once the canvas is fully drawn, with animation on or off).

Additional info

  • Jest test for the paint marker — Echart.test.tsx asserts the canvas host is tagged with echarts-host and is only flagged echarts-render-finished on the ECharts finished event.
  • Follow-up (not in this PR): an end-to-end report-capture check in CI, to guard the gate against regressions in a real browser render.

🤖 Generated with Claude Code

Scheduled dashboard reports could deliver a screenshot with blank chart
regions. The readiness gate treated a holder as "rendered" once
.slice_container was present, but that mounts when data arrives -- before the
ECharts canvas is drawn -- so the capture could fire on an empty canvas.

Tag the ECharts host .echarts-host and add .echarts-render-finished only in
the ECharts finished event, the single signal that the canvas is fully
painted (chartStatus/onRenderSuccess both fire pre-paint). The readiness gate
now treats a holder with an unpainted host as non-terminal (mounted_unpainted)
and waits for it, failing loud on timeout instead of capturing blank. Applies
to the dashboard gate and the single chart-container gate.

Only ECharts hosts are gated: DOM/SVG vizzes paint on commit and non-ECharts
canvas vizzes have no .echarts-host, so they are unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Verifies the host carries echarts-host and that echarts-render-finished is
set only when the ECharts finished event fires (not on mount/setOption).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Aug 11, 2026
@codecov

codecov Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.56%. Comparing base (af258c2) to head (8857e94).
⚠️ Report is 98 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43077      +/-   ##
==========================================
+ Coverage   66.00%   66.56%   +0.56%     
==========================================
  Files        2866     2868       +2     
  Lines      162263   163128     +865     
  Branches    37346    37542     +196     
==========================================
+ Hits       107097   108590    +1493     
+ Misses      53100    52409     -691     
- Partials     2066     2129      +63     
Flag Coverage Δ
hive 38.17% <100.00%> (-0.01%) ⬇️
javascript 73.64% <100.00%> (+<0.01%) ⬆️
mysql 57.83% <100.00%> (+0.07%) ⬆️
postgres 57.87% <100.00%> (+0.05%) ⬆️
presto 40.11% <100.00%> (-0.02%) ⬇️
python 59.26% <100.00%> (+1.22%) ⬆️
sqlite 57.51% <100.00%> (+0.07%) ⬆️
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Import order, prettier formatting, and jest-dom toHaveClass. No logic change.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@netlify

netlify Bot commented Aug 11, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit ca817f1
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7bb4e6515f6d0008285e11
😎 Deploy Preview https://deploy-preview-43077--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

eschutho and others added 2 commits August 14, 2026 23:37
Fixes the failing pre-commit CI check (ruff-format) on the new test file.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The PR rewrite of Echart.test.tsx dropped tests that still cover live code:
the isReportScreenshotMode() standalone-mode matrix, the animation
disable/keep tests, and the query-event-handler replacement test. Restore
them (from the pre-PR file) and keep the two new paint-marker tests, so the
suite exercises both the readiness marker and the pre-existing behavior.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@eschutho
eschutho marked this pull request as ready for review August 15, 2026 00:04
@dosubot dosubot Bot added alert-reports Namespace | Anything related to the Alert & Reports feature change:frontend Requires changing the frontend viz:charts:echarts Related to Echarts labels Aug 15, 2026
@bito-code-review

bito-code-review Bot commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8d38b6

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: 5c03640..8857e94
    • superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.test.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
    • superset/utils/screenshot_utils.py
    • tests/unit_tests/utils/test_screenshot_utils.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@sadpandajoe

Copy link
Copy Markdown
Member

@fitzee this PR may be related to things you're looking at

@aminghadersohi aminghadersohi 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.

Reviewed at 8857e94c3255167919b198aeae5ad2cb4d0372ec. Clean, well-documented cross-stack change — the paint-marker contract between Echart.tsx and screenshot_utils.py is sound and the inline rationale comments make it easy to follow. LGTM. A few non-blocking notes:

Readiness gate now requires paint, and the timeout path fails loudly (not silently). REPORT_CHART_HOLDERS_READY_JS / CHART_CONTAINER_READY_JS re-raise on timeout ("aborting before capture or delivery"), so an ECharts host that mounts but never fires finished will hang until timeout and abort the report rather than capture a blank tile. This is fine as designed: (a) the raise-and-abort is pre-existing behavior (#38130/#38441), the PR only adds one more readiness conjunct; (b) it fails loudly with the new mounted_unpainted diagnostic in the WARNING log, so it's diagnosable rather than a silent drop; (c) finished is registered before any setOption runs (init effect registers the handler, then flips didMount; the setOption effect is didMount-gated, and init() alone doesn't paint), so the "event fires before handler attached" race doesn't apply; and (d) screenshot mode disables animation (animationDuration: 0), so finished fires promptly. Worth being aware that a genuine mid-render ECharts failure now aborts the report instead of delivering a broken tile — that's the intended "fail loudly rather than ship a blank chart" tradeoff.

Minor asymmetry between the two gates. The dashboard holder gate short-circuits error/empty to ready regardless of paint — hasErrorOrEmpty || (hasSliceContainer && !hasUnpaintedEchart) (screenshot_utils.py:185-186) — while the standalone-chart gate applies the unpainted check unconditionally: ... && chart.querySelector(ECHARTS_UNPAINTED_HOST_SELECTOR) === null (screenshot_utils.py:274). In practice an error/empty standalone chart renders the alert/empty placeholder instead of the Echart, so .echarts-host and a terminal error/empty marker shouldn't co-occur and there's no deadlock — but for symmetry/defense-in-depth you could give the chart gate the same hasErrorOrEmpty || (...) decomposition. Non-blocking.

Handler lifecycle is clean: on('finished', ...) is registered only inside the if (!chartRef.current) init branch (once per mount) and dispose() on unmount takes the handler with it, so no duplicate stacking.

Tests: the frontend marks the host painted only on the finished event test is genuinely non-vacuous — trigger('finished') invokes the real registered handler, and reverting either the finished registration or the echarts-host class fails the assertions. The Python test_readiness_predicates_gate_on_unpainted_echarts_hosts is a string-assertion test (a unit test can't execute the browser JS), so it verifies the selector is wired into the three gates but not the runtime readiness logic — is that covered by a Playwright/e2e case anywhere? (I verified the assertions and the frontend test by inspection; I couldn't execute either suite in my sandbox — missing superset_core for pytest and no installed node_modules for jest.)

Scope: confirmed Echart.tsx is the only frontend file that calls echarts init(), so every ECharts chart routes through this component and the marker covers them all; non-ECharts vizzes have no .echarts-host and are unaffected. Fix is complete across ECharts plugins.

@aminghadersohi
aminghadersohi merged commit e2070d7 into master Aug 18, 2026
145 checks passed
@aminghadersohi
aminghadersohi deleted the fix-reports-echarts-paint-readiness branch August 18, 2026 04:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alert-reports Namespace | Anything related to the Alert & Reports feature change:frontend Requires changing the frontend plugins preset-io size/L viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants