feat(android,web): 实现本地缓存与预加载优化,修复多项体验问题 - #24
Merged
Merged
Conversation
本次提交完成多维度功能升级与问题修复:
1. 新增Android端原生缓存插件,实现封面、歌词、列表数据的本地LRU缓存管理,支持自定义缓存上限与自动清理
2. 全量接入缓存驱动的图片加载:为SImage新增cacheType参数,自动复用本地缓存Blob URL,减少网络请求与加载抖动
3. 实现音频预加载优化:Android端预下载下一首音频前512KB,切歌秒级响应
4. 优化歌词渲染性能:使用requestIdleCallback异步构建歌词动画,避免主线程阻塞
5. 修复多项已知问题:
- 修复播放历史列表序列化O(N²)性能问题
- 修复歌单续传加载逻辑,避免全量重拉已有数据
- 修复Android后台播放队列重置时跳过首曲的BUG
6. 新增缓存设置面板,支持分项清理与实时占用统计
7. 流媒体场景新增本地缓存兜底,离线也可查看已缓存歌单
将原有的播放音质和音源的推断逻辑抽离为inferNativePlaybackInfo私有方法, 简化prepareSongToPlay和applyNativeTrackChanged两处重复代码,统一播放信息的处理逻辑。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 变更类型
📝 变更说明
本次提交是一次围绕「Android 端缓存与播放体验」的综合升级,跨 Vue 渲染层、Capacitor 桥层、Android 原生层三端协同:
1. 原生缓存基础设施(新增)
封面 / 歌词 / 列表数据全部走本地 LRU;支持自定义缓存上限(最低 256 MB,可设小数)与自动驱逐最久未访问条目2. 图片加载缓存化
SImage组件新增cacheType参数,按调用点声明缓存域(covers/list-covers/none),命中后复用 Blob URL,减少重复网络请求与首屏抖动memoryHitGet/Put/Release三态生命周期,配合卸载时主动 release,避免内存泄漏3. 音频缓存与预加载
CacheDataSource;resolveCacheKey 提取音频文件名作为稳定 key,跨签名 URL 也能命中Content-Length严格校验后标记 promoted(automix 与离线场景的可信源)4. 歌词渲染性能
requestIdleCallback异步构建歌词动画,避免在切歌热路径阻塞主线程5. Bug 修复
cached.songs.length偏移续传current(),常规右滑窗口仍走advanceRaw(false)currentAudioSource滞留导致下一首 URL 推错cache.getCachedBytesvsContentMetadata.getContentLength)allowBackup备份范围:排除 WebView 存储 / 登录 cookie / Capacitor SharedPreferences,避免跨设备恢复泄露账号会话🔗 关联 Issue
Closes #
📱 影响范围
✅ 自检清单
devpnpm lint且无 warningpnpm typecheck且无报错📸 截图 / 录屏
🧪 测试方式
prefetch done);同一首再播一遍,无 HTTP upstream 日志adb backup -f x.ab <pkg>后用abe.jar解包,确认app_webview/与CapacitorStorage.xml不在备份内容中💬 其他说明
windowResetFromWrap字段,JS / Java 同步落地;旧版混用时降级为默认 false,行为退回原advanceRaw路径(不致命)