Camera freezes and goes weird after full screen

On my iPhone if I pinch the video pane it opens in full screen but when I come back to the browser the video freezes . I turn the camera off with a button in my app and back on but still frozen, if I try to switch to the front camera the same view gets duplicated and flipped.