perf(player): 限制雪碧图与海报预缓存内存并给播放位置缓存加容量上限

雪碧图解码从 2048 降到 1024、缓存从 8 张降到 3 张,避免擦洗预览驻留十几 MB 位图;
相邻集海报预缓存改用 ResizeImage 按 360/720 宽解码,不再缓存整张原图;
播放位置缓存按写入时间淘汰,最多保留 100 条,长会话不再只增不减;
观看记录详情失败日志加 kDebugMode 保护,release 下不再逐条打堆栈。
This commit is contained in:
Vicky authored and trae-solo-agent committed 2026-10-29 11:25:47 +08:00
1 parent fb9001a02d
commit 0f777b19f2
5 files changed
+82 -14

No files matched your search

@@ -89,6 +89,25 @@ void main() {
expect(cache.latestForDrama('drama-a')?.episodeId, 'episode-2');
});
test('should_evict_oldest_entry_when_capacity_exceeded', () {
var now = DateTime(2026, 10, 22, 12);
final cache = PlaybackPositionCache(now: () => now, maxEntries: 2);
for (final episodeId in ['episode-1', 'episode-2', 'episode-3']) {
cache.save(
episodeId: episodeId,
dramaId: 'drama-a',
position: const Duration(seconds: 30),
duration: const Duration(minutes: 3),
);
now = now.add(const Duration(minutes: 1));
}
expect(cache.read('episode-1', dramaId: 'drama-a'), isNull);
expect(cache.read('episode-2', dramaId: 'drama-a'), isNotNull);
expect(cache.read('episode-3', dramaId: 'drama-a'), isNotNull);
});
test('should_reject_expired_cached_position', () {
var now = DateTime(2026, 10, 22, 12);
final cache = PlaybackPositionCache(now: () => now);