Bug description
I am currently facing an issue in exporting my dashboards from page 3 onwards. Is there a way to go about solving this issue?
How to reproduce the bug
.
Screenshots/recordings
Superset version
master / latest-dev
Python version
I don't know
Node version
I don't know
Browser
Chrome
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.
- [ ] 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.
Comment From: dosubot[bot]
Hi @chengkaijie0! 👋 I'm a bot here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together!
To resolve the issue of being unable to export your dashboards from page 3 onwards in a multi-page PDF document, you should investigate the _get_screenshots and _get_pdf methods in the BaseReportState class. These methods are responsible for generating the screenshots and compiling them into a PDF.
Here is the relevant code snippet:
def _get_screenshots(self) -> list[bytes]:
"""
Get chart or dashboard screenshots
:raises: ReportScheduleScreenshotFailedError
"""
url = self._get_url()
_, username = get_executor(
executor_types=app.config["ALERT_REPORTS_EXECUTE_AS"],
model=self._report_schedule,
)
user = security_manager.find_user(username)
if self._report_schedule.chart:
window_width, window_height = app.config["WEBDRIVER_WINDOW"]["slice"]
window_size = (
self._report_schedule.custom_width or window_width,
self._report_schedule.custom_height or window_height,
)
screenshot: Union[ChartScreenshot, DashboardScreenshot] = ChartScreenshot(
url,
self._report_schedule.chart.digest,
window_size=window_size,
thumb_size=app.config["WEBDRIVER_WINDOW"]["slice"],
)
else:
window_width, window_height = app.config["WEBDRIVER_WINDOW"]["dashboard"]
window_size = (
self._report_schedule.custom_width or window_width,
self._report_schedule.custom_height or window_height,
)
screenshot = DashboardScreenshot(
url,
self._report_schedule.dashboard.digest,
window_size=window_size,
thumb_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
)
try:
image = screenshot.get_screenshot(user=user)
except SoftTimeLimitExceeded as ex:
logger.warning("A timeout occurred while taking a screenshot.")
raise ReportScheduleScreenshotTimeout() from ex
except Exception as ex:
raise ReportScheduleScreenshotFailedError(
f"Failed taking a screenshot {str(ex)}"
) from ex
if not image:
raise ReportScheduleScreenshotFailedError()
return [image]
def _get_pdf(self) -> bytes:
"""
Get chart or dashboard pdf
:raises: ReportSchedulePdfFailedError
"""
screenshots = self._get_screenshots()
pdf = build_pdf_from_screenshots(screenshots)
return pdf
The _get_screenshots method captures screenshots of the charts or dashboards, and the _get_pdf method compiles these screenshots into a PDF. If the issue is occurring from page 3 onwards, it might be due to a timeout or an error in capturing the screenshots.
To debug this issue, you can:
- Check for Timeouts: Ensure that the screenshot capturing process is not timing out. The
SoftTimeLimitExceededexception indicates a timeout. - Error Handling: Look for any exceptions being raised in the
_get_screenshotsmethod. TheReportScheduleScreenshotFailedErrorexception indicates a failure in taking a screenshot. - Logging: Add additional logging to capture more details about the failure. This can help identify if the issue is with specific pages or charts.
- Configuration: Verify the configuration settings for
WEBDRIVER_WINDOWto ensure that the window size is appropriate for capturing the entire dashboard.
By addressing these points, you should be able to identify and resolve the issue with exporting your dashboards in a multi-page PDF document [1].
To continue talking to Dosu, mention @dosu.
Comment From: rusackas
Possibly related to (or even a duplicate of?) https://github.com/apache/superset/issues/29324
Comment From: xavier-GitHub76
Possibly related to https://github.com/apache/superset/issues/31158
Comment From: rusackas
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.
Comment From: tahvane1
Setting DASHBOARD_VIRTUALIZATION to False doesn't solve this issue (not at least for me).