Android crash after en error log from CreateProgramShaderUniformBridge

Hi, I have a crash on Android on certain devices currently only PowerVR GE8320 graphic devices are concerned but I don’t have lot of test devices.

On the logs I have the following error:

Error IMGSRV CreateProgramShaderUniformBridge: recompiled revision contains on-opaque uniform which cannot be found in initial revision

Followed by a crash:

CRASH *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
CRASH Version '6000.0.33f1 (433b0a79340b)', Build type 'Development', Scripting Backend 'il2cpp', CPU 'arm64-v8a', Stripping 'Disabled'
CRASH Build fingerprint: 'OPPO/CPH2349T2/OP5321:11/RP1A.200720.011/1725938230840:user/release-keys'
CRASH Revision: '0'
CRASH ABI: 'arm64'
CRASH Timestamp: 2025-01-21 17:44:59.770819919+0400
CRASH pid: 25195, tid: 26559, name: UnityGfxDeviceW  >>> com.lagoonsoft.pm <<<
CRASH uid: 10374
CRASH signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr --------
CRASH Cause: null pointer dereference
CRASH     x0  b4000078b2d79980  x1  0000000000000000  x2  b4000078b28b55a0  x3  b40000790e4ec6f0
CRASH     x4  b4000078b28b55a0  x5  0000000000000000  x6  0000000000000000  x7  0000000000000001
CRASH     x8  00000078fee4b27c  x9  0000000000000000  x10 0000000000000000  x11 b400000000000000
CRASH     x12 00000078b2a9c340  x13 00000078b2a9cac0  x14 0000000000000020  x15 0000000000000005
CRASH     x16 0000007900625b28  x17 000000799fc26c68  x18 00000077a5b5e000  x19 b4000078b2d79980
CRASH     x20 b40000790e4ec6f0  x21 0000000000000000  x22 b4000078b28b55a0  x23 b4000078b28a0e00
CRASH     x24 00000078feefadc8  x25 0000000000000000  x26 b40000790e5bb600  x27 0000000000000001
CRASH     x28 0000000000000000  x29 00000078ae1d73f0
CRASH     lr  00000078fee52a10  sp  00000078ae1d73f0  pc  00000078fee4b290  pst 0000000060000000
CRASH backtrace:
CRASH       #00 pc 0000000000106290  /vendor/lib64/egl/libGLESv2_mtk.so (BuildId: 6240319d489f6c9551fbba9faf1ab558)
CRASH       #01 pc 000000000010da0c  /vendor/lib64/egl/libGLESv2_mtk.so (BuildId: 6240319d489f6c9551fbba9faf1ab558)
CRASH       #02 pc 0000000000073624  /vendor/lib64/egl/libGLESv2_mtk.so (BuildId: 6240319d489f6c9551fbba9faf1ab558)
CRASH       #03 pc 0000000000032b5c  /vendor/lib64/libsrv_um.so (BuildId: af5cb1979a82072235bbb413f82a7c01)
CRASH       #04 pc 00000000000db188  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: a6e89496b61a77b8a97118405d4e247e)
CRASH       #05 pc 000000000007a9d0  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: a6e89496b61a77b8a97118405d4e247e)
CRASH Forwarding signal 11

I currently have 2 similar cases on my game when this crash happens and on the 2 cases here what is done:

  • instantiate a prefab.
  • play an animation.
    • on the first case the animation is done by an animator and awaited until the end.
    • on the second the animation is done by chained DOTweens with some async delays.
  • destroy the gameobject.

All async code uses Awaitable.

I don’t know where the problem really happens here because I see the crash log on the console some times before the crash happens. The crash log appear at instantiation or maybe a little after, but the animation always complete before the app crash.

I’m still investigating to find more information.
Any help would be appreciated to help me fix this.

EDIT 1:

  • the crash occurs only on the first game launch after install or update of the game on the device.

Ok, it seems that the crash was caused by a custom Shader on some sprite renderers.
I converted the shader to a shader graph equivalent and the crash disappeared.

Here is the faulty one:
mostly a copy of URP Sprite-Unlit-Default shader with a lerp on the color at fragment stage.

