fix: Crash on software mode emulators (#13067) a5bf12c58e
This PR fixes a deterministic Android emulator GPU-process crash when rendering some .riv files on software/headless emulators.

These emulators route GLES through ANGLE onto "SwiftShader", which is Google’s CPU Vulkan implementation used when no host GPU path is available. In that stack, our advanced-blend destination-read fallback can trigger host-side memory corruption when resolving partial framebuffer regions. This change detects Android "ANGLE-on-SwiftShader" and avoids the crash-prone partial resolve path by doing one full-target destination copy per advanced-blend barrier.

Hardware GPUs, -gpu host emulators, WebGL, desktop GL, and native Vulkan keep the existing optimized behavior.

Co-authored-by: Erik <erik@rive.app>
diff --git a/.rive_head b/.rive_head
index 451a471..9f10cf6 100644
--- a/.rive_head
+++ b/.rive_head
@@ -1 +1 @@
-9c7a56dfc0035b963f609c6f09c5be820ca09b85
+a5bf12c58e594a10de1f24c47f257bdd0c3764f5
diff --git a/renderer/include/rive/renderer/gl/gles3.hpp b/renderer/include/rive/renderer/gl/gles3.hpp
index af88b2e..e3686a9 100644
--- a/renderer/include/rive/renderer/gl/gles3.hpp
+++ b/renderer/include/rive/renderer/gl/gles3.hpp
@@ -201,6 +201,9 @@
     // ANGLE_shader_pixel_local_storage is currently broken with
     // GL_TEXTURE_2D_ARRAY on ANGLE's d3d11 renderer.
     bool avoidTexture2DArrayWithWebGLPLS;
+    // Android ANGLE backed by SwiftShader can corrupt memory when resolving
+    // partial framebuffer regions. Resolve the full target as a workaround.
+    bool avoidPartialFramebufferBlits;
 
     // Extensions
     bool ANGLE_base_vertex_base_instance_shader_builtin : 1;
diff --git a/renderer/src/gl/render_context_gl_impl.cpp b/renderer/src/gl/render_context_gl_impl.cpp
index e882e98..d5ca8f2 100644
--- a/renderer/src/gl/render_context_gl_impl.cpp
+++ b/renderer/src/gl/render_context_gl_impl.cpp
@@ -2874,15 +2874,29 @@
                 assert(batch.dstReadList != nullptr);
                 renderTarget->bindDstColorFramebuffer(GL_DRAW_FRAMEBUFFER);
                 m_state->disableScissor();
-                for (const Draw* draw = batch.dstReadList; draw != nullptr;
-                     draw = draw->nextDstRead())
+                if (m_capabilities.avoidPartialFramebufferBlits)
                 {
-                    assert(draw->blendMode() != BlendMode::srcOver);
+                    // A single full-target copy contains every destination
+                    // pixel needed by this batch. This intentionally trades
+                    // bandwidth for stability on Android ANGLE/SwiftShader,
+                    // whose partial resolves can corrupt host memory.
                     glutils::BlitFramebuffer(
-                        desc.renderTargetUpdateBounds.intersect(
-                            draw->pixelBounds()),
+                        IAABB::MakeWH(renderTarget->width(),
+                                      renderTarget->height()),
                         renderTarget->height());
                 }
+                else
+                {
+                    for (const Draw* draw = batch.dstReadList; draw != nullptr;
+                         draw = draw->nextDstRead())
+                    {
+                        assert(draw->blendMode() != BlendMode::srcOver);
+                        glutils::BlitFramebuffer(
+                            desc.renderTargetUpdateBounds.intersect(
+                                draw->pixelBounds()),
+                            renderTarget->height());
+                    }
+                }
                 renderTarget->bindMSAAFramebuffer(this, desc.msaaSampleCount);
             }
         }
@@ -3301,6 +3315,11 @@
     capabilities.isAdreno = strstr(rendererString, "Adreno");
     capabilities.isMali = strstr(rendererString, "Mali");
     capabilities.isPowerVR = strstr(rendererString, "PowerVR");
+#ifdef RIVE_ANDROID
+    capabilities.avoidPartialFramebufferBlits =
+        capabilities.isANGLESystemDriver &&
+        strstr(rendererString, "SwiftShader") != nullptr;
+#endif
 
     if (!capabilities.isGLES)
     {