Why does changing the app state unfreeze the video?

Sometimes when I do a one-on-one video call my own video stream freezes. To unfreeze my video stream, I’ve found that I need to press the home button on the iPhone which will put the app in the background and then when I bring it back to foreground my video stream magically works again. Does anybody know why switching from the background to the foreground enables a video stream that was frozen before?

I think I’ve found out why going in the background and then back in the foreground unfreezes the video stream. If I understand it correctly, going in the background (at least on iOS) turns off the camera. When we put the app in the foreground again, the camera is turned on again and the stream functions properly again.

In order to unfreeze a frozen video stream, I’ve found that all I need to do is set track.enabled to false and then to true. So I basically turn off the track first and then turn it on again and that seems to reset it. Here the code for disabling it:

        stream[username].getVideoTracks().forEach(videoTrack => {
            videoTrack.enabled = false;
        });