Session Replay: session segment ID can repeat after an error converts buffer mode

Đang mở
#6,740 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

Chưa có ai nhận issue này.

Đánh giá

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

Hướng nghiên cứu

Start in ReplayIntegration.captureCurrentReplay and follow convert() into BufferCaptureStrategy.start; then read the queued replay tasks for pause, configuration_changed, and add_frame that mutate currentSegment. Reproduce with a test where one of those tasks is queued when an error converts the strategy, then assert session segment IDs do not repeat. Done when the next session ID is derived from the segment actually sent via onSegmentSent, not from a stale copy, and the replay test passes.

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

Mô tả

Android Bug Platform: Java Replays

Problem

When an error converts buffer mode to session mode, the session can send two segments with the same segment ID.

captureCurrentReplay calls convert() on the caller thread. convert() gives currentSegment to SessionCaptureStrategy.start(segmentId = currentSegment) immediately. But tasks that are still in the queue of the replay executor can change the counter of the buffer strategy after that copy:

The capture_replay task then sends the current segment with the changed counter. After that, the callback does activeStrategy.currentSegment++ on the copy that is out of date.

Example

  1. Buffer mode. No segments are buffered, so currentSegment is 0.
  2. The user rotates the device. A configuration_changed task is in the queue.
  3. An error occurs before that task runs. convert() starts the session with segment ID 0.
  4. The configuration_changed task buffers segment 0. The buffer counter becomes 1.
  5. The capture_replay task sends buffered segment 0 and current segment 1. The callback sets the session counter from 0 to 1.
  6. The next session segment also has ID 1.

Proposed fix

Set the next session segment ID from the ID of the segment that the flush sent (for example, pass it to onSegmentSent and set currentSegment = sentId + 1). Do not increment a copy.

Add a test: a configuration_changed or pause task in the queue when an error converts the strategy. Then the session segment IDs must not repeat.

Found while reviewing #6542. That PR can also change the counter in a queued task (a clock jump deletes buffered segments). The bug is on main without it.

Ngôn ngữ chính
Kotlin
Star
1.4k
Fork
483
Merge trung bình
2 ngày 54 phút
Pull request đã merge (30 ngày)
207

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 getsentry/sentry-java

Tất cả issue của getsentry/sentry-java

Issue tương tự

Thêm issue về Kotlin

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.