Android phones with an Adreno 420/430 generate crashes when trying to compile a shader that works fine on other phones.
Investigating the crashing fragment shader shows that using gl_FragCoord causes the issue. If we remove gl_FragCoord occurences, compilation goes fine.
A demo APK that works on e.g. Nexus 5 and fails on e.g. Nexus 6 is here: http://download.gluonhq.com/tmp/HelloGluon.apk
This is also reported on the JavaFX-Android issue tracker at https://bitbucket.org/javafxports/javafxmobile-plugin/issues/28/lollipop-51-and-error-with-gradient and discussed on the OpenJFX mailing list at http://mail.openjdk.java.net/pipermail/openjfx-dev/2015-July/017578.html
I saw similar reports on this forum, but I didn't see a link to the usage of gl_FragCoord yet.
The relevant log info:
F/libc (28382): Fatal signal 11 (SIGSEGV), code 1, fault addr 0xc in tid 28406 (QuantumRenderer)^M
I/DEBUG ( 354): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***^M
I/DEBUG ( 354): Build fingerprint: 'google/shamu/shamu:5.1.1/LMY47Z/1860966:user/release-keys'^M
I/DEBUG ( 354): Revision: '33696'^M
I/DEBUG ( 354): ABI: 'arm'^M
I/DEBUG ( 354): pid: 28382, tid: 28406, name: QuantumRenderer >>> com.hellogluon <<<^M
I/DEBUG ( 354): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xc^M
I/DEBUG ( 354): r0 00000000 r1 aa9ba96b r2 00000000 r3 ffffffff^M
I/DEBUG ( 354): r4 9e3fdabc r5 aec99cf0 r6 9e3f77f8 r7 00000014^M
I/DEBUG ( 354): r8 aec99d04 r9 aaaf4b8b sl ffffffde fp 9e3f7a10^M
I/DEBUG ( 354): ip aab235a8 sp 9e3f77e0 lr aaa09205 pc aaa09218 cpsr 60070030^M
I/DEBUG ( 354): ^M
I/DEBUG ( 354): backtrace:^M
I/DEBUG ( 354): #00 pc 005bb218 /system/vendor/lib/libllvm-glnext.so (TParseContext::handleIdentifier(TSymbol*, llvm::StringRef const&, int)+275)^M
I/DEBUG ( 354): #01 pc 005d727d /system/vendor/lib/libllvm-glnext.so (yy2parse(TParseContext&)+972)^M
I/DEBUG ( 354): #02 pc 005dcd3d /system/vendor/lib/libllvm-glnext.so (yy2PaYYParse(TParseContext&)+16)^M
I/DEBUG ( 354): #03 pc 005e481d /system/vendor/lib/libllvm-glnext.so (YYParser::ParseStrings(char**, long*, int, TParseContext&, int)+276)^M
I/DEBUG ( 354): #04 pc 005b305b /system/vendor/lib/libllvm-glnext.so (ShCompile+1326)^M
I/DEBUG ( 354): #05 pc 00552399 /system/vendor/lib/libllvm-glnext.so (LLVMCompiler::parse(QGLC_SRCSHADER*)+1188)^M
I/DEBUG ( 354): #06 pc 005557ed /system/vendor/lib/libllvm-glnext.so (CompilerContext::CompileToIRShader(QGLC_SRCSHADER*, QGLC_COMPILETOIR_RESULT*)+168)^M
I/DEBUG ( 354): #07 pc 00105903 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShaderCompiler::CompileShader(EsxContext const*, EsxShader const*, EsxInfoLog*)+526)^M
I/DEBUG ( 354): #08 pc 00103ced /system/vendor/lib/egl/libGLESv2_adreno.so (EsxShader::Compile(EsxContext*)+72)^M
I/DEBUG ( 354): #09 pc 000b2201 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxContext::GlCompileShader(unsigned int)+60)^M
I/DEBUG ( 354): #10 pc 000e4ef9 /system/vendor/lib/egl/libGLESv2_adreno.so (EsxGlApiParamValidate::GlCompileShader(EsxDispatch*, unsigned int)+40)^M
I/DEBUG ( 354): #11 pc 000a947d /system/vendor/lib/egl/libGLESv2_adreno.so (glCompileShader+44)^M
I/DEBUG ( 354): #12 pc 00005729 /data/app/com.hellogluon-1/lib/arm/libprism_es2_monocle.so (Java_com_sun_prism_es2_GLContext_nCompileShader+112)^M
W/ActivityManager( 804): Force finishing activity 1 com.hellogluon/javafxports.android.FXActivity^M
i can confirm this bug is exist with snapdragon 805&810 (adreno 420&430). certain shader compilation causes crash, but on all other gpu's works fine.
Hello Johan.
Thanks for the report and submitting the APK
Unfortunately, APKs are not terribly useful for us. What is useful is the actual fragment shader causing the problem.
By exploring your links, I was able to track down this message:
http://comments.gmane.org/gmane.comp.java.openjdk.openjfx.devel/9796
This mentions a fragment shader named "FillRoundRect_LinearGradient_PAD.frag" and the following line from that shader:
Now this looks like you are initialising "pixcoord" using a "non-constant expression", so you should take a look at my post here:
https://developer.qualcomm.com/comment/9100#comment-9100
If this is the problem then you should be able to fix the fragment shader as explained in the OpenGL Specifications referenced in that above post.
You are correct that the compiler shouldn't crash, and that crash will be fixed at a future time, however the fragment shader should not be using non-constant initializers to initialize "pixcoord".
Hope this helps, and if it does please report back to let us know.
Thanks, that helped indeed.
Moving the pixcoord initialisation into the main function fixed the problem.
A nice warning instead of a crash would be much appreciated, so I'm looking forward to future releases.
Meanwhile, on behalf of many JavaFX developers, thanks a lot for your help, much appreciated.
- Johan