Taking Screenshot generate a temporary black background on Main Camera

I’m working with scripts from this example project. In this project and the one I forked, I don’t see any problem. But when I tried to replicate that in a more complex project, I have strange visual effect: a temporary black background.

When I am taking screenshot from a second camera (screenshot camera), I can see a visual effect with my main camera. The effect is similar to change the camera.clearColor to black for a very small time (<1sec).


I pinpointed the line that may caused this visual effect:

// From https://forum.playcanvas.com/t/save-specific-rendered-entities-to-image/2855/4
CameraToTexture.prototype.takeScreenshot = function (cameraPointIndex) {
gl.bindFramebuffer(gl.FRAMEBUFFER, fb); //Commenting this single line will break the screenshot, but also remove the visual black background effect

Everything else is working fine! My screenshots are goods, no other problem except that. So, param or setting may cause this problem?

Unfortunately, my current project is not public and not playable with the editor.