Fix room list duplicate-detection telemetry crashing before it can report (#6791)
* Add room dupe regression tests * Fix telemetry path for dedupe discovery
This commit is contained in:
parent
1cb6b07db3
commit
c318b2540b
4 changed files with 165 additions and 10 deletions
|
|
@ -16,25 +16,25 @@ import org.matrix.rustcomponents.sdk.RoomListEntriesUpdate
|
|||
internal fun RoomListEntriesUpdate.describe(): String {
|
||||
return when (this) {
|
||||
is RoomListEntriesUpdate.Set -> {
|
||||
"Set #$index to '${value.displayName()}'"
|
||||
"Set #$index to '${value.id()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.Append -> {
|
||||
"Append ${values.map { "'" + it.displayName() + "'" }}"
|
||||
"Append ${values.map { "'" + it.id() + "'" }}"
|
||||
}
|
||||
is RoomListEntriesUpdate.PushBack -> {
|
||||
"PushBack '${value.displayName()}'"
|
||||
"PushBack '${value.id()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.PushFront -> {
|
||||
"PushFront '${value.displayName()}'"
|
||||
"PushFront '${value.id()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.Insert -> {
|
||||
"Insert at #$index: '${value.displayName()}'"
|
||||
"Insert at #$index: '${value.id()}'"
|
||||
}
|
||||
is RoomListEntriesUpdate.Remove -> {
|
||||
"Remove #$index"
|
||||
}
|
||||
is RoomListEntriesUpdate.Reset -> {
|
||||
"Reset all to ${values.map { "'" + it.displayName() + "'" }}"
|
||||
"Reset all to ${values.map { "'" + it.id() + "'" }}"
|
||||
}
|
||||
RoomListEntriesUpdate.PopBack -> {
|
||||
"PopBack"
|
||||
|
|
|
|||
|
|
@ -112,6 +112,11 @@ class RoomSummaryListProcessor(
|
|||
private suspend fun updateRoomSummaries(updates: List<RoomListEntriesUpdate>, block: suspend MutableList<RoomSummary>.() -> Unit) = withContext(
|
||||
coroutineContext
|
||||
) {
|
||||
// Capture the description before applying updates: applyUpdate consumes each Room via
|
||||
// `entry.use { ... }` which destroys it, and the duplicate-detection branch below reads
|
||||
// id() through `describe()`. Without this capture the trackError call crashes before it
|
||||
// can be reported.
|
||||
val updatesDescription = updates.description()
|
||||
mutex.withLock {
|
||||
val current = roomSummaries.replayCache.lastOrNull()
|
||||
val mutableRoomSummaries = current.orEmpty().toMutableList()
|
||||
|
|
@ -126,7 +131,7 @@ class RoomSummaryListProcessor(
|
|||
analyticsService.trackError(
|
||||
IllegalStateException(
|
||||
"Found duplicates in room summaries after a list update from the SDK: $duplicates. " +
|
||||
"Updates: ${updates.description()}"
|
||||
"Updates: $updatesDescription"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue