Several of our clients are being affected by a random crash in iOS.
After doing GL.InvalidateState Unity does not restore state properly
I am testing in iOS, OpenGL ES 2.0
The attached project is a minimal scene, that clears using a SkyBox. A script is attached to the camera and calls GL.InvalidateState inside OnPostRender()
Analyzing the commands using XCODE for a frame I am getting a random behaviour when Unity renders the SkyBox. Normally it does:
#12 glEnableVertexAttribArray(0)
#13 glBindBuffer(GL_ARRAY_BUFFER, 1)
#14 glVertexAttribPointer(0, 3, GL_FLOAT, 0, 28, NULL)
#15 glUniformMatrix4fv
#16 glUniformMatrix4fv
#17 glDrawArrays(GL_TRIANGLES, 0, 5040) – DRAWSKYBOX
But sometimes, randomly, it does:
#12 glEnableVertexAttribArray(0)
#13 glUniformMatrix4fv
#14 glUniformMatrix4fv
#15 glDrawArrays(GL_TRIANGLES, 0, 5040)
So, sometimes, the VertexAttrib is enabled but glVertexAttribPointer is not called. This is not a proper restoration of the vertex attrib state. We are a native plugin, that instead of GL.InvalidateState() is doing GL.IssuePluginEvent() (this automatically generates a GL.InvalidateState()). We are modifying the vertex array state (using glVertexAttribPointer and own vertex objects).
Problem is that when Unity behaves improperly (not calling glVertexAttribPointer) the state is not properly restored and Unity is using our own vertex buffer object. This, of course, generates random crashes for our clients.
I have filed a report: 718348
Any feedback about it? It seems quite critical for us.