fix: limit mem cache resolution
This commit is contained in:
@@ -1032,6 +1032,19 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
heroItem.art ?? heroItem.grandparentArt,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
memCacheWidth:
|
||||
(MediaQuery.of(context).size.width *
|
||||
MediaQuery.of(context).devicePixelRatio)
|
||||
.clamp(900, 2400)
|
||||
.round(),
|
||||
memCacheHeight:
|
||||
(MediaQuery.of(context).size.height *
|
||||
MediaQuery.of(
|
||||
context,
|
||||
).devicePixelRatio *
|
||||
0.7)
|
||||
.clamp(600, 1600)
|
||||
.round(),
|
||||
placeholder: (context, url) => Container(
|
||||
color: Theme.of(
|
||||
context,
|
||||
@@ -1099,6 +1112,13 @@ class _DiscoverScreenState extends State<DiscoverScreen>
|
||||
),
|
||||
filterQuality: FilterQuality.medium,
|
||||
fit: BoxFit.contain,
|
||||
memCacheWidth:
|
||||
(400 *
|
||||
MediaQuery.of(
|
||||
context,
|
||||
).devicePixelRatio)
|
||||
.clamp(200, 800)
|
||||
.round(),
|
||||
alignment: isLargeScreen
|
||||
? Alignment.bottomLeft
|
||||
: Alignment.bottomCenter,
|
||||
|
||||
@@ -27,7 +27,6 @@ class VideoFilterManager {
|
||||
/// Current player viewport size
|
||||
Size? _playerSize;
|
||||
|
||||
|
||||
/// Debounced video filter update with leading edge execution
|
||||
late final Debounce _debouncedUpdateVideoFilter;
|
||||
|
||||
@@ -87,7 +86,6 @@ class VideoFilterManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Update the video scaling and positioning based on current display mode
|
||||
void updateVideoFilter() async {
|
||||
try {
|
||||
|
||||
@@ -978,15 +978,27 @@ Widget _buildPosterImage(BuildContext context, dynamic item) {
|
||||
}
|
||||
|
||||
if (posterUrl != null) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final client = _getClientForItem(context, item);
|
||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
// Fall back to a reasonable size if constraints are unbounded.
|
||||
final targetWidth =
|
||||
(constraints.maxWidth.isFinite ? constraints.maxWidth : 160) *
|
||||
devicePixelRatio;
|
||||
final targetHeight =
|
||||
(constraints.maxHeight.isFinite ? constraints.maxHeight : 240) *
|
||||
devicePixelRatio;
|
||||
|
||||
return CachedNetworkImage(
|
||||
imageUrl: client.getThumbnailUrl(posterUrl!),
|
||||
fit: BoxFit.cover,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
// Decode close to the rendered size to keep memory in check when
|
||||
// many posters load at once.
|
||||
memCacheWidth: targetWidth.clamp(120, 800).round(),
|
||||
memCacheHeight: targetHeight.clamp(180, 1200).round(),
|
||||
filterQuality: FilterQuality.medium,
|
||||
fadeInDuration: const Duration(milliseconds: 300),
|
||||
placeholder: (context, url) => const SkeletonLoader(),
|
||||
|
||||
@@ -168,6 +168,7 @@ class _PlaylistItemCardState extends State<PlaylistItemCard>
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
final client = _getClientForItem(context);
|
||||
final devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
|
||||
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
@@ -175,6 +176,8 @@ class _PlaylistItemCardState extends State<PlaylistItemCard>
|
||||
imageUrl: client.getThumbnailUrl(posterUrl),
|
||||
width: 60,
|
||||
height: 90,
|
||||
memCacheWidth: (60 * devicePixelRatio).round(),
|
||||
memCacheHeight: (90 * devicePixelRatio).round(),
|
||||
fit: BoxFit.cover,
|
||||
placeholder: (context, url) => _buildPlaceholder(),
|
||||
errorWidget: (context, url, error) => _buildPlaceholder(),
|
||||
|
||||
Reference in New Issue
Block a user