superset icon indicating copy to clipboard operation
superset copied to clipboard

Export to PDF leaves charts empty on first export

Open ignasv opened this issue 1 year ago • 13 comments

Bug description

When using the new Export to PDF functionality, we get a mostly empty PDF on the first try. Second export usually works fine. If we refresh the page - same issues reappear: first export is empty, second is fine.

The issue does not seem to impact Big Number and Table charts. But everything else: Pie Charts, Bar Charts, Area Charts, seem to be impacted.

How to reproduce the bug

  1. Open a dashboard which has a Pie Chart.
  2. Click Export to PDF
  3. Check PDF

Screenshots/recordings

First click on Export to PDF: Screenshot 2024-03-15 at 14 50 04

Second click on Export to PDF: Screenshot 2024-03-15 at 14 50 30

Superset version

3.1.1

Python version

3.10

Node version

Not applicable

Browser

Safari

Additional context

No response

Checklist

  • [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [X] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [X] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

ignasv avatar Mar 15 '24 13:03 ignasv

Same issue for me, with the 4.0.1 version of superset.

Arcelone avatar Jun 18 '24 15:06 Arcelone

I also face exact same issue (4.0.1)

Spragalas avatar Jun 19 '24 13:06 Spragalas

Same problem, but worst:

  • For me it only prints what is visible on the screen. Anything outside it is not printed, but rather shows the Superset loading logo.

Is this using the webdriver component? If yes, perhaps it is not waiting long enough to take the screenshot.

hanslemm avatar Jul 04 '24 12:07 hanslemm

@hanslemm i think this is the issue. I don't know which technology they use to generate the pdf. But it may be just a option to force the rendering of all the page and not only the visible part.

Arcelone avatar Jul 06 '24 09:07 Arcelone

Similar problem with embedded dashboard. When we export embedded dashboard, only visible charts are saved in pdf. If some charts are out of screen, in pdf we have loading logo instead of charts. I have attached a screenshot.

But when we export dashboard from superset (not embedded), pdf is saving correctly.

In addition (maybe it can help) - if you will try to scroll embedded dashboard quicky, you will see a loading logo by a millisecond before chart renders. It seems like charts that are out of screen are unloading.

UPDATE: I have debugged it - there is DASHBOARD_VIRTUALIZATION feature flag. If it is True, charts out of screen are removing from DOM. I set it False and export embedded dashboard now is working correctly. Maybe it would be right if all charts will be loaded back before exporting to pdf?

Снимок экрана от 2024-07-23 11-18-42

artyom738 avatar Jul 23 '24 09:07 artyom738

We suspect that this might be resolved in the current 4.1 release candidate. Please test and vote accordingly! Let me know if you need help with that, and make sure you subscribe to the [email protected] mailing list (just send an email to [email protected])

rusackas avatar Jul 26 '24 17:07 rusackas

@rusackas could this fix also get implemented within the @superset-ui/embedded-sdk NPM package?

When my users try to print their page via the browser functionality, the same issue occurs where any chart outside of the viewport doesn't get rendered but displays the "loading" status instead.

Xyrai avatar Aug 01 '24 07:08 Xyrai

We suspect that this might be resolved in the current 4.1 release candidate. Please test and vote accordingly! Let me know if you need help with that, and make sure you subscribe to the [email protected] mailing list (just send an email to [email protected])

hello, I'm testing witht the latest dev code, the issue is still present, there is no guarantee that all the charts of a dashboard are being sent to the pdf generation module.

BTW, is it possible to have Apache Superset generate the pdf on the server side?

jpchev avatar Nov 15 '24 09:11 jpchev

hello, I think this is due to React (re)rendering mechanism, is it possible to disable that ?

It seems this line is being entered if the user "is a bot", which means by the web driver. Can that be put in OR with the condition that the user is on the web UI and it wants to get a pdf with all the charts rendered (that should always be true) ?

@rusackas what do you think?

jpchev avatar Nov 15 '24 13:11 jpchev

I have created this PR https://github.com/apache/superset/pull/30935 to propose a fix

jpchev avatar Nov 15 '24 18:11 jpchev

Hi all,

Are folks still facing this? It's been quiet for a long time now. With any luck, it was resolved along the way, but let me know if it's still happening in 4.1.2/5.0.0, and whether or not you have the PLAYWRIGHT_REPORTS_AND_THUMBNAILS flag turned on or not.

rusackas avatar Apr 23 '25 23:04 rusackas

I have a similar issue on 5.0.0 but the correct export is the first.

Image

After the export is KO

Image

xavier-GitHub76 avatar May 23 '25 13:05 xavier-GitHub76

These all seem like they might effectively be the same issue:

https://github.com/apache/superset/issues/29394 https://github.com/apache/superset/issues/31158 https://github.com/apache/superset/issues/29719 https://github.com/apache/superset/issues/28713 https://github.com/apache/superset/issues/27532

Can anyone here test this with DASHBOARD_VIRTUALIZATION set to false? I have a suspicion that may fix it. If so, we can probably just disable viewport virtualization when the headless browser is building the screencap.

rusackas avatar Jun 10 '25 03:06 rusackas