Forums - Crash on Nexus 5 & 7 during shader linking

9 posts / 0 new
Last post
Crash on Nexus 5 & 7 during shader linking
Remi
Join Date: 14 May 14
Posts: 6
Posted: Thu, 2014-05-15 02:52

We have some generated shaders which trigger app crashes at link time on Nexus5 / Adreno330, whilst working on all other tested devices & GPUs (no other Adrenos tested though). Simply compiling and linking the shaders is enough to trigger the error, no rendering required.

While we've worked out which exact line in the fragment shader triggers the crash we need to understand a bit more about the underlying reason in order to implement a work-around in our code generator.

Fragment shader (this is where the trigger appears to be): 

#ifdef GL_ES

#extension GL_OES_standard_derivatives : enable

# ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
# else
precision mediump float;
# endif
#endif
#define g false
#define h true
#define i 1
#define j 3
#define k 3
#define l 3
#define m 3
#define n 3
#define o 3
#define p 3
#define q 3
#define r 3
#define s 3
#define t 3
uniform vec3 x[j], A[m], D[p], F[r], L;
uniform float y[k], z[l], B[n], C[o], E[q], G[s];
uniform int H[t];
uniform sampler2D T, U;
varying vec2 M;
varying vec3 N, O, P, Q, R;
varying float S;
vec4 V(vec3 W, vec3 X, vec3 Y, vec3 Z, vec4 aa, float ab){
    vec3 ac = vec3(0.0, 0.0, 0.0);
    for (int ad = 0; ad < i; ++ad)
    {
        vec3 ae = normalize(W - x[ad]);
       // float af = max(y[0], length(x[ad] - W) / z[ad]);        // this works
        float af = max(y[ad], length(x[ad] - W) / z[ad]);        // this crashes
 
        float ag = clamp(float(dot(X, -ae)), 0.0, 1.2);
        vec3 ah = ((float(ag) * Y) * A[ad]) / pow(af, B[ad]);
        vec3 ai = normalize(Z + ae);
        float aj = float(clamp(float(pow(dot(X, ai), C[ad])), 0.0, 2.0));
        vec3 ak = ((aj * Q) * D[ad]) / pow(af, E[ad]);
        vec3 al = (Y * F[ad]) / pow(af, G[ad]);
        ac = ac + (((al + ah) + ak) * float(H[ad]));
     }
     return mix(vec4(ac, 1.0), aa, ab);
}
void main()
{
    gl_FragColor = V(R, mat3(normalize(N), normalize(O), normalize(P)) * (g ? normalize((texture2D(T, M).xyz * 2.0) - 1.0) : vec3(0.0, 0.0, 1.0)), Q * (h ? texture2D(U, M) : vec4(1.0)).xyz, L, vec4(0.0, 0.0, 0.0, 0.0), S);
}
 
Both shaders also attached for convenience.
  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Thu, 2014-05-15 07:06

Hi Remi - thanks for reporting this problem.  At first attempt I'm not able to duplicate the crash using a development Adreno 330 device (no Nexus 5 available at the moment).

Are there any shader logs that are generated?  

Do you have the logcat for the crash? (Also let us know the Adreno version that shows up in the log)

Is there a build version and date for the Nexus 5?

Do you an apk that you can share which duplicates the linker crash?

 

thanks...

  • Up0
  • Down0
Remi
Join Date: 14 May 14
Posts: 6
Posted: Fri, 2014-05-16 00:38
Hi,
Here's the relevant logcat, as you can see the shader logs are completely empty.
 
The Nexus5 in question:
Baseband: M8974A-1.0.25.0.17
Kernel version: 3.4.0-g9eb14ba [email protected] #1 Tue Oct 22 15:43:47 PDT 2103
Build number: KRT16M
 
I've attached a small repro case.
 
I/Adreno-EGL(18230): <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM build:  (CL3776187)
I/Adreno-EGL(18230): OpenGL ES Shader Compiler Version: 
I/Adreno-EGL(18230): Build Date: 10/15/13 Tue
I/Adreno-EGL(18230): Local Branch: 
I/Adreno-EGL(18230): Remote Branch: partner/upstream
I/Adreno-EGL(18230): Local Patches: 
I/Adreno-EGL(18230): Reconstruct Branch: 
D/OpenGLRenderer(18230): Enabling debug mode 0
D/LinkerCrash(18230): **********************************************************************************************************************************************************************
D/LinkerCrash(18230): GL_RENDERER: Adreno (TM) 330
D/LinkerCrash(18230): GL_VERSION: OpenGL ES 3.0 [email protected] AU@  (CL@3776187)
D/LinkerCrash(18230): GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 3.00
D/LinkerCrash(18230): vshader compile status 1
D/LinkerCrash(18230): vs log: 
D/LinkerCrash(18230): fshader compile status 1
D/LinkerCrash(18230): fs log: 
I/ActivityManager(  772): Process com.example.myapplication.app (pid 18230) has died.
W/ActivityManager(  772): Force removing ActivityRecord{4297fcd8 u0 com.example.myapplication.app/.MainActivity t573}: app died, no saved state
I/WindowState(  772): WIN DEATH: Window{42bae828 u0 com.example.myapplication.app/com.example.myapplication.app.MainActivity}
I/WindowState(  772): WIN DEATH: Window{42bcbce8 u0 SurfaceView}
 
 
  • Up0
  • Down0
