You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ability to limit canvas size for Expand scale mode. #7027
The "Expand" scale mode in Phaser is generally excellent, but it has a significant issue.
When I configure my game with a width of 1080 and a height of 1920 (a portrait mode game), and use the "Expand" scale mode, the canvas size can become excessively large when the screen is in landscape orientation with a wide aspect ratio. For instance, the canvas might expand to 5000x1920 or even larger, depending on the aspect ratio.
I encountered this problem when my game started crashing on all Android devices in landscape mode with a Framebuffer status: Incomplete Attachment error.
The solution seems to be the ability to configure maximum canvas width and height limits (something like maxCanvasWidth and maxCanvasHeight options).
While max.width and max.height config options already exist, they appear to only limit the size of the HTML element, not the actual canvas width and height. I haven't been able to find a suitable way to use these options to prevent the excessive canvas size issue.
Hi @leha-games, could you provide code examples so we can have a closer look?
Also did you set the parent property in the game config?
Without setting the parent property, you will need to manually call the setParentSize method in the Scale Manager to set the maximum width and height for the canvas.
An example of the parent property in the scale object in the game config should look something like this:
Thank you for submitting this issue. We have merged a PR that fixed this and pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.
Activity
zekeatchan commentedon Feb 5, 2025
Hi @leha-games, could you provide code examples so we can have a closer look?
Also did you set the
parentproperty in the game config?Without setting the
parentproperty, you will need to manually call thesetParentSizemethod in the Scale Manager to set the maximum width and height for the canvas.An example of the
parentproperty in thescaleobject in the game config should look something like this:leha-games commentedon Feb 5, 2025
There is example from my phone. When I set this config:
It throws this error:
Also it can be achieved on PC:
photonstorm commentedon Mar 4, 2025
Thank you for submitting this issue. We have merged a PR that fixed this and pushed to the
masterbranch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.photonstorm commentedon Oct 13, 2025
This issue has been mentioned on Phaser. There might be relevant details there:
https://phaser.discourse.group/t/mobile-rotation-breaks-layout-randomly/15444/3