Stats: Tags and Categories details crashes when two expanded groups share a tag

Đang mở Phù hợp với người mới
#26,458 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/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ệ
ios, swift
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu với StatsDataHelper.swift, đặc biệt là childRowsForItems và expandableDataRowsFor, sau đó kiểm tra tính bằng nhau của DetailExpandableChildRow và bản sửa lỗi cho issue #26415. Tái hiện lỗi với hai nhóm tag dùng chung một tag và có ít nhất bảy mục, rồi mở rộng cả hai nhóm trong thẻ Tags and Categories kiểu cổ điển. Hoàn tất khi cả hai nhóm mở rộng mà không bị crash và các phần có thể mở rộng liên quan vẫn hoạt động chính xác.

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

Mô tả

[Type] Crash Stats

The app crashes when you expand two groups in the classic Insights → Tags and Categories → View more screen that share a tag. We reproduced it on an iOS 27.2 simulator using stats data served from a local proxy. None of the crash reports Sentry still keeps for this crash signature (JETPACK-IOS-1ASW) come from this screen, so we don't know how many users hit it.

Who hits it

Anyone whose top tags include two groups with a tag in common. The Stats API groups tags that appear together on a post, so a site with posts tagged "news, tech" and "news, sport" shows two groups that both contain "news". Expanding both crashes the app.

Why

The expanded tag rows only hold the tag's name, an empty count and its URL. Nothing ties a row to the group it's in, so the two "news" rows are equal, and the diffable table rejects them as duplicate items (NSInternalInconsistencyException: "supplied item identifiers are not unique"). The rows are built by childRowsForItems:

https://github.com/wordpress-mobile/WordPress-iOS/blob/5a363729ba2016c48ecdbe8ca2695db642d09f52/WordPress/Classes/ViewRelated/Stats/Helpers/StatsDataHelper.swift#L90-L98

#26415 fixes the same crash for Post Stats month rows, which is the case behind all retained Sentry reports, but it does not cover tags.

Fix

  • Make each expanded child row include its parent row's identity (for example the parent's name and statSection) in DetailExpandableChildRow equality, set in expandableDataRowsFor.
  • That one change covers every expandable section built there: tags, months, and possibly Authors (a co-authored post under two authors) and repeated Clicks or Referrers entries. Those last cases have not been reproduced.

How to reproduce

  1. Use a site whose stats return two tag groups sharing a tag (for example "news, tech" and "news, sport") and at least seven entries, so the card shows View more.
  2. With New Stats turned off, open Insights, add the Tags and Categories card if needed, and tap View more.
  3. Expand "news, tech", then "news, sport". The app crashes.
Crash log from the simulator (Jetpack Debug, built from #26415)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Fatal: supplied item identifiers are not unique. Duplicate identifiers: {(
    WordPress.AnyHashableImmuTableRow(immuTableRow: WordPress.DetailExpandableChildRow(rowData: WordPress.StatsTotalRowData(id: nil, name: "news", data: "", ..., showDisclosure: true, disclosureURL: Optional(https://jkmassel.wordpress.com/tag/news/), multiline: true, childRows: Optional([]), statSection: nil, isReferrerSpam: false, month: nil), ..., hideIndentedSeparator: true, hideFullSeparator: true, ...))
)}'

The tags response the proxy served:

{"tags": [
  {"views": 20, "tags": [{"name": "news", "type": "tag"}, {"name": "tech", "type": "tag"}]},
  {"views": 10, "tags": [{"name": "news", "type": "tag"}, {"name": "sport", "type": "tag"}]},
  {"views": 9, "tags": [{"name": "filler0", "type": "tag"}]},
  "... five more single-tag entries"
]}
Ngôn ngữ chính
Swift
Star
3.9k
Fork
1.2k
Merge trung bình
1 ngày 21 giờ
Pull request đã merge (30 ngày)
126

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 wordpress-mobile/WordPress-iOS

Tất cả issue của wordpress-mobile/WordPress-iOS

Issue tương tự

Thêm issue về Swift

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.