表现形式
在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。