Running JUCE Demo on Android


#1

I just opened JUCE Demo 4.1.0 (latest tip) on Android and there are a couple of bugs I think.

I am running android 6 on Motorola X 2014. Android studio build on OSX.

1. I get a Unit Test failed in "Files / Reading" 1 test failed out of 22.

2. OpenGL 2D crashes instantly. Android crash report appears

12-29 19:06:55.639 19716-19716/com.yourcompany.jucedemo W/View: requestLayout() improperly called by com.yourcompany.jucedemo.JuceDemo$ComponentPeerView{d558d91 VFED..... .F....ID 0,0-1082,1536} during layout: running second layout pass 12-29 19:07:09.880 19716-19716/com.yourcompany.jucedemo I/Choreographer: Skipped 43 frames! The application may be doing too much work on its main thread. 12-29 19:07:10.096 19716-665/com.yourcompany.jucedemo A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 665 (Pool)

3. Some text seems to be rendering weirdly. See screenshots (some of these are showing the problem and some show that the problem isn't happening everywhere):

https://www.dropbox.com/s/sftua2ue901xosw/2015-12-29%2019.00.15.png?dl=0

https://www.dropbox.com/s/t775ybn5s2pggu8/2015-12-29%2018.59.58.png?dl=0

https://www.dropbox.com/s/p48b0ejq3trioao/2015-12-29%2018.58.48.png?dl=0

https://www.dropbox.com/s/yktulvdnwe39eyk/2015-12-29%2018.58.38.png?dl=0


#2

I can confirm bugs 1) and 3) on my device. The first bug should be relatively straight forward to fix. The third one might be more complicated but I'll give it a go. I'll get back to you on both.

On bug 2): Can you check that the "teapot" opengl demo works as expected. Can you also check that you can set the renderer to open gl by clicking on the "Tabs & Widgets" demo and then selecting "Use OpenGL Renderer" from the Look-and-feel menu on the right?

Thank you!


#3

* Teapot demo seems pretty smooth. I can spin the teapot around and change the texture etc.

* I can sucessfully change the lookandfeel to OpenGL Renderer and back. (It shows a black refresh frame between the two but I assume that is expected)


#4

I've looked into this a bit more and seems to have something to do with the OpenGL shader version. The OpenGL 2D demo requests shader version 2 but some newer Motorola devices nevertheless returns an OpenGL 3 context. I was able to re-produce the crash with the Motorola Nexus 6. I've filed a bug to Google but obviously JUCE still shouldn't crash. I'll see if I can come up with a workaround.


#5

This is the shader code in the OpenGL2D demo that ultimately gets sent to the GPU:

varying mediump vec4 frontColour;varying highp vec2 pixelPos;
mediump float pixelAlpha = frontColour.a;
/*  This demo shows the use of the OpenGLGraphicsContextCustomShader,
which allows a 2D area to be filled using a GL shader program.
Edit the shader program below and it will be 
recompiled in real-time!
*/
void main()
{
    mediump vec4 colour1 = vec4 (1.0, 0.4, 0.6, 1.0);
    mediump vec4 colour2 = vec4 (0.0, 0.8, 0.6, 1.0);
    mediump float alpha = pixelPos.x / 1000.0;
    gl_FragColor = pixelAlpha * mix (colour1, colour2, alpha);
}

which fails to compile with the following error:


ERROR: 0.2: 'frontColour': Only consts or uniforms can be used in a global initializer

Note that this error only occurs on some newer Motorola devices (Nexus 9, Nexus 6 for example). Are there any Open GL gurus out there that could point me in the right direction?


#6

Have you tried moving the 

mediump float pixelAlpha = frontColour.a;​

to the main function ?

It could be due to the fact that you can't initialize with non-constant expression outside of the main function on some versions of GLSL compilers

I can't test this as I only have a Nexus 10, on which this compiles and runs ok.

Sorry that I can't be more helpful...


#7

That was it! I've fixed this now on the latest tip.

Thanks for the suggestion!