Shader "lagoonSoft/SpriteTint"
{
    Properties
    {
        _MainTex ("Sprite Texture", 2D) = "white" {}
        _TintPower ("Tint Power", Range (0, 1)) = 0
        [HDR]_TintColor ("TintColor", Color) = (1,1,1,1)

        // Legacy properties. They're here so that materials using this shader can gracefully fallback to the legacy sprite shader.
        [HideInInspector] _Color ("Tint", Color) = (1,1,1,1)
        [HideInInspector] PixelSnap ("Pixel snap", Float) = 0
        [HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
        [HideInInspector] _AlphaTex ("External Alpha", 2D) = "white" {}
        [HideInInspector] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
    }

    SubShader
    {
        Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" }

        Blend SrcAlpha OneMinusSrcAlpha
        Cull Off
        ZWrite Off

        Pass
        {
            Tags { "LightMode" = "Universal2D" }

            HLSLPROGRAM
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
            #if defined(DEBUG_DISPLAY)
            #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
            #endif

            #pragma vertex UnlitVertex
            #pragma fragment UnlitFragment

            #pragma multi_compile _ DEBUG_DISPLAY SKINNED_SPRITE

            struct Attributes
            {
                float3 positionOS   : POSITION;
                float4 color        : COLOR;
                float2 uv           : TEXCOORD0;
                UNITY_SKINNED_VERTEX_INPUTS
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct Varyings
            {
                float4  positionCS  : SV_POSITION;
                half4   color       : COLOR;
                float2  uv          : TEXCOORD0;
                #if defined(DEBUG_DISPLAY)
                float3  positionWS  : TEXCOORD2;
                #endif
                UNITY_VERTEX_OUTPUT_STEREO
            };

            TEXTURE2D(_MainTex);
            SAMPLER(sampler_MainTex);
            UNITY_TEXTURE_STREAMING_DEBUG_VARS_FOR_TEX(_MainTex);

            // NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
            CBUFFER_START(UnityPerMaterial)
                half4 _Color;
                half4 _TintColor;
                float _TintPower;
            CBUFFER_END

            Varyings UnlitVertex(Attributes v)
            {
                Varyings o = (Varyings)0;
                UNITY_SETUP_INSTANCE_ID(v);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
                UNITY_SKINNED_VERTEX_COMPUTE(v);

                v.positionOS = UnityFlipSprite(v.positionOS, unity_SpriteProps.xy);
                o.positionCS = TransformObjectToHClip(v.positionOS);
                #if defined(DEBUG_DISPLAY)
                o.positionWS = TransformObjectToWorld(v.positionOS);
                #endif
                o.uv = v.uv;
                o.color = /*unity_SpriteColor;*/v.color * _Color * unity_SpriteColor;
                return o;
            }

            half4 UnlitFragment(Varyings i) : SV_Target
            {
                float4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);

                #if defined(DEBUG_DISPLAY)
                SurfaceData2D surfaceData;
                InputData2D inputData;
                half4 debugColor = 0;

                InitializeSurfaceData(mainTex.rgb, mainTex.a, surfaceData);
                InitializeInputData(i.uv, inputData);
                SETUP_DEBUG_TEXTURE_DATA_2D_NO_TS(inputData, i.positionWS, i.positionCS, _MainTex);

                if(CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
                {
                    return debugColor;
                }
                #endif

                // colorize
                const float4 col = float4(_TintColor.r,_TintColor.g,_TintColor.b,_TintColor.a*mainTex.a);
                if (_TintPower > 0 )
                    mainTex = lerp(mainTex,col,_TintPower);
                
                return mainTex;
            }
            ENDHLSL
        }

        Pass
        {
            Tags { "LightMode" = "UniversalForward" "Queue"="Transparent" "RenderType"="Transparent"}

            HLSLPROGRAM
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl"
            #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl"
            #if defined(DEBUG_DISPLAY)
            #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl"
            #endif

            #pragma vertex UnlitVertex
            #pragma fragment UnlitFragment

            #pragma multi_compile_fragment _ DEBUG_DISPLAY

            struct Attributes
            {
                float3 positionOS   : POSITION;
                float4 color        : COLOR;
                float2 uv           : TEXCOORD0;
                UNITY_SKINNED_VERTEX_INPUTS
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct Varyings
            {
                float4  positionCS      : SV_POSITION;
                float4  color           : COLOR;
                float2  uv              : TEXCOORD0;
                #if defined(DEBUG_DISPLAY)
                float3  positionWS      : TEXCOORD2;
                #endif
                UNITY_VERTEX_OUTPUT_STEREO
            };

            TEXTURE2D(_MainTex);
            SAMPLER(sampler_MainTex);
            UNITY_TEXTURE_STREAMING_DEBUG_VARS_FOR_TEX(_MainTex);

            // NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
            CBUFFER_START( UnityPerMaterial )
                half4 _Color;
                half4 _TintColor;
                float _TintPower;
            CBUFFER_END

            Varyings UnlitVertex(Attributes attributes)
            {
                Varyings o = (Varyings)0;
                UNITY_SETUP_INSTANCE_ID(attributes);
                UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
                UNITY_SKINNED_VERTEX_COMPUTE(attributes);

                attributes.positionOS = UnityFlipSprite(attributes.positionOS, unity_SpriteProps.xy);
                o.positionCS = TransformObjectToHClip(attributes.positionOS);
                #if defined(DEBUG_DISPLAY)
                o.positionWS = TransformObjectToWorld(attributes.positionOS);
                #endif
                o.uv = attributes.uv;
                o.color = /*unity_SpriteColor;*/attributes.color * _Color * unity_SpriteColor;
                return o;
            }

            float4 UnlitFragment(Varyings i) : SV_Target
            {
                float4 mainTex = i.color * SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);

                #if defined(DEBUG_DISPLAY)
                SurfaceData2D surfaceData;
                InputData2D inputData;
                half4 debugColor = 0;

                InitializeSurfaceData(mainTex.rgb, mainTex.a, surfaceData);
                InitializeInputData(i.uv, inputData);
                SETUP_DEBUG_TEXTURE_DATA_2D_NO_TS(inputData, i.positionWS, i.positionCS, _MainTex);

                if(CanDebugOverrideOutputColor(surfaceData, inputData, debugColor))
                {
                    return debugColor;
                }
                #endif
                
                // colorize
                const float4 col = float4(_TintColor.r,_TintColor.g,_TintColor.b,_TintColor.a*mainTex.a);
                mainTex = lerp(mainTex,col,_TintPower);
                
                return mainTex;
            }
            ENDHLSL
        }
    }

    Fallback "Sprites/Default"
}

So… Anyone knows why a so simple shader can produce a crash like this only on certain device and only at first launch ??