Readpixels throws error when calling screenshot

We are in the process of upgrading to version 6 from an earlier version. When attempting to get a screenshot, I am getting the following error:

Uncaught TypeError: Cannot read properties of null (reading 'then')

This is from running the following code:

ScreenshotTools.CreateScreenshotUsingRenderTarget(
     scene.getEngine(),
     scene.activeCamera as any,
     size,
     data => {
       resolve(data);
     },
     mimeType,
     4,
     shouldUseFxaa(size), // true in this case
     '',
     false,
     true,
     false,
     4,
     null,
   );

A few notes:

  1. I can confirm that scene, engine, and activeCamera are not null
  2. This is using WebGL 2 in Chromium 106:
Chromium	106.0.5249.0 (Developer Build) (arm64) 
Revision	4fe489136201d28818c92ee6a4a28eca8625c885-refs/heads/main@{#1036745}
OS	macOS Version 13.5 (Build 22G74)
JavaScript	V8 10.6.194

If I step through the code, it’s failing when readPixels checks for this._texture which is always null.

looks like you are trying to read pixels from a disposed texture. Could you share a repro ?