Camera w/ Multiple Post Processing Effects Crashes on Re-Enabling

I have a project w/ 3 cameras
The 1st camera is for the main menu, has scenes and post processing on it (bloom, fxaa, vignette, and LUT found here: PlayCanvas 3D HTML5 Game Engine ). Once the play button is pressed, it is disabled and the gameplay camera is enabled.

The gameplay camera has post processing (fxaa, blend, vignette, and the LUT). The game plays and then gets to the end screen. The gameplay camera is turned off and the end scene camera is turned on.

The end scene camera has the same post processing as the main menu camera.

Once play again is pressed, the end scene camera is turned off and the gameplay camera is turned back on. Turning the camera back on causes a crash:

[playcanvas.min.js?version=1.51.5:6]: Uncaught TypeError: Cannot read properties of undefined (reading 'width')

TypeError: Cannot read properties of undefined (reading 'width')
    at t.get (
    at e.i.initRenderTarget (
    at e.i.updateBegin (
    at Object.Fs [as drawFullscreenQuad] (
    at VignetteEffect.render (
    at (
    at t.e.renderComposition (
    at i.n.render (

At first I noticed that it was the vignette post effect, so I disabled it all together and the crash still happens but with a different effect. So I disabled all effects and turned one on, disabled the camera, enabled the camera and it worked fine (did this for each effect). So then I thought it was a combination of specific effects, it turns out that it doesn’t matter which 2 effects are on but if it is more than one post processing effect it always crashes.

The gameplay camera starts the game turned off. It is only when it is re-enabled does it crash.

All cameras are priority 1

Hi @derek9nine,

I think that happened in a project of mine a few months ago, but I wasn’t sure if it was my implementation or an engine bug.

What I did back then after switching cameras, to avoid this exact error, was a hack like this:

// re-create post effects queue;
    try { = new pc.PostEffectQueue(, cameraEntity);
    } catch (e) { }

// toggle on/off each effect to trigger the action that adds them to the effects queue
        cameraEntity.script.ssao.enabled = false;
        cameraEntity.script.ssao.enabled = true;

        cameraEntity.script.bloom.enabled = false;
        cameraEntity.script.bloom.enabled = true;

// etc

I’m not sure where the crash is coming from, likely a bug in the engine. But I’d say that using a single camera with post-effects might be a good idea, as otherwise all cameras would have post-effect frame-buffers allocated. It’s possible they got deleted when camera is disabled, but I’m not entirely sure.


Ideally a single camera would be great if I could get away with it and have a very particular and nit picky client be happy :smiley:

1 Like

@Leonidas This did the trick. Thank you so much. Luckily I only have to do it once, maybe twice in a standard use case.

Appreciate the help