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

E/AnimPlayer.AnimConfigManager: parseConfig error java.lang.IllegalStateException: AssetInputStream is closed #189

Closed
W-quan opened this issue Dec 18, 2021 · 11 comments

Comments

@W-quan
Copy link

W-quan commented Dec 18, 2021

  1. 问题描述(重现路径)

RecyclerView 里使用,在item移除触发 onDetachedFromWindow() 后, 再进入触发 onAttachedToWindow() 后。

  1. 运行环境(手机型号,Android/iOS版本等)

Android, vap 版本2.0.23

  1. 相关日志
 E/AnimPlayer.AnimConfigManager: parseConfig error java.lang.IllegalStateException: AssetInputStream is closed
    java.lang.IllegalStateException: AssetInputStream is closed
        at android.content.res.AssetManager$AssetInputStream.ensureOpen(AssetManager.java:1215)
        at android.content.res.AssetManager$AssetInputStream.read(AssetManager.java:1154)
        at com.tencent.qgame.animplayer.file.AssetsFileContainer.read(AssetsFileContainer.kt:50)
        at com.tencent.qgame.animplayer.AnimConfigManager.parse(AnimConfigManager.kt:128)
        at com.tencent.qgame.animplayer.AnimConfigManager.parseConfig(AnimConfigManager.kt:45)
        at com.tencent.qgame.animplayer.AnimPlayer$startPlay$1.run(AnimPlayer.kt:89)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:65)
2021-12-18 17:46:11.924 5317-6704/com.ormatch.android.asmr E/AnimPlayer.Decoder: onFailed errorType=10005, errorMsg=0x5 parse config fail 

@hexleo
Copy link
Collaborator

hexleo commented Dec 20, 2021

你应该是读取的Assets里的文件吧,建议改为file读取,assets文件不知道为什么读取有兼容问题

你参考看看是不是这个问题:#168

@W-quan
Copy link
Author

W-quan commented Dec 20, 2021

图片

我真的是麻了,播放个文件都要各种判断。 正常的API设计不是应该指定个文件地址就 everything is fine 的吗

@W-quan
Copy link
Author

W-quan commented Dec 20, 2021

onSizeChanged() 应该换成 onLayoutChange()。 控件在大小不变的情况下, 显隐不会再调用onSizeChanged()。

另外 isRunning() 判断也是有问题。明明上次已经播放失败了。 结果还是提示 is running。

建议调用startPlay()后,如果isRunning, 则替换新的任务,而不是 报错。

@hexleo
Copy link
Collaborator

hexleo commented Dec 21, 2021

你遇到的是不是这个问题?#180 在2.0.23已经修复了才对,你的复现场景是什么样的?麻烦提供下完整的日志

@W-quan
Copy link
Author

W-quan commented Dec 21, 2021

recycleview 里 item 再次进入屏幕, 不会调用onSizeChanged(), 2.0.23新增了 isCallSizeChange字段。 所以无法播放。

我已经回退版本

@hexleo
Copy link
Collaborator

hexleo commented Dec 21, 2021

你切换到这个分支试试 bugfix/android_state_error,在onDetachedFromWindow的时候不会重置onSizeChangedCalled标志位。但有个问题,你这个应该是view的大小没变化所以没有回调onSizeChanged,如果你这个view在复用之后size变化了,而播放已经开始,就会导致第二次播放变形,你只能保证复用后size不能变化才行。

你先测试下,没问题我再发布新版本

@W-quan
Copy link
Author

W-quan commented Jan 7, 2022

@hexleo 抱歉,久等了

测试通过

另外发现了一个新问题, 跳转到新activity后,logcat依旧一直打印日志。 这应该是没有停止吧。 这需要手动停止?

2022-01-07 11:40:11.193 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] Now Flushing
2022-01-07 11:40:11.198 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] FlushingState onOMXEvent(0,1,1)
2022-01-07 11:40:11.198 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] FlushingState onOMXEvent(0,1,0)
2022-01-07 11:40:11.198 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] Now Executing
2022-01-07 11:40:21.157 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] signalFlush
2022-01-07 11:40:21.157 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] ExecutingState flushing now (codec owns 0/4 input, 0/4 output).
2022-01-07 11:40:21.157 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] Now Flushing
2022-01-07 11:40:21.162 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] FlushingState onOMXEvent(0,1,0)
2022-01-07 11:40:21.162 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] FlushingState onOMXEvent(0,1,1)
2022-01-07 11:40:21.162 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] Now Executing
2022-01-07 11:40:23.263 24741-25046/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] signalFlush
2022-01-07 11:40:23.263 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] ExecutingState flushing now (codec owns 0/4 input, 3/11 output).
2022-01-07 11:40:23.263 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] Now Flushing
2022-01-07 11:40:23.267 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] FlushingState onOMXEvent(0,1,1)
2022-01-07 11:40:23.267 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] FlushingState onOMXEvent(0,1,0)
2022-01-07 11:40:23.267 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] Now Executing
2022-01-07 11:40:33.178 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] signalFlush
2022-01-07 11:40:33.179 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] ExecutingState flushing now (codec owns 0/4 input, 0/4 output).
2022-01-07 11:40:33.181 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] Now Flushing
2022-01-07 11:40:33.182 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] FlushingState onOMXEvent(0,1,0)
2022-01-07 11:40:33.182 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] FlushingState onOMXEvent(0,1,1)
2022-01-07 11:40:33.182 24741-25057/com.tencent.qgame.playerproj I/ACodec: [OMX.google.aac.decoder] Now Executing
2022-01-07 11:40:35.352 24741-25046/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] signalFlush
2022-01-07 11:40:35.353 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] ExecutingState flushing now (codec owns 0/4 input, 3/11 output).
2022-01-07 11:40:35.353 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] Now Flushing
2022-01-07 11:40:35.357 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] FlushingState onOMXEvent(0,1,1)
2022-01-07 11:40:35.357 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] FlushingState onOMXEvent(0,1,0)
2022-01-07 11:40:35.358 24741-25047/com.tencent.qgame.playerproj I/ACodec: [OMX.qcom.video.decoder.avc] Now Executing

@W-quan
Copy link
Author

W-quan commented Jan 7, 2022

建议加个

 override fun onVisibilityChanged(changedView: View, visibility: Int) {
        
 }

@hexleo
Copy link
Collaborator

hexleo commented Jan 10, 2022

view如果有执行onDetachWindow就会自动结束,如果没有执行就不会自动结束。但看你的发的日志都是系统的解码日志,没看到vap相关日志

@W-quan
Copy link
Author

W-quan commented Jan 10, 2022

跳转到新activity后, 并不会 执行 onDetachWindow,所以不会结束。日志确实是vap没结束产生的。

想要自动结束,还是要用 onVisibilityChanged,或者 onWindowFoucusChanged

@hexleo
Copy link
Collaborator

hexleo commented Jan 10, 2022

 跳转activity是指新打开一个activity,还是指上一个activity被关闭。如果是关闭activity,因为onDetachWindow是系统回收view的时候必须回调的,如果没有回调说明有可能出现activity泄漏。如果是打开新的activity,是否停止播放需要自己实现

@W-quan W-quan closed this as completed Jan 10, 2022
hexleo added a commit that referenced this issue Jan 11, 2022
bug: 解决recycleview view复用导致无法播放的问题 close #189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants