Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question WebGL Throwing "Memory Out of Bounds"

Discussion in 'Web' started by CharlieDaLoon, Jan 31, 2021.

  1. CharlieDaLoon

    CharlieDaLoon

    Joined:
    Mar 3, 2020
    Posts:
    22
    I'll preface this by saying that this project works flawlessly both in-editor and as a standalone. However, once I run a WebGL build (linear color space, so WebGL 2.0), I get a series of errors that prevent the game from even loading.

    After hours of rebuilding the WebGL build and watching console output like a hawk, I've finally discovered the specific lines of code that are throwing the error (this is the very first function that runs after the splash screens) - see below for details.

    Code (CSharp):
    1. private IEnumerator LoadLevelWithAwaitAsync(string levelName)
    2.     {
    3.         sceneLoaded = false;
    4.         loadBar.value = 0;
    5.         cardAnimator.StopPlayback();
    6.         animator.SetTrigger("FadeOut");
    7.         // Error throws at this yield, if I comment it out...
    8.         yield return new WaitForSeconds(1.0f);
    9.         AsyncOperation op = SceneManager.LoadSceneAsync(levelName);
    10.         while (!op.isDone)
    11.         {
    12.             loadBar.value = Mathf.Clamp01(op.progress / 0.9f);
    13.             // Then the error throws at THIS yield ... sensing a pattern?
    14.             yield return null;
    15.         }
    16.         while(!sceneLoaded)
    17.         {
    18.             yield return null;
    19.         }
    20.         ResetParameters();
    21.         animator.SetTrigger("FadeIn");
    22.         yield return new WaitForSeconds(1.0f);
    23.         cardAnimator.StartPlayback();
    24.         nonSettingsRemover.SetSceneName(levelName);
    25.     }
    The actual error that's being thrown is as follows:
    The alert text that pops up is as follows

    I'm not sure this part is relevant, since I just assume this is saying the unity script is unable to progress, but immediately after closing the alert box, I get

     
  2. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    This does suggest like some bug. Any chance you'd be able to reduce the issue to a minimal test case, and report it?
     
  3. CharlieDaLoon

    CharlieDaLoon

    Joined:
    Mar 3, 2020
    Posts:
    22
    I was throwing my hands up in frustration over this, it seemed like everything I did caused a new set of errors to happen.

    Well, as it turns out, the problem was the Unity Localization package. After trying a thousand different configurations with a super stripped-down version of the game... I took a full copy of the feature-complete version of the game, removed the Localization package and fixed the compilation errors that came with that, and it just works now.
     
  4. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    953
    That sounds curious. Is that one of Unity developed packages, or authored by someone else? Maybe you can throw a line to the developer of the package to let them know?