Remi
Join Date: 14 May 14
Posts: 6
Posted: Fri, 2014-05-16 00:43

Well, I don't seem to be able to attach anything else than .txt's, nor edit any other post than #1. Anyway, here is the repro case: https://www.dropbox.com/s/kddzvjag71v5w0x/LinkerCrash.apk

  • Up0
  • Down0
Remi
Join Date: 14 May 14
Posts: 6
Posted: Fri, 2014-05-16 06:21

We picked up a Nexus 7 (2013 edition, obviously) and while the bug did not trigger with Android 4.3 (default install) it *did* show up once the device had been upgraded to 4.4.2

Kernel version 3.4.0-gac9222c,  build time: Wed Nov 20 14:50:44 PST 2013.  Build number: KOT49H

logcat:

--------- beginning of /dev/log/system

I/ActivityManager(  605): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.myapplication.app/.Main
Activity} from pid 1037
--------- beginning of /dev/log/main
D/dalvikvm( 3041): Late-enabling CheckJNI
I/ActivityManager(  605): Start proc com.example.myapplication.app for activity com.example.myapplication.app/.MainActivity: pid=3041 uid=10069 gids={50069}
I/Adreno-EGL( 3041): <qeglDrvAPI_eglInitialize:320>: EGL 1.4 QUALCOMM Build: I0404c4692afb8623f95c43aeb6d5e13ed4b30ddbDate: 11/06/13
D/OpenGLRenderer( 3041): Enabling debug mode 0
D/LinkerCrash( 3041): ******************************************************************************************************************************************
****************************
D/LinkerCrash( 3041): GL_RENDERER: Adreno (TM) 320
D/LinkerCrash( 3041): GL_VERSION: OpenGL ES 3.0 [email protected] AU@  (CL@)
D/LinkerCrash( 3041): GL_SHADING_LANGUAGE_VERSION: OpenGL ES GLSL ES 3.00
D/LinkerCrash( 3041): vshader compile status 1
D/LinkerCrash( 3041): vs log:
D/LinkerCrash( 3041): fshader compile status 1
D/LinkerCrash( 3041): fs log:
I/ActivityManager(  605): Process com.example.myapplication.app (pid 3041) has died.
I/WindowState(  605): WIN DEATH: Window{424516f0 u0 com.example.myapplication.app/com.example.myapplication.app.MainActivity}
W/ActivityManager(  605): Force removing ActivityRecord{426d2690 u0 com.example.myapplication.app/.MainActivity t9}: app died, no saved state
I/WindowState(  605): WIN DEATH: Window{4249a288 u0 SurfaceView}
W/InputMethodManagerService(  605): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@42140218 attribute=n
ull, token = android.os.BinderProxy@423d6958
D/Zygote  (  178): Process 3041 exited cleanly (1)
 
 
  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Fri, 2014-05-16 14:35

We've been able to duplicate the crash on both Nexus 5 and Nexus 7 with the factory image builds:

N5 build

Android: 4.4.2

Baseband version: M8974A-1.0.25.0.23

Kernel version: 3.4.0-gadb2201 [email protected] #1 Wed Nov 20 14:42:53 PST 2013

Build number: KOT49H

 

N7 build

Android: 4.4.2

Kernel version: 3.4.0-gac9222c [email protected] #1 Wed Nov 20 14:50:44 PST 2013

Build number: KOT49H

 

However using a current open source 44 driver (https://developers.google.com/android/nexus/drivers) as well as a current internal driver, the app shows a green flashing screen.  Likely the crash has been fixed.

  • Up0
  • Down0
Remi
Join Date: 14 May 14
Posts: 6
Posted: Mon, 2014-05-19 02:50

Hi again,

Given that it crashes on the drivers that (presumably) the majority of consumers use it'd be really good to work around this bug on our side. Would it be possible for you to provide some details on what actually triggered the problem? It wouldn't be the first time we implemented workarounds in our code generator. :)

 

  • Up0
  • Down0
mhfeldma Moderator
Join Date: 29 Nov 12
Posts: 310
Posted: Mon, 2014-05-19 07:27

The fix is with our shader compiler doing agressive "optimization" on the indexing.  You might try introudcing a temporary variable and copy the indexed variable into it:  int temp = y[ad], and then use temp.

  • Up0
  • Down0
Remi
Join Date: 14 May 14
Posts: 6
Posted: Fri, 2014-05-23 05:33

Thanks!  Just naively replacing it didn't help but we'll see if we can get any further with it once our compiler team has some free time.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.