Normally my app runs at 60 fps, But when I add some simple models it decreases to 40fps.
I think v-sync on, which is might be causing it to run slower.
Is there any way to disable v-sync in WebGL?
Would glflush at the end of rendering work?
In WebGL, Swap Interval is what they call v-sync.
To enable Swap Interval
To disable Swap Interval
WebGL does not have control over v-sync or buffer swapping.
gl.flush is not going to either force or prevent a v-sync. gl.flush "force execution of GL commands in finite time" http://www.dei.isep.ipp.pt/~matos/cg/docs/manual/glFlush.3G.html
If you schedule your draw routine via setInterval or setTimeout it might be detrimential to rendering quality and v-sync artifacts might be more apparent (I have observed this in Chrome, but have not seen a difference in Firefox).
To avoid out of page-redraws you can call requestAnimationFrame to sync up your redraws with the page redraw. However this will not cause v-sync to be either on or off, it merely might reduce the impact of v-sync artifacts, and it makes your app behave more nicely performance wise (because you will not draw if your tab does not have focus).
A drop from 60fps to 40fps might indicate that you're making the GPU busy and you'll need to go over your code to make it faster.
Note that in order to measure accurate performance and exclude other effects, you should capture a start time before drawing, call gl.finish() after you're done, and then take an end time and log the difference into a collection from which you calculate an averaged result.
The gl.finish call ensures you are going to see a true performance measure and not just how fast your commands get commmited to the browsers backlog of WebGL calls (which is asynchronous).