Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaSourceResultsPresentation memory leak #1565

Open
Him188 opened this issue Jan 22, 2025 · 1 comment
Open

MediaSourceResultsPresentation memory leak #1565

Him188 opened this issue Jan 22, 2025 · 1 comment
Assignees
Labels
C 严重优先级, 需要立即修复 s: ui 子系统: UI
Milestone

Comments

@Him188
Copy link
Member

Him188 commented Jan 22, 2025

问题描述

me.him188.ani.app.ui.subject.episode.EpisodeViewModel#getPageState 里面创建 MediaSourceResultsPresentation 会传入 backgroundScope.coroutineContext.

而 MediaSourceResultsPresentation 会在这个 context 下 launch job, 导致 presentation 对象 leak (这涉及整个数据源匹配链路上的所有对象). 最近见到几个 OOM 报告, 应该就是这个导致的

只要有任一以下 flow 变更就会 leak 一份实例.

fetchPlayState.episodeSessionFlow.flatMapLatest { episodeSession ->
        me.him188.ani.utils.coroutines.flows.combine(
            episodeSession.infoBundleFlow.distinctUntilChanged().onStart { emit(null) },
            episodeSession.infoLoadErrorStateFlow,
            episodeSession.fetchSelectFlow,
            combine(
                danmakuLoader.danmakuLoadingStateFlow,
                danmakuLoader.fetchResults,
                settingsRepository.danmakuEnabled.flow,
                ::DanmakuStatistics,
            ).distinctUntilChanged(),
            settingsRepository.danmakuEnabled.flow,
            settingsRepository.danmakuConfig.flow,
        ) 

复现步骤

No response

Ani 版本号

440a3

操作系统

No response

应用日志



@Him188 Him188 added C 严重优先级, 需要立即修复 s: ui 子系统: UI labels Jan 22, 2025
@Him188 Him188 self-assigned this Jan 22, 2025
@Him188
Copy link
Member Author

Him188 commented Jan 22, 2025

这块代码比较难改 (media selector ui 太烂), 我打算吧 media selector 的 ui 重构了来解决这个问题

@Him188 Him188 added this to the 4.4.0 milestone Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C 严重优先级, 需要立即修复 s: ui 子系统: UI
Projects
None yet
Development

No branches or pull requests

1 participant