Monday 17 November 2014

Nexus 10 and Android Lollipop (5) problem (Solved)

This is now address in version 1.6.0.  I like to give special thanks to Anton and Felix for helping me verifying and debugging this problem.

What is the problem?

There seems to be a bug with Nexus 10 and Android L opengl shader program implementation.  I have been using this shader program for all platforms and devices including IOS since now.  



precision mediump float;
            uniform vec4 vColor;
            varying vec2 vTextureCoord;
            uniform sampler2D sTexture;
            uniform lowp float textureMask;

            void main() {
                  gl_FragColor = textureMask * texture2D(sTexture, vTextureCoord)*vColor  + (1.0- textureMask)*vColor;
            }


 This shader program is simply for rendering any set of vertices with color and/or texture based on the "textureMask" variable.  I dont know exactly what happened internally with the driver but when rendering different vertices as color or texture the driver throw a glerror 1285 which stand for "out of memory".  However, I think the problem is because of the memory corruption when switching between texture and color.  

Case 1) To render object as pure color, I just need to pass in just the position vertices while disable the texture vertices.  

Case 2)  To render object with texture, I need to pass in both the position and texture vertices.

 What I think is that when switching from case 2 back to case 1.  The driver may not recognize that the texture vertices should be disable and potentially reference to incorrect memory.  This is my guess but it make the most sense.


The solution:


I have created two separate shaders for each purpose so there are no need for extra flag and optional parameter for the cases I described.  By breaking them into two simple shader programs I am able to bypass the driver glitch.

Lesson Learned:

Simple is better :)

------------------------------------------------------------------------------------------------------------------------------

Right now there seems to be problem running Drawexpress with the latest Android Lollipop on Nexus 10.  The problem is related to opengl issues.  I am not sure about the exact problem yet since I dont have the Nexus 10 device to test with yet. If you have a Nexus 10 please hold off on updating to Lollipop. 

If you have other devices and are having the problem loading Drawexpress after Lollipop update please email me at support@drawexpress.com.  I am also greatly appreciated if anyone with Nexus 10 who is willing to join my Android beta testing program.

- PD