Profiling fix C: Tonight's Pick card painted once (0.108.114)
The panel, picture and navy fade are combined into one bitmap at the card's size off the drawing thread, so the graphics chip paints one layer instead of three. Measured downstairs (8 November 2026): What's On 20.1/20.9 -> 17.1/17.1 ms a frame median, drawing thread 16.6 -> 12.7 ms, janky frames 7/8 -> 5/8. Builds 0.108.110-112 were measurement builds (fix A attempt and its baseline); fix A is parked on perf/fix-a-attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,8 @@ android {
|
||||
applicationId = "tv.orbit.classic"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 269
|
||||
versionName = "0.108.109-restore"
|
||||
versionCode = 275
|
||||
versionName = "0.108.114-pick-card"
|
||||
}
|
||||
buildFeatures { compose = true }
|
||||
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
|
||||
|
||||
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
|
||||
}
|
||||
/** The sign-in headers for this kind of server. */
|
||||
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
|
||||
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.109\"") +
|
||||
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.114\"") +
|
||||
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
|
||||
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.109\"" +
|
||||
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.114\"" +
|
||||
(token?.let { ", Token=\"$it\"" } ?: ""))
|
||||
}
|
||||
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
|
||||
|
||||
@@ -39,7 +39,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
|
||||
next.instanceFollowRedirects = false
|
||||
next.connectTimeout = 10_000
|
||||
next.readTimeout = 20_000
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.108.109")
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.108.114")
|
||||
next.setRequestProperty("Accept-Encoding", "identity")
|
||||
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
|
||||
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
|
||||
|
||||
@@ -19,6 +19,8 @@ import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import androidx.compose.ui.text.font.Font
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -100,9 +102,20 @@ internal fun WhatsOnScreen(session: EmbySampleSession, plans: Map<Int, ChannelPl
|
||||
return@FocusCard
|
||||
}
|
||||
val picture = rememberFilmPicture(session, pick.entry.media.item.id)
|
||||
Box(Modifier.fillMaxSize().background(Panel)) {
|
||||
if (picture != null) Image(picture.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.Crop)
|
||||
Box(Modifier.fillMaxSize().background(Brush.horizontalGradient(0f to Navy.copy(alpha = .97f), .45f to Navy.copy(alpha = .88f), .75f to Navy.copy(alpha = .35f), 1f to Navy.copy(alpha = .15f))))
|
||||
// Profiling fix C (8 November 2026): the panel, the picture and the fade are put together once, off the drawing
|
||||
// thread, at the card's own size, so the graphics chip paints one picture each frame instead of three layers.
|
||||
var size by remember { mutableStateOf(androidx.compose.ui.unit.IntSize.Zero) }
|
||||
val card by produceState<android.graphics.Bitmap?>(null, picture, size) {
|
||||
value = if (picture == null || size.width <= 0 || size.height <= 0) null
|
||||
else kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.Default) { runCatching { pickCard(picture, size.width, size.height) }.getOrNull() }
|
||||
}
|
||||
Box(Modifier.fillMaxSize().onSizeChanged { size = it }.background(Panel)) {
|
||||
val baked = card
|
||||
if (baked != null) Image(baked.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds)
|
||||
else {
|
||||
if (picture != null) Image(picture.asImageBitmap(), null, Modifier.fillMaxSize(), contentScale = ContentScale.Crop)
|
||||
Box(Modifier.fillMaxSize().background(Brush.horizontalGradient(0f to Navy.copy(alpha = .97f), .45f to Navy.copy(alpha = .88f), .75f to Navy.copy(alpha = .35f), 1f to Navy.copy(alpha = .15f))))
|
||||
}
|
||||
Column(Modifier.fillMaxSize().padding(16.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
Tag("TONIGHT'S PICK", Yellow, 11)
|
||||
Logo(pick.channel, 96, 30)
|
||||
@@ -222,3 +235,25 @@ internal fun ProgrammeReminderCard(reminder: ProgrammeReminder, nowMs: Long, onW
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Tonight's Pick's card, painted once (profiling fix C): the panel colour, the picture cropped to fill the card as
|
||||
* ContentScale.Crop does, and the same left-to-right navy fade, all in one bitmap of the card's size.
|
||||
*/
|
||||
internal fun pickCard(picture: android.graphics.Bitmap, width: Int, height: Int): android.graphics.Bitmap {
|
||||
val out = android.graphics.Bitmap.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888)
|
||||
val canvas = android.graphics.Canvas(out)
|
||||
canvas.drawColor(Panel.toArgb())
|
||||
val scale = maxOf(width.toFloat() / picture.width, height.toFloat() / picture.height)
|
||||
val w = picture.width * scale; val h = picture.height * scale
|
||||
val dst = android.graphics.RectF((width - w) / 2f, (height - h) / 2f, (width + w) / 2f, (height + h) / 2f)
|
||||
canvas.drawBitmap(picture, null, dst, android.graphics.Paint(android.graphics.Paint.FILTER_BITMAP_FLAG))
|
||||
val fade = android.graphics.Paint().apply {
|
||||
shader = android.graphics.LinearGradient(0f, 0f, width.toFloat(), 0f,
|
||||
intArrayOf(Navy.copy(alpha = .97f).toArgb(), Navy.copy(alpha = .88f).toArgb(), Navy.copy(alpha = .35f).toArgb(), Navy.copy(alpha = .15f).toArgb()),
|
||||
floatArrayOf(0f, .45f, .75f, 1f), android.graphics.Shader.TileMode.CLAMP)
|
||||
}
|
||||
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), fade)
|
||||
return out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user