Skip to content

Give hide browser a per-command budget for frames that never answer - #627

Merged
yansfil merged 5 commits into
mainfrom
fix/silent-frame-budget
Oct 6, 2026
Merged

yansfil merged 5 commits into
mainfrom
fix/silent-frame-budget

Conversation

@yansfil

@yansfil yansfil commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #625

Summary

응답하지 않는 프레임이 읽기마다 한 step(8초)씩 비용을 내고, wait가 timeout을 넘기고, 게이트웨이의 pending 상한을 넘길 수 있던 문제를 한 가지 원인으로 묶어 고쳤습니다.
화면 변경은 없습니다. hide browser의 동작과 도움말만 바뀝니다.

  • 프레임은 한 명령 안에서 응답 없는 라운드가 연속 2번(MISS_LIMIT)이면 기록만 하고 그 명령이 끝날 때까지 다시 묻지 않습니다. 횟수는 요청 종류별로 셉니다(enable·tag·읽기 / 안쪽 프레임 찾기). 같은 종류의 답만 그 종류의 횟수를 처음부터 다시 시작합니다.
  • 게이트웨이에 자리가 없어 보내지 못한 호출은 NotSent로 따로 다루며, 프레임의 miss로 세지 않고 이번 라운드에만 unread로 남깁니다. 다음 라운드에 다시 묻습니다.
  • 안쪽 프레임을 찾지 못한 프레임은 이미 읽힌 프레임입니다. section과 ref를 그대로 갖고 변경 비교에도 정상적으로 들어갑니다. 그 안의 프레임이 unread이고 # OOPIF unlisted origin=<origin>으로 표시됩니다. 프레임은 계속 unread로 이름이 불리고, 변경으로도 부재로도 세지 않습니다.
  • 최상위 문서와 입력 이벤트(드래그의 mouseReleased 포함)는 프레임 읽기가 차지한 자리 때문에 거절되지 않습니다. 프레임 읽기는 게이트웨이에 남은 자리 안에서 묶음으로 나가고, 아직 묻지 않은 세션이 먼저, 마지막 질문에 답하지 않은 세션은 나중에 나갑니다.
  • 명령은 게이트웨이가 답이나 자기 deadline 오류를 보낼 때까지 pending으로 셉니다. 시간으로 추정하지 않으므로 느린 relay에서도 상한을 넘지 않습니다.
  • wait의 첫 poll은 온전한 읽기이고, 이후 poll의 모든 읽기는 남은 시간으로 제한됩니다. 최상위 문서의 읽기가 deadline에 잘리면 "텍스트가 없다"가 아니라 "page가 답하기 전에 끝났다"고 말합니다.
  • 응답 없는 프레임 옆의 @tag:N ref는 여전히 page_unresponsive이지만 next_action이 새 snapshot을 찍으라고 안내하고, help의 오류표도 같은 말을 합니다.

Review

  • 판단해 주세요: 예산을 "연속 2번"으로 둔 것. 두 라운드 연속 침묵한 프레임은 그 명령 안에서 다시 답해도 읽지 않습니다(긴 wait에서 20초 뒤 살아난 프레임이 대표 사례). 한 번 더 묻는 시점(예: wait의 deadline 직전)을 두는 것은 후속으로 남겼습니다.
  • 판단해 주세요: stale ref 옆의 침묵 프레임은 ref_stale로 바꾸지 않고 page_unresponsive + 새 snapshot 안내로 뒀습니다. 침묵 프레임이 그 ref의 프레임이 아님을 알 방법이 없기 때문입니다.
  • 조심해서 볼 파일: hided/src/browser_page/cdp.rs - failure path와 고빈도 경로: call_all의 admit(상한 28/16, 최상위 우선)과 pending 맵. 대기하지 않고, 못 보낸 호출은 무응답으로 읽힙니다.
  • 조심해서 볼 파일: hided/src/browser_page/page.rs - eval/eval_all/scan의 연속 miss 계산과 unreadable()(자기 프레임을 찾지 못한 프레임도 noted).
  • 비용 검토: 명령당 추가 작업은 pending 맵(명령 하나에 항목 하나, 답이나 게이트웨이 오류에 제거)과 프레임당 카운터뿐입니다. 호출마다 admit이 한 번 pending을 훑습니다(최대 32). 상시 작업이 아닙니다.

Evidence

  • 2차 리뷰(REVIEW-2) 세 건: 위 세 불릿이 그 처리입니다. 후속으로 남긴 것(미처리): wait의 첫 poll이 짧은 --timeout을 무시하는 점, 단일 호출이 게이트웨이 pending 상한에서 면제인 점. 리드가 별도 이슈로 올립니다.
  • 확인한 것: head ad58abad에서 verify와 Design contract가 모두 통과했습니다(Rust workspace, remote mailbox, Linux·Windows OS contract, Windows check, Linux web e2e 4샤드, Windows e2e). 재실행은 없었습니다.
  • 확인한 것: scripts/verify-cargo.sh lint(fmt + clippy -D warnings) 통과. head 83408fed의 hided lib 250개 통과, browser_page 59개 통과.
  • 확인한 것: 세 건 각각에 대응하는 테스트를 넣었고(a_frame_that_answers_reads_but_not_the_look_for_its_own_frames_is_given_up_for_that_look, a_call_the_gateways_room_kept_back_is_not_a_miss_and_is_made_once_the_held_commands_end, a_frame_read_in_both_reads_is_compared_and_the_frames_inside_it_that_could_not_be_listed_are_not, a_frame_whose_own_frames_could_not_be_listed_keeps_its_section_and_is_not_called_unresponsive), 결함을 넣으면 각각 실패합니다(어떤 답이든 횟수 초기화, 보내지 않은 호출을 miss로 셈, 안 나열된 프레임 자신을 비교에서 뺌). 두 번째 건은 recording_held로 게이트웨이가 쥔 명령을 테스트가 정한 순서에 끝내므로 시간에 기대지 않습니다. 첫 번째 건의 경과 시간 단언은 TESTING.md의 규칙(짧은 시계 한도 금지) 때문에 넣지 않고 setAutoAttach 횟수로 대신했습니다.
  • 확인하지 못한 것: 이 머신 디스크가 가득 차(267 MiB 남음) codesign이 internal error in Code Signing subsystem으로 실패해, hided/tests/connect_build.rs의 3개 테스트가 로컬에서 실패했습니다(직접 codesign을 실행해도 같은 오류). 이 변경이 닿지 않는 코드이고 직전 head에서는 같은 머신에서 통과했으며, CI 결과로 확인합니다.
  • 확인한 것: 이슈의 재현 4건과 리뷰 항목 1-5, 7, 8을 fake_gateway.rs의 스크립트 게이트웨이로 옮겼고, 시간이 아니라 순서와 횟수로 판정합니다. 게이트웨이 모델은 33번째 명령에서 1013으로 닫고, 답 없는 명령에는 자기 deadline에 오류 답을 보냅니다.
  • 확인한 것: 의도적으로 결함을 넣어 보았습니다(답하면 횟수 초기화 끔, 최상위 문서를 우선 호출에서 뺌, 반복 질문 상한을 28로 올림, 부모 연쇄 제외 끔). 각각 대응하는 테스트가 실패했습니다.
  • 확인하지 못한 것: 데스크톱 e2e(desktop/e2e/browser-agent.spec.ts의 "never answers" 시나리오)는 이 머신에서 실행하지 않았습니다. 네이티브 앱이 필요합니다.
  • 확인하지 못한 것: 게이트웨이의 분당 600 명령 상한은 세지 않습니다. pending 상한만 셉니다. 느린 relay(항목 6)는 실제 지연으로 재현하지 못했고, 시간 추정을 없앤 설계로 답했습니다.
  • 확인하지 못한 것: 항목 7(한 번의 frames()에서 부모 재스캔)은 직접 테스트가 없습니다. 같은 호출 안에서 다시 보내지 않는 것을 코드(scanned_now)로 보장하고, 호출을 넘는 횟수는 setAutoAttach가 2번을 넘지 않는 테스트로 봅니다.
