Note that there are some explanatory texts on larger screens.

plurals
  1. POStuttering when using SurfaceTexture and Camera (Android 4.0 ICS)
    text
    copied!<p>I have noticed an interesting bug when using <code>SurfaceTexture</code> with the <code>Camera</code>.</p> <p>If I setup a <code>SurfaceTexture</code>, pass it a valid <code>OpenGL</code> texture and pass that into the <code>Camera</code>, everything works great. I can then swap out the pixel shader with a simple shader and all still works great. But if I swap out the pixel shader with a more complex shader the framerate drops and stuttering appears.</p> <p>What seems to be happening is that a frame is getting processed out of order. After some hypothesizing I wondered if the hardware was being sent too much to do. After trying a number of things I found that if I just slept the gl processing thread for around 75 milliseconds or so the framerate jumped back up and the stuttering disappeared.</p> <p>This is an okay hack for now, but I worry that value is just an arbitrary guess based on my shader, and that it may change with other shaders or other phones. My question is: Is it possible to know when it is safe to send another frame down to OpenGL without over-taxing the system? (Or is something else going on here?)</p> <p>I have tried using <code>glFinish</code>, and <code>glFlush</code> but neither of these helped. I wondered if that was because the camera uses samplerExternalOES and somehow that effects it? </p> <p>Note: If I run the same <code>OpenGL</code> code using a <code>SurfaceView</code> instead I don't get any stuttering. Of course the performance isn't as good so that may be the reason it doesn't.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload