I just noticed (after hours of debugging) that a too high FPS can (and does) actually cause a problem with the web cam. I’m using WebCamTexture
class to get the image from the webcam in my laptop and put it as a texture on an object (real-time). And it works well. But when I run the app (in the Editor) and it has a high FPS (like 900 or more, I’m not sure what’s the threshold) the application chokes horribly, freezes, lags and so on… It doesn’t complete freeze as it jumps a few frames (literally a few) every couple of seconds then it freezes again and so on… But when I set Application.targetFrameRate
to a low value (like 60) the problem disappeared. Also 100 - 200 seemed to work well. I tested the app also on my mobile phone and it works ok (but I assume it’s because it can’t get 1000 FPS there :P).
So my conclusion is that too high an FPS causes problems as the web cam can’t catch up or something. But why? Has anyone come across this problem before? Should I just fix the FPS in my application or what’s the correct solution?
As a side note, or question rather - can I lock the FPS for a moment in my application (only when I actually use the camera) and then unlock it again? Or should Application.targetFrameRate
be used just once at the start and never touched again?