Search Issue Tracker
By Design
Votes
0
Found in
2020.3.42f1
2021.3.14f1
2022.1.23f1
2022.2.0b16
2023.1.0a20
Issue ID
UUM-19938
Regression
No
[WebGL] The canvas element gets constantly resized when width and height are defined in attributes but not styles
Reproduction steps:
1. Open the attached “IN-22017_unity-bug-webgl-canvas-rescale-to-infinity.7z“ project
2. Open “SampleScene” scene
3. Switch platform to WebGL
4. In Player settings, choose the WebGL template called 'WorkingStyles', Build and Run the project
5. Inspect the local server window. Canvas is visible and scales according to the window size
6. In Player settings, choose the WebGL template called 'BuggedAttributes', Build and Run the project
7. Inspect the local server window. Canvas is black and keeps constantly scaling
8. Inspect window console log errors
Expected result: Canvas scales according to screen size
Actual result: Canvas keeps constantly scaling and the screen goes black
Reproducible with: 2020.3.42f1, 2021.3.14f1, 2022.1.23f1, 2022.2.0b16, 2023.1.0a20
Reproduced on: macOS Monterey 12.6 (Intel)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- The letter "i" is incorrectly formatted into “İ" when capitalised if the devices Region is set to "Turkish (Turkiye)"
- [VFX] No templates available in Default VFX Graph Templates window
- [VFX] "ArgumentException" error thrown when trying to add/create Curl Noise Node
- Properties of custom visual elements fail to initialize when inside of template that has been renamed
- HDR output fails to render in Player when using Direct3D11 in Exclusive Fullscreen mode
Resolution Note:
By default, Unity will resize the canvas resolution to match the style resolution, along with the devicePixelRatio to scale the resolution for HDPI screens. This is because the canvas attributes control the WebGL resolution in the browser, and Unity matches the resolution to how it's displayed. For example if you switch to full screen, the resolution will be automatically adjusted to that new size. You can turn off this behavior with `config.matchWebGLToCanvasSize = false;` in the template html, which will give you independent control of the style and canvas resolution.