Nested filters crash after renderer resize
PixiJS version
8.21.0 (latest)
Link to minimal reproduction
https://www.pixiplayground.com/#/edit/mC7E06TUGRPXgcakQR3ZR
Steps to reproduce
- Open the reproduction link and the console.
- It creates a rectangle with an AlphaFilter inside a container with another AlphaFilter.
- The example renders once, resizes the renderer from 301 × 201 to 347 × 229, then renders again.
What is expected?
Both renders should succeed normally, and the blue rectangle should remain visible after resizing.
What is actually happening?
The first render succeeds.
Resizing produces two warnings about a textureSource and textureSampler being destroyed while still bound to a shader. The second render then crashes:
FilterSystem.ts:783 Uncaught (in promise) TypeError:
Cannot read properties of null (reading '_resolution')The error occurs in _findFilterResolution. Second render OK is never logged because the render throws first.
System Info
System:
OS: Windows 11 10.0.26200
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 8.49 GB / 31.92 GB
Browsers:
Chrome: 153.0.8010.53
Edge: Chromium (152.0.4191.66)
Firefox: 156.0.1 - C:\Program Files\Mozilla Firefox\firefox.exeAny additional comments?
Resizing the renderer seems to prune pooled textures for the old screen size, while the filter stack keeps references to those textures between frames.
I traced the crash to push() incrementing _filterStackIndex before _findFilterResolution() is called. The lookup then starts at _filterStackIndex - 1, which appears to be the current entry rather than the parent. At that point its old texture has already been destroyed and source is null.
I think the lookup during push() needs to start from the parent entry. applyFilter() seems to need slightly different handling since the current entry has already been popped there. I also noticed the lookup excludes index 0, even though that can contain a valid parent filter.
Source: pixijs/pixijs