Surface先进行lockCanvas,随后绘制视频引发的IlleageArgumentException

表现形式

在SurfaceView或者SurfaceTextture中,先对拿到serface,对其lockCanvas获得画布,绘画解除锁定后,又播放视频。出现了崩溃。

思路来源

  • https://stackoverflow.com/questions/48988467/using-a-surface-in-mediaplayer-after-it-has-been-manually-drawn-on
  • https://source.android.com/devices/graphics/arch-sh

解决方法

机制问题,无解决方法

原因

When you lock a Surface for Canvas access, the “CPU renderer” connects to the producer side of the BufferQueue and does not disconnect until the Surface is destroyed. Most other producers (like GLES) can be disconnected and reconnected to a Surface, but the Canvas-based “CPU renderer” cannot. This means you can’t draw on a surface with GLES or send it frames from a video decoder if you’ve ever locked it for a Canvas. — 官方文档(上面第二个链接)

机翻:

如果您曾调用过 lockCanvas(),则无法使用 GLES 在 Surface 上绘图或从视频解码器向其发送帧。lockCanvas() 会将 CPU 渲染程序连接到 BufferQueue 的生产方,直到 Surface 被销毁时才会断开连接。与大多数生产方(如 GLES 或 Vulkan)不同,基于画布的 CPU 渲染程序无法在断开连接后重新连接到 Surface。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值