Add debug log entry for video player pool usage.

This commit is contained in:
Alex Hart
2022-05-20 14:54:24 -03:00
parent 63f4f0bcec
commit eaa7262b2f
9 changed files with 90 additions and 32 deletions

View File

@@ -0,0 +1,39 @@
package org.thoughtcrime.securesms.logsubmit
import android.content.Context
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.video.exo.ExoPlayerPool
/**
* Prints off the current exoplayer pool stats, including ownership info.
*/
class LogSectionExoPlayerPool : LogSection {
override fun getTitle(): String = "EXOPLAYER POOL"
override fun getContent(context: Context): CharSequence {
val poolStats = ApplicationDependencies.getExoPlayerPool().getPoolStats()
val owners: Map<String, List<ExoPlayerPool.OwnershipInfo>> = poolStats.owners.groupBy { it.tag }
val output = StringBuilder()
output.append("Total players created: ${poolStats.created}\n")
output.append("Max allowed unreserved instances: ${poolStats.maxUnreserved}\n")
output.append("Max allowed reserved instances: ${poolStats.maxReserved}\n")
output.append("Available created unreserved instances: ${poolStats.unreservedAndAvailable}\n")
output.append("Available created reserved instances: ${poolStats.reservedAndAvailable}\n")
output.append("Total unreserved created: ${poolStats.unreserved}\n")
output.append("Total reserved created: ${poolStats.reserved}\n\n")
output.append("Ownership Info:\n")
if (owners.isEmpty()) {
output.append(" No ownership info to display.")
} else {
owners.forEach { (ownerTag, infoList) ->
output.append(" Owner $ownerTag\n")
output.append(" reserved: ${infoList.filter { it.isReserved }.size}\n")
output.append(" unreserved: ${infoList.filterNot { it.isReserved }.size}\n")
}
}
return output
}
}

View File

@@ -78,6 +78,7 @@ public class SubmitDebugLogRepository {
}
add(new LogSectionNotifications());
add(new LogSectionNotificationProfiles());
add(new LogSectionExoPlayerPool());
add(new LogSectionKeyPreferences());
add(new LogSectionBadges());
add(new LogSectionPermissions());