Android recording cleanup stays pending after the recorder PID is reused

Đang mở
#4,242 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@thymikee đang làm issue này rồi.

Từ ngày 5/11/2026.

  • #4245 của @thymikee — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
android, typescript
Lĩnh vực
mobile, testing

Hướng nghiên cứu

Read packages/platform-android/src/recording/chunks.ts and cleanup.ts, then inspect the Android recording transport fixture and recovery-cleanup.test.ts matrix referenced in the issue. Trace how ownership-lost and path-writer results affect cleanup. Done means cleanup succeeds for a reused PID with a conclusive empty writer scan, never signals the replacement process, and retains evidence when inspection is inconclusive or a writer remains.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

needs-triage

Problem

An Android recording can remain stuck in cleanup after its recorder has already exited. Android may assign that process number to another app or system process before the recording is closed or recovered. Cleanup treats that unrelated process as an unresolved recording owner and refuses to remove the old recording's files and marker. Retrying cleanup does not help while the replacement process remains alive. Users can be left with retained recording state and a device claim that cannot be released normally.

Reproduction path

  1. Start an Android recording, then leave unfinished recording state after the native recorder exits, for example after a daemon interruption or a failed stop.
  2. Let Android reuse the recorded PID for an unrelated process while the recording's manifest and artifact remain.
  3. Close or recover that recording, entering screenRecordingCleanup with its valid persisted envelope.
  4. Observe cleanup-pending / transport-failed despite the original recorder being gone and no process writing its artifact.

A deterministic host-only regression can use the existing Android recording transport fixture: return ownership-lost from stop and inspect for the persisted identity, and a conclusive empty writer scan for its path. Assert cleanup succeeds without signaling the replacement PID. This reproducer has not been executed here. PID reuse is an ordinary OS event, but its frequency in this exact cleanup window is uncertain.

Evidence

  • src/platform-runtime-screen-recording-android-host.ts:173-180 identifies a PID whose command no longer matches as ownership-lost; the replacement can be completely unrelated to recording.
  • packages/platform-android/src/recording/chunks.ts:228-233 throws immediately on that stop result, before any path-writer check.
  • packages/platform-android/src/recording/cleanup.ts:17-27 calls that stop routine and converts its exception into pending cleanup, so it never removes the old artifact or manifest.
  • packages/platform-android/src/recording/chunks.ts:257-263 also throws when a poll establishes that the original process identity has terminated through reassignment.
  • Read e41da2338f and its packages/platform-android/src/recording/recovery-cleanup.test.ts test matrix direct cleanup checks a reused PID and path writers when %s. The empty case proves cleanup without signaling the replacement; the inconclusive and foreign-writer cases correctly retain evidence. Admission-release and successor cases in that test depend on archive-only machinery and are not required for this issue.

Suggested minimal fix and completion conditions

In exact-evidence cleanup, distinguish termination of the original process from continued ownership of its numeric PID. When reassignment is confirmed, require a conclusive empty writer scan for the artifact before deleting it. Never signal the replacement process. Retain evidence if identity inspection or writer enumeration is inconclusive, or if any writer remains. Verify successful cleanup for a reused unrelated PID and refusal for a real path writer.

Estimated clean scope: roughly 40–80 production lines in Android recording chunks/cleanup, plus three or four focused transport-fixture cases. Do not port device-wide admission or change normal export behavior to implement this fix. Dependencies: none; main already exposes identity inspection and path-writer probing.

Relevant archive commit: e41da2338f0e3ff4663548df59c920cc78327daf. Its cleanup caller uses rollbackChunks through earlier archive changes; adapt the behavior to main's cleanupVerifiedAndroidEvidence rather than cherry-picking it unchanged.

Likelihood: plausible after delayed cleanup or daemon interruption on busy devices; uncommon in short uninterrupted recordings. Confidence: high in the cleanup failure, medium in practical incidence.

Ngôn ngữ chính
TypeScript
Star
5.3k
Fork
377
Merge trung bình
14 giờ 6 phút
Pull request đã merge (30 ngày)
650

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của callstack/agent-device

Tất cả issue của callstack/agent-device

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.