Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Screenshotting] Add captureBeyondViewport: false to workaround a res… #131877

Merged

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented May 9, 2022

Summary

Closes #131111

captureBeyondViewport flag

This adds captureBeyondViewport: false to our call of Puppeteer's Page.screenshot function to work around a bug that triggers an implicit resize inside of Puppeteer when we call that method.

From the Puppeteer docs:

captureBeyondViewport When true, captures screenshot beyond the viewport. When false, falls back to old behaviour, and cuts the screenshot by the viewport size. Defaults to true.

Adding this flag is high risk, because any part of the page that isn't contained in the viewport will be invisible. This can lead to screenshots that are cut-off or blank. This PR avoids that problem by doing a final resize of the viewport, to ensure that it includes the element to capture, before the screenshot is captured.

Checklist

  • Test Reporting developer example plugin
  • Test Canvas PDF: Default layout
  • Test Canvas PDF: "full page" layout
  • Test Dashboard PNG/PDF
  • Test Dashboard PDF Print Layout
  • Test Agg-based visualization from the editor
  • Test TSVB visualization from the editor
  • Unit or functional tests were updated or added to match the most common scenarios

Release Note

Fixed an issue in PDF/PNG reporting where visualization panels could sometimes appear blank.

@tsullivan tsullivan force-pushed the screenshot/fix-resize-during-capture branch 2 times, most recently from 9d83b19 to c6969c3 Compare May 10, 2022 00:16
@tsullivan tsullivan force-pushed the screenshot/fix-resize-during-capture branch 2 times, most recently from 093d47a to 38167c0 Compare May 10, 2022 00:43
@tsullivan tsullivan added v8.3.0 v8.1.2 v8.2.1 v8.1.3 (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. Team:AppServicesUx and removed v8.1.2 labels May 10, 2022
tsullivan added 4 commits May 9, 2022 18:22
commit 9e5c688aefb9ff725a38b3c43402dfb96550a96a
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Fri May 6 14:56:11 2022 -0700

    get real

commit c05056e69145a1ad2e95f112b3987f2e88ba9408
Merge: 846ae81 8aa9241
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Fri May 6 14:15:36 2022 -0700

    Merge remote-tracking branch 'elastic/main' into reporting/ks-2573

commit 846ae81
Merge: 64b4c33 99c659c
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed May 4 19:28:17 2022 -0700

    Merge remote-tracking branch 'elastic/main' into reporting/ks-2573

commit 64b4c33
Merge: efa88c3 1cdf0a4
Author: Tim Sullivan <tsullivan@users.noreply.github.com>
Date:   Wed May 4 11:08:44 2022 -0700

    Merge branch 'main' into reporting/ks-2573

commit efa88c3
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed May 4 11:07:47 2022 -0700

    higher visualize png check threshold

commit 8e76398
Merge: 366a28a 47f4658
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed May 4 11:04:47 2022 -0700

    Merge remote-tracking branch 'elastic/main' into reporting/ks-2573

commit 366a28a
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Wed May 4 10:52:32 2022 -0700

    add visualize test for tsvb

commit 7c7e00d
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Tue May 3 19:06:42 2022 -0700

    add new test for kibana 7.6 sample data

commit 25319dd
Author: Timothy Sullivan <tsullivan@elastic.co>
Date:   Tue May 3 17:07:25 2022 -0700

    add test fixtures for 7.6 dashboard
@tsullivan tsullivan force-pushed the screenshot/fix-resize-during-capture branch from 67d06a8 to 5ab1168 Compare May 10, 2022 01:22
@elastic elastic deleted a comment from kibana-ci May 10, 2022
@@ -227,5 +261,57 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await kibanaServer.uiSettings.replace({});
});
});

describe('Sample data from Kibana 7.6', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test adds sample data that was saved and imported in 7.6, as according to the original bug, the types of visualizations here tend to highlight the race condition more than Lens visualizations.

@tsullivan tsullivan marked this pull request as ready for review May 10, 2022 01:47
@tsullivan tsullivan requested review from a team as code owners May 10, 2022 01:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServicesUx)

@tsullivan tsullivan removed the request for review from a team May 10, 2022 01:55
@flash1293
Copy link
Contributor

flash1293 commented May 10, 2022

About the TSVB problem - when setting the viewport before calling the screenshot method the full panel would be captured for me: #131605 (comment) (it introduced a new issue of blurriness, not sure what that's about)

Copy link
Contributor

@dokmic dokmic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything LGTM! That's a fantastic job 👍

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
screenshotting 3 5 +2

Total ESLint disabled count

id before after diff
screenshotting 6 8 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@tsullivan tsullivan enabled auto-merge (squash) May 17, 2022 18:24
@brianseeders brianseeders disabled auto-merge May 17, 2022 18:36
@brianseeders brianseeders merged commit 8cf3344 into elastic:main May 17, 2022
@tsullivan tsullivan deleted the screenshot/fix-resize-during-capture branch May 17, 2022 19:07
@tsullivan tsullivan added v8.1.4 and removed v8.1.3 labels May 19, 2022
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 131877 or prevent reminders by adding the backport:skip label.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label May 20, 2022
@tsullivan tsullivan added the backport:skip This commit does not require backporting label May 20, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label May 20, 2022
@tsullivan
Copy link
Member Author

Added the backport:skip label, since I manually staged the backport PRs

@tsullivan tsullivan removed the v8.1.4 label May 20, 2022
@flash1293
Copy link
Contributor

@tsullivan It seems like this PR missed the 7.17.4 build:

This is the last commit that went into 7.17.4: https://github.com/elastic/kibana/commits/a408358a8fc5671f5eb7985678a1733684441b37

This is the commit merging the reporting fix into the 7.17 branch: 4dd9bf1

  • I guess we should adjust the labels on this PR?
  • Should we make sure there is a 7.17.5 release in the near term to get this fix out?

@bataya0
Copy link

bataya0 commented May 31, 2022

I see that it also didnt make it into v8.2.2

@tsullivan
Copy link
Member Author

@bataya0 I have downloaded the Docker build of 8.2.2 and tested it out. One of the symptoms of this bug was, you could not run a PDF/PNG report from TSVB editor, and I verified this test case. I also viewed the script code in the docker container to make sure it has the latest code, and it does.

Maybe you are having a different issue?

@bataya0
Copy link

bataya0 commented May 31, 2022

In v8.2.2 when viewing a TSVB item, I can still generate PDF and PNG successfully, so I guess the fix is in v8.2.2 even though the tag for v8.2.2 isnt on this pull request.

@tsullivan
Copy link
Member Author

@bataya0 it looks like I needed to correct the version labels here. Done. Thanks for the heads up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. release_note:fix v7.17.5 v8.2.2 v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kibana prints empty for TSVB gauge and metric charts, classical visualization types
9 participants