Skip to content

Progressive performance degradation in ScrollablePanel with mask, enableLayer and forceSetTimeout enabled #563

Description

@notKitory

Bug Description

A progressive performance degradation (smooth framerate drop) occurs when using ScrollablePanel with specific rendering and FPS configurations. The rendering cost appears to increase with every frame over time.

This issue is specific to Phaser 4 (tested on 4.1.0 + phaser4-rex-plugins 4.0.5/4.0.7).
Note: Under the exact same conditions, this setup works without any performance issues in Phaser 3.90.0.

Steps to Reproduce

The issue is triggered by combining the following base parameters:

  1. Set the game FPS configuration with a high target and forceSetTimeOut enabled:
    fps: {
        target: 240,
        forceSetTimeOut: true
    }
  2. Create a ScrollablePanel with both mask and enableLayer enabled:
    panel: {
        child: content,
        mask: { updateMode: 0 }, // or true
        enableLayer: true
    }
  3. Run the application and wait for a few moments or scroll the panel.
  4. Observe the frame rate gradually decreasing and the rendering time increasing.

Additional Context

  • The performance drop happens smoothly, which suggests a potential WebGL resource leak, un-cleared stencil/mask buffers, or layer stacking overhead in Phaser 4.
  • This issue likely affects any mask application on Rex-objects in Phaser 4.

Tested Environments

  • Phaser version: 4.1.0 (Works fine in 3.90.0)
  • phaser4-rex-plugins version: 4.0.5 (via jsdelivr) & 4.0.7
  • Devices & Browsers:
    • MacBook Air M4 (Chrome, Safari)
    • iPhone 15 (iOS Safari)
    • Redmi Note 14

Expected Behavior

The performance should remain stable over time, matching the behavior observed in Phaser 3.

Live Demonstration

You can reproduce the bug using this pre-configured CodePen:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions