WebGL app crashes when I call InstantiateAsync

I have some code where I load a list of IResourceLocation using a label I created for my assets.
My code loads them one at a time as the user clicks an arrow key to loop through them one-by-one.

When I run this in Unity it works flawlessly.

I’ll then do a WebGL build and deploy it in a Docker container that I have hosted on my own machine.

I have console output that indicates that it finds the locations just fine. However, as soon as it calls InstantiateAsync it crashes. In Chrome it gives me the “aw snap” error. Also crashes in Edge with a “This page is having a problem” error. In Firefox it doesn’t crash, but it refuses to process anything after that first call to InstantiateAsync. It starts throwing all sorts of null pointer exceptions as though everything loaded previously just went away.

I’ve also tried doing a call to LoadAssetAsync before InstantiateAsync, but then it crashes on LoadAssetAsync.

I’m using Unity 2020.3.28f1 and addressables 1.18.19

The following is my code:

IEnumerator Start()
    {
        models = new List<GameObject>();

        AsyncOperationHandle<IList<IResourceLocation>> locationHandler = Addressables.LoadResourceLocationsAsync(addressableModelLabel, null);
        yield return locationHandler;

        resources = locationHandler.Result; //This returns a list of 7 items

        StartCoroutine(LoadAddressable(resources[index])); //index initially set to 0
    }

    private IEnumerator LoadAddressable(IResourceLocation reference)
    {
        AsyncOperationHandle<GameObject> instHandle = Addressables.InstantiateAsync(reference, transform);
        yield return instHandle;

        GameObject newObject = instHandle.Result;
        string key = resources[refIndex].PrimaryKey;
        newObject.name = key;
        models.Insert(index, newObject);
    }

I’ve attached an image of how my addressables are set up.

The settings for each group has the defaults for Content Packing & Loading and Content Update Restriction. The addressables settings are also on their defaults.

In Other Settings I have Manage Stripping Level set to Low. I also tried it with Strip Engine Code unchecked.

There are no errors in the console. Doing a log dump of chrome also yields no results.

Update:

I’ll create a bran new scene, add an empty object and add a script to that object. This is literally everything in that script:

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;

public class TestingAddressables : MonoBehaviour
{
    // Start is called before the first frame update
    IEnumerator Start()
    {
        yield return Addressables.InitializeAsync();

        AsyncOperationHandle<IList<IResourceLocation>> locationHandler = Addressables.LoadResourceLocationsAsync("my-label", null);
        yield return locationHandler;

        var resources = locationHandler.Result;

        Console.WriteLine(resources.Count + " resources found");

        yield return LoadAddressable(resources[0]);
    }

    private IEnumerator LoadAddressable(IResourceLocation reference)
    {
        Console.WriteLine("Attempting to instantiate reference");
        AsyncOperationHandle<GameObject> instHandle = Addressables.InstantiateAsync(reference, transform);
        yield return instHandle;

    }
}

The console outputs “7 resources found” then “Attempting to instantiate reference” and then it crashes.

Looks like if there are too many resources in an addressable group it causes the crash.

Edit: Most of my prefabs include fbx files and can be large. After splitting them up so only 2 prefabs were in each group it solved my problem. webgl deployments no longer crash after this.