iielse / imageviewer

A simple and customizable Android full-screen image viewer 一个简单且可自定义的Android全屏图像浏览器
MIT License
2.23k stars 310 forks source link

视频播放内存溢出 #138

Closed zhangkun0018 closed 2 years ago

zhangkun0018 commented 2 years ago

最新版本,连续切换,播放多次后会出现内存溢出问题: 2022-09-26 16:13:12.178 16835-17167/com.github.iielse.imageviewer.demo E/LoadTask: OutOfMemory error loading stream java.lang.OutOfMemoryError: Failed to allocate a 65552 byte allocation with 48504 free bytes and 47KB until OOM, target footprint 268435456, growth limit 268435456 at com.google.android.exoplayer2.upstream.DefaultAllocator.allocate(DefaultAllocator.java:104) at com.google.android.exoplayer2.source.SampleDataQueue.preAppend(SampleDataQueue.java:240) at com.google.android.exoplayer2.source.SampleDataQueue.sampleData(SampleDataQueue.java:174) at com.google.android.exoplayer2.source.SampleQueue.sampleData(SampleQueue.java:579) at com.google.android.exoplayer2.extractor.TrackOutput.sampleData(TrackOutput.java:153) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.readSample(Mp4Extractor.java:613) at com.google.android.exoplayer2.extractor.mp4.Mp4Extractor.read(Mp4Extractor.java:247) at com.google.android.exoplayer2.source.BundledExtractorsAdapter.read(BundledExtractorsAdapter.java:127) at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:1047) at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:409) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)

iielse commented 2 years ago

demo弄得出来把, 怎么个切法,是打开预览 退出预览, 还是左右滑动切换 还是什么

复现了

iielse commented 2 years ago

bug 找到了release 没走. 上个版本支持全屏播放的时候 引入的 bug ExoVideoView 里面 private var ar = false 这里写错了, 默认值应该用true

这个版本你可以暂时 用 setAutoRelease 方法设置成true 在viewHolder 初始化的时候

iielse commented 2 years ago

或者先用 18. 等下我确认好后 发个 20. 把exoVideoView的 是否自动释放的默认值换成true

实锤了,就应该是这个原因了,我现在来回切换30多次没啥问题。

iielse commented 2 years ago

@zhangkun0018 用 2.1.20 试试, 应该好了。 [这个bug在2.1.19展示内容有video的时候会出现]

zhangkun0018 commented 2 years ago

好的,谢谢,2.1.20 使用后问题解决了。