fix(reports): anchor tiled budget clock at overall screenshot start - #42661
fix(reports): anchor tiled budget clock at overall screenshot start#42661eschutho wants to merge 1 commit into
Conversation
Follow-up to #42118, implementing the non-blocking review suggestion left at merge time: the tiled wait budget is derived from the running Celery task's own time limit, but elapsed time was measured from a clock started inside take_tiled_screenshot() -- so navigation (page.goto, bounded 60s), the headstart sleep, element waits, and dimension probing all ran before the clock started, effectively granting the tile loop a fresh full budget on top of task time already spent. On hard-limit-only tasks that overhang can still crest the task limit -- the SIGKILL #42118 exists to prevent. The non-tiled readiness wait already avoids this by threading screenshot_started_at from the top of get_screenshot (#42427); this applies the same pattern to the tiled call: - take_tiled_screenshot() accepts screenshot_started_at (optional, defaults to "now" for backward compatibility) and anchors the budget clock on it; - WebDriverPlaywright.get_screenshot() passes its existing screenshot_started_at into the tiled call, putting both capture paths on one clock. Tests: pre-capture elapsed time reduces the first tile's capped wait when the anchor is provided; the local-clock default is unchanged when it is omitted; the existing tiled call-site assertion now pins the new argument. Co-Authored-By: Claude <noreply@anthropic.com>
Code Review Agent Run #32a320Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42661 +/- ##
=======================================
Coverage 65.42% 65.42%
=======================================
Files 2810 2810
Lines 159422 159422
Branches 36382 36382
=======================================
Hits 104309 104309
Misses 53070 53070
Partials 2043 2043
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Folding this into #42624 rather than maintaining it standalone: #42624 restructures the exact code this PR patches (the tiled budget clock), and its report-path deadline already starts at task start — superseding this anchor for scheduled reports. The residual non-report case (thumbnails routed to tiling counting pre-capture time) is now implemented on #42624's branch with the same tests, credited to the original review suggestion on #42118. Branch stays for reference. |
…hot start Folds open PR apache#42661 into this branch (its standalone form patched code this branch restructures): take_tiled_screenshot() accepts the caller's screenshot_started_at so navigation/headstart/element-wait time counts against the non-report task budget, matching the clock _wait_for_charts_ready already uses. Report captures are unaffected -- their deadline starts at task start, which supersedes the anchor. Falls back to "now" when omitted. Co-Authored-By: Claude <noreply@anthropic.com>
SUMMARY
Follow-up to #42118, implementing @rebenitez1802's non-blocking review suggestion left at merge time (#42118 (comment) — "tiled budget clock resets instead of accounting for pre-capture time").
The tiled wait budget is derived from the running Celery task's own time limit, but elapsed time was measured from a clock started inside
take_tiled_screenshot()— sopage.goto(bounded 60s), the headstart sleep,element.wait_for, and dimension probing all ran before the clock started. The tile loop effectively got a fresh full budget on top of task time already spent. In the common case the 20%/300s cleanup margin absorbs the overhang (and a soft-limit overrun still surfaces as a cleanSoftTimeLimitExceeded), but on hard-limit-only tasks the uncounted pre-capture time plus a full budget of tiled waits can still crest the hard limit — the SIGKILL #42118 exists to prevent.The non-tiled readiness wait already avoids this: #42427 threads
screenshot_started_atfrom the top ofget_screenshotinto_wait_for_charts_readyand subtracts already-elapsed time. This PR applies exactly the same pattern to the tiled call — the three coordinated changes from the review suggestion:take_tiled_screenshot()acceptsscreenshot_started_at: float | None = Noneand anchors the budget clock on it (falls back to "now" when omitted, preserving the existing API for any other caller);WebDriverPlaywright.get_screenshot()passes its existingscreenshot_started_atinto the tiled call;TESTING INSTRUCTIONS
New tests: with
screenshot_started_atprovided, 900s of pre-capture elapsed time reduces the first tile's capped wait to the true remaining budget (100s of a 1000s budget, not the fullload_wait); with it omitted, the local-clock default behaves exactly as before. The existing tiled call-site assertion now pins the new argument being forwarded.ADDITIONAL INFORMATION