I found a bug in the PDF-only scheduled delivery f...
# community-contributors
y
I found a bug in the PDF-only scheduled delivery feature that I added in #21457. When using the PDF format, charts rendered with ECharts (Canvas) are intermittently blank in the generated PDF — tile titles and borders appear, but the chart areas are empty. The IMAGE+PDF path is stable because
page.screenshot()
is called before
page.pdf()
, which forces the browser to fully paint all canvas elements. The PDF-only path calls
page.pdf()
directly, and Chromium's print rendering pipeline unreliably captures canvas content. I've filed an issue with the root cause analysis: #21950
I'm planning to tackle this bug. I have a few ideas for the fix, so I’d like to sync with you on the best approach before I start implementation.
j
charts rendered with ECharts (Canvas) are intermittently blank in the generated PDF
In the past, this error was happening because the browser incorrectly thinks the chart finished loading, or timeout, or the charts has an animation (we need to diable those in minimal). It might not be related with pdf-only A quick fix, if you confirm it only happens with pdf-only is to always do the screenshot before the pdf.
y
Thanks for the context! In my testing: • IMAGE format (screenshot only): always works • IMAGE+PDF (screenshot, then PDF): PDF is stable — charts render correctly • PDF-only (no screenshot before PDF): charts are intermittently blank So it does seem specific to the PDF-only path where
page.pdf()
is called without a prior
page.screenshot()
. The screenshot appears to force the browser to fully paint the canvas before the PDF is generated. I'll submit a PR with the quick fix — taking a screenshot before
page.pdf()
in the PDF-only path to align it with the IMAGE+PDF path. Regarding animations: are ECharts animations already disabled in the minimal page context? If not, that could also be contributing to the instability.
j
> are ECharts animations already disabled in the minimal page context? If not, that could also be contributing to the instability. Should be now, for example, we added sankey charts recently, but we forgot to disable animations on minimal for that chart type, so it was causing a similar issue (charts were partioally rendered on the screenshot). PR: https://github.com/lightdash/lightdash/pull/20987
y
Thanks for pointing that out! I checked the codebase and found that Funnel, Treemap, and Gauge chart types are missing the
minimal
check for disabling animations — they only check `isInDashboard`:
Copy code
ts
// Current (these 3 chart types)
animation: !isInDashboard,

// Should be (matching Cartesian, Pie, Sankey)
animation: !(isInDashboard || minimal),
Should I include this fix in the PR as well, along with the screenshot-before-PDF fix for the PDF-only path?
j
yes, I think so, or you can do it on a separate PR, since it fixes a separate bug, up to you. Thanks !
🆗 1
y
I created two PRs: • #22008 ◦ Take a screenshot before
page.pdf()
in the PDF-only path to force canvas painting • #22010 ◦ Disable ECharts animations in minimal mode for funnel, treemap, and gauge (same fix as #20987 for sankey) On the second one — this is the third time this pattern has been missed for a chart type. Is there a good way to catch
animation: !isInDashboard
without
minimal
automatically? Something like a grep-based CI check or a unit test per config hook. Open to ideas.
thank you 1
j
I have just merged both, thanks for your contribution !
electric mint heart 1