리뷰 항목별 처리
  1. 연속 miss로 바꾸고 답이 오면 0으로 되돌립니다. 테스트: a_frame_that_answers_starts_its_budget_again.
  2. 첫 poll은 호출마다 온전한 step을 받고, 이후 poll만 남은 시간으로 제한됩니다. 테스트: a_wait_shorter_than_a_read_still_gets_one_whole_read, a_polls_reads_after_the_first_end_with_the_wait_and_say_the_text_is_not_known_absent.
  3. 대기하지 않고 맞는 호출만 보냅니다. 아직 묻지 않은 세션이 먼저 나갑니다. 테스트: frames_that_answer_are_read_beside_frames_the_gateway_still_holds_commands_of.
  4. 최상위 문서와 단일 호출(입력 이벤트)은 자리를 따지지 않습니다. 테스트: a_drag_ends_with_its_release_whatever_the_gateway_holds_of_frame_reads, the_top_document_is_asked_when_frame_reads_have_filled_their_room.
  5. 자기 프레임을 찾지 못한 프레임은 noted/unread이고, compare는 그 프레임과 안쪽 프레임을 양쪽 텍스트에서 뺍니다(Composite.lineage). 테스트: a_look_for_a_frames_own_frames_that_went_unanswered_..., frames_inside_a_frame_one_read_could_not_list_are_left_out_of_both_texts.
  6. 250 ms 가정과 시간 기반 해제를 없애고 게이트웨이가 보낸 메시지로만 해제합니다.
  7. 같은 frames() 호출에서 이미 본 부모는 다시 스캔하지 않습니다(scanned_now).
  8. 간격은 실제로 묻는 세션 수로 셉니다. 테스트: a_poll_counts_only_the_frames_it_asks.
  9. 새로 쓴 문단은 문장마다 한 줄입니다.
  10. help의 page_unresponsive 행이 새 snapshot 안내를 말합니다.

A frame that left MISS_LIMIT rounds of one command unanswered is noted and
not asked again for the rest of that command, so a permanently hung frame
costs two steps, not one on every read. Every wait of a command is bounded
by what the command has left, so wait reports timeout at its own deadline.
The client counts commands the gateway still holds, including those it gave
up on at its step, against the gateway's pending cap, so silent frames never
end a read with browser_limit. A ref no readable frame carries, beside a
frame that did not answer, says to take a fresh snapshot.
…t short

The look for a frame's own frames shares the frame's budget of unanswered
rounds, so a frame that goes silent after it answered is not scanned again
and again. A wait whose last poll ended before the top document answered
says so instead of reporting the text as not found, and nothing is sent when
the command has no time left.
…topping a healthy call

A frame that answers starts its budget again, and a look for its own frames
that went unanswered waits for the next read instead of being repeated in
the same call. The top document and input events are always sent; frame
reads go in rounds that stay within the room the gateway has, the sessions
not yet asked first, and a session that has not answered its last command
is asked again only while few are held. Commands count as held until a
message of the gateway's ends them, not by a guess at its clock.

A frame whose own frames could not be listed is named in a snapshot, in a
change check, where the frames inside it are left out of both texts, and in
a wait. A wait's first poll is a whole read, and its interval counts only
the sessions asked. The help error table and the docs match what the
command returns.
…of the unread

A miss is a round in which a frame was asked one kind of thing and gave no
answer to it. A frame's look for its own frames is counted apart from its
enable, tag and reads, so an answer to a read no longer starts the count of
a look it never answers, and neither kind is cleared by the other.

A call the gateway had no room for, or no time left for, is never sent and
has its own outcome: the frame stays unread for that round, is not charged a
miss, and is asked in a later round.

A frame whose own frames could not be listed has been read: it keeps its
section and refs, is compared normally and is not called unresponsive. The
frames inside it are the unread ones, noted as unlisted, left out of both
texts of a change check and named by a wait that times out.
…hat releases them

The error answers that end what the gateway holds now precede the answer to
the request that releases them on the socket, so a client that has read its
answer has read them. Sent after it, they could still be in flight when the
next read began, which made the held-command test depend on the scheduler.
@yansfil
yansfil merged commit 098eab5 into main Oct 6, 2026
19 checks passed
@yansfil
yansfil deleted the fix/silent-frame-budget branch October 6, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant