Skip to content

fix(reports): narrow spinner checks to viewport and tighten exception handling#39892

Open
eschutho wants to merge 2 commits intomasterfrom
playwright-report-spinners
Open

fix(reports): narrow spinner checks to viewport and tighten exception handling#39892
eschutho wants to merge 2 commits intomasterfrom
playwright-report-spinners

Conversation

@eschutho
Copy link
Copy Markdown
Member

@eschutho eschutho commented May 5, 2026

SUMMARY

Follow-up to #39579. The first fix addressed the snapshot-based spinner detection in webdriver.py. This PR addresses additional issues identified during review:

  1. Viewport-aware global spinner check — The global wait_for_function in webdriver.py previously checked document.querySelectorAll('.loading').length === 0, which can deadlock on tall dashboards when DashboardVirtualization renders off-screen placeholder .loading divs. Changed to the same getBoundingClientRect viewport-visibility check used in the per-tile path.

  2. Narrow exception handling in screenshot_utils.py — The per-tile spinner wait caught bare Exception, silently swallowing non-timeout errors (e.g. browser crash). Narrowed to PlaywrightTimeout with a runtime-safe conditional import (same try/except import pattern as webdriver.py).

  3. Fix load_wait default — The take_tiled_screenshot load_wait parameter defaulted to 30 s, inconsistent with the SCREENSHOT_LOAD_WAIT config default of 60 s.

  4. Tests — Added tests for the per-tile spinner wait: viewport JS check, timeout warning + continue, non-timeout propagation, and the load_wait default value. Updated existing webdriver test to match the new viewport-aware JS.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend logic change only.

TESTING INSTRUCTIONS

  1. Run pytest tests/unit_tests/utils/test_screenshot_utils.py tests/unit_tests/utils/webdriver_test.py
  2. Trigger a PDF report for a dashboard taller than the viewport (several rows of charts) and verify no spinners appear in the output PDF.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

eschutho and others added 2 commits April 23, 2026 02:01
…g elements

The Playwright screenshot path waited for `.loading` elements to detach
by calling `page.locator(".loading").all()` once and iterating the
snapshot. Spinners that appeared after the snapshot was taken (common on
long dashboards where charts load lazily) were never waited for, causing
PDF reports to capture charts that were still fetching data.

Replace the snapshot loop with `page.wait_for_function` which
continuously polls `document.querySelectorAll('.loading').length === 0`
until the page is genuinely clear of all spinners, then use
`self._screenshot_load_wait` (already stored on the base class) for the
timeout to stay consistent with the Selenium path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… handling

- Replace global '.loading' count check in webdriver.py with a
  getBoundingClientRect viewport-visibility check to avoid deadlock
  when DashboardVirtualization renders off-screen placeholder spinners
- Narrow except clause in screenshot_utils.py from bare Exception to
  PlaywrightTimeout so non-timeout errors (e.g. browser crash) propagate
- Fix load_wait default from 30 s to 60 s to match SCREENSHOT_LOAD_WAIT
  config default
- Add tests covering per-tile spinner wait, timeout warning, non-timeout
  propagation, and load_wait default value

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 5, 2026

Code Review Agent Run #c27d0d

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/utils/screenshot_utils.py - 1
Review Details
  • Files reviewed - 4 · Commit Range: 199435e..a0b2b18
    • superset/utils/screenshot_utils.py
    • superset/utils/webdriver.py
    • tests/unit_tests/utils/test_screenshot_utils.py
    • tests/unit_tests/utils/webdriver_test.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the alert-reports Namespace | Anything related to the Alert & Reports feature label May 5, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 5, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit a0b2b18
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69fa1a773373ca0008f411e2
😎 Deploy Preview https://deploy-preview-39892--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.

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 size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant