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

Aperta Adatta ai principianti
#26,458 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
ios, swift
Ambito
mobile

Direzione di ricerca

Inizia da StatsDataHelper.swift, in particolare da childRowsForItems e expandableDataRowsFor, poi esamina l’uguaglianza di DetailExpandableChildRow e la correzione dell’issue #26415. Riproduci il problema con due gruppi di tag che condividono un tag e almeno sette voci, quindi espandi entrambi i gruppi nella scheda classica Tags and Categories. Il lavoro è completato quando entrambi i gruppi si espandono senza arresti anomali e le sezioni espandibili correlate continuano a funzionare correttamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[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"
]}
Lingua principale
Swift
Stelle
3.9k
Fork
1.2k
Merge medio
1g 21h
PR unite (30g)
126

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wordpress-mobile/WordPress-iOS

Tutte le issue di wordpress-mobile/WordPress-iOS

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.