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

[Bug]: 使用AndroidNativeView渲染视频,会出现卡住,无法渲染的情况 #2168

Open
joechan-cq opened this issue Dec 27, 2024 · 0 comments
Labels
Android Android Only

Comments

@joechan-cq
Copy link
Collaborator

请描述遇到的问题,以及您所期望的正确的结果

使用AndroidNativeView进行视频渲染的界面,在从二级页回退回来时,出现渲染卡住的情况,刷屏报如下错误:

ImageReader dequeueBuffer: BufferQueue has been abandoned

请说明如何操作会遇到上述问题

No response

在下面填入关键复现代码

复现的平台

Android

Flutter SDK版本

3.22.2

FlutterBoost版本

5.0.2

是否延迟初始化FlutterBoost

No

解决方案

原因是Flutter 3.22.2版本开始,FlutterActivityAndFragmentDelegate.java文件的onStop方法中,新增了如下的代码

image

新增的onTrimMemory会使得导致渲染NativeView用的PerImageReader调用close
这个onStop是绑定FlutterActivity的onStop触发的,因此在FlutterBoost的场景下,一级页面中有AndroidNativeView时,从二级页面返回时,因为先触发一级页面的onResume,后触发二级页面的onStop,就导致后面的onStop把一级页面渲染用的PerImageReaderclose了,所以出现了问题。

临时解决方案:设置

FlutterRenderer.debugForceSurfaceProducerGlTextures = true;

这个会把NativeView的渲染从ImageReaderSurfaceProducer改回SurfaceTextureSurfaceProducer,相当于使用老版本的方案。

@joechan-cq joechan-cq added the Android Android Only label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android Only
Projects
None yet
Development

No branches or pull requests

1 participant