Search Issue Tracker

Fixed

Votes

6

Found in

2018.4

2019.4

2020.2

2020.2.5f1

2021.1

2021.2

Issue ID

1315960

Regression

No

WebGL Player freezes with 'Cannot enlarge memory arrays' error when the 'Standard' Shader is always included in builds

WebGL

-

How to reproduce:
1. Create a new project (or simply open the attached project 'test-standart-shader.zip' and skip to step 6)
2. In the Hierarchy window create a new Cube
3. Go to Edit -> Project Settings -> Graphics and under the 'Always Included Shaders' setting add the 'Standard' Shader as another element
4. Open the ProjectSettings.asset in a text editor and change the webGLMemorySize setting to 128
5. Change the 'webGLEmscriptenArgs' setting like so 'webGLEmscriptenArgs: -s ALLOW_MEMORY_GROWTH=0 -s TOTAL_MEMORY=134217728'
6. Back in Unity go to File -> Build Settings and switch the platform to WebGL
7. Add the 'SampleScene' to the build order and click 'Build And Run'

Reproducible with: 2018.4.32f1, 2019.4.21f1, 2020.2.7f1, 2021.1.0b10, 2021.2.0a6

Notes:
- This error message is thrown in the browser (2020.2, 2021.1, 2021.2): 'abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 134217728, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0'
- This error message is thrown in the browser (2018.4, 2019.4): 'Out of memory. If you are the developer of this content, try allocating more memory to your WebGL build in the WebGL player settings'

  1. Resolution Note:

    The build succeeds if ALLOW_MEMORY_GROWTH is set to 1, or if the TOTAL_MEMORY is increased. Setting ALLOW_MEMORY_GROWTH=1 with asm.js builds used to be inefficient when it comes to runtime speed. but now there is no performance cost with WASM builds.

Comments (3)

  1. sta-3ik

    Sep 23, 2021 08:03

    The problem is not in ALLOW_MEMORY_GROWTH is set to 1 and the performance costs for memory allocations.
    The problem is that when "Standart" shader is included in a build, the memory for an empty project is more than 128 MB.
    Is it by design?

  2. G-S-Pratap

    Jun 30, 2021 07:49

    Even with out using Standard shader also getting out of memory issue. 2020.3.8f1

  3. fish-rp

    Jun 21, 2021 17:13

    Also reproducible in Unity 2020.3.6f1

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.