一、 问题描述
GLSurfaceView运行期间抛出OOM崩溃:
07-22 11:47:19.919 24862 25042 W Adreno-GSL: <sharedmem_gpuobj_alloc:2713>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory
07-22 11:47:19.920 24862 25042 E Adreno-GSL: <gsl_memory_alloc_pure:2297>: GSL MEM ERROR: kgsl_sharedmem_alloc ioctl failed.
07-22 11:47:19.921 24862 25042 E OpenGLRenderer: GL error: Out of memory!
07-22 11:47:19.921 24862 25042 F OpenGLRenderer: GL errors! frameworks/base/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.cpp:138
二、 问题原因
这个问题在Google上一搜一大堆,没有明确的解释native层如何引起崩溃,先大致回顾以下绘制流程:
开启硬件加速后,会创建Render Thread,当Vsync信号来到时,执行Choreographer中的traversal这个callback,即UI线程绘制操作,绘制操作会被记录到DisplayList中,同步到Render线程,并渲染出最终的buffer,交给SurfaceFlinger去合成,最终展示在显示屏上。
而该OOM问题对应的SkiaOpenGLPipeline,位于上述Render线程的渲染过程中,