Skip to content

hide browser: a frame that never answers costs a full step on every read, and wait overshoots its timeout #625

Closed

Description

@yansfil

What happened

Found by the fourth review of #571, lower confidence, timing and budget only (no wrong answer).
After #571 a frame that never answers is asked again on every read of the page, so a permanently hung iframe costs time on every command.
All four items share one cause: silent frames are re-asked without a per-command budget, and the retry is sized to the gateway's limits, not to the command's deadline.

  1. Page::frames() (hided/src/browser_page/page.rs) re-asks every silent frame (Page.enable, tag, scan) on each call and blocks a full STEP (8 s) for each unanswered round, and a command calls it several times.
    A page with one iframe stuck in a loop: click @k:3 with verify calls it in the capture, frame(), frame_offset and each of the three change reads, about 6 x 8 s = 48 s.
    A frame that answers Page.enable but not its tag read adds a second round per call, and a nested level adds more, which can pass the 120 s command deadline and end with a generic page_unresponsive.
    Scans of silent parents are sequential (8 s each), not batched.
    The tried set bounds retries only within one call.
  2. wait_for (hided/src/browser_page/actions.rs) checks its deadline only after a whole poll, and each poll begins with frames() blocking a full step on a frame that never answered.
    wait --text Done --timeout 5 on a page with one hung iframe returns after about 8 s; with --timeout 60 and several hung levels the last poll can start just before the deadline and run to about 24 s, so the 120 s command limit can cut it off instead of reporting timeout.
  3. Page::frame() maps Lookup::Unknown to a silent page_unresponsive whenever any unrelated frame is silent.
    A ref from a frame that navigated, used while an ad iframe never answers Page.enable, gets page_unresponsive with "retry, or ask the operator", never ref_stale with the "take a fresh snapshot" guidance, so a caller can retry the same stale ref forever.
  4. Cdp::call_all (hided/src/browser_page/cdp.rs) sizes its rounds to the gateway's 32-command pending cap, but hided gives up at STEP (8 s) while the gateway keeps an unanswered command pending until its 10 s deadline.
    With about 17 or more hung frames (the cap is 24), a second frames() call starts at 8 s while the first batch is still pending until 10 s; pending passes 32 and the gateway closes the connection with 1013, so the command fails browser_limit instead of noting the silent frames.

What you expected

  • A frame that did not answer is retried within a per-command budget, not on every read: after one unanswered round in a command it is noted and skipped for the rest of that command, or retried at most once more at the end.
  • wait reports timeout within its own deadline (plus at most one step), whatever the frames do; a poll's reads are bounded by the time left.
  • A ref whose tag no frame carries answers ref_stale with the re-snapshot guidance when the silent frame cannot be that ref's frame, or page_unresponsive with a next_action that also says to take a fresh snapshot.
  • Pending commands never pass the gateway's cap: the batch size counts commands the gateway still holds from an earlier round (those abandoned at 8 s are pending until 10 s), so no read ends with browser_limit because of silent frames.

Steps to reproduce

Each is a deterministic test on the scripted gateway in hided/src/browser_page/fake_gateway.rs, with ordering and counts asserted, not wall-clock bounds (docs/TESTING.md).

  1. Frames hung: 1, then run click with verify and count the Page.enable sent to the hung frame: expect a bounded number per command, not one per read.
  2. wait --text with a hung frame and a timeout shorter than STEP: expect timeout, not a poll that runs a whole step past it.
  3. click @old:3 with hung: 1 and no frame carrying old: expect the re-snapshot guidance.
  4. hung: 24, two frames() calls in a row against a gateway that keeps abandoned commands pending: expect the commands in flight to stay at or under 32.

Versions

Diagnostics

From the fourth review pass on #571 (items it ranked lower confidence); no log lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions