[blocker] Crash on heavy CPU usage

We’re getting device crash after the device goes into 137% CPU usage, and the stack trace seems to have something to do with mesh conversion to polyspatial, any ideas what could be the cause or any way to test deeper?

I can’t think of anything offhand. Is it a particularly complicated mesh? If you submit a bug report with a repro case and let us know the incident number (IN-#####), we can look into it further.

it’s quite a lot of small interactable objects rather than one big one if that gives you any clue.

Additionally this happens the second time we load the level.
Level is loaded in Additive mode, we we discharge it this way:

        await SceneManager.UnloadSceneAsync( scene );
        await Resources.UnloadUnusedAssets();

and the next time we load the level, device crashes with apple logo

In your Instruments trace – what do the frames below the highlighted one look like? I see “11.74 seconds” as the weight there, but the self weight is only 14ms. So a lot of the time is being spent below that.

Also for the device crashes, that’s something you should definitely report to Apple via Feedback Assistant :slight_smile: Nothing an app can do should case the device to crash, so that’s a problem in the OS.

We also noticed that on other levels, each loading of a new level is slower and slower, until at some point the device crashes. Is it possible that unloading scenes and resources is not working as it should?

Later we will prepare project with bug report

We have seen crashes where pushing too many changes to RealityKit in one frame will exhaust it’s buffers causing a full device reboot. This typically happens if you load/unload a scene with many objects. I’m not sure if this is what happens here…

We have found this a handy function to check for potential asset unloading issues in builds. Call it when you have unloaded your scene, or after you load a new one, to get a quick overview of what is loaded.

    private void DumpAssetInfo()
    {
        var mats = Resources.FindObjectsOfTypeAll<Material>();
        var texs = Resources.FindObjectsOfTypeAll<Texture>();
        var mshs = Resources.FindObjectsOfTypeAll<Mesh>();
        var cmps = Resources.FindObjectsOfTypeAll<Component>();
        var gos = Resources.FindObjectsOfTypeAll<GameObject>();
        var fonts = Resources.FindObjectsOfTypeAll<Font>();

        int nullCount = 0;
        foreach (var go in gos)
        {
            if (go.scene.IsValid() == false)
                nullCount++;
        }

        Dictionary<System.Type, List<Component>> cmpCount = new Dictionary<System.Type, List<Component>>();
        Dictionary<string, List<GameObject>> goCount = new Dictionary<string, List<GameObject>>();

        string output = $"AssetInfo Materials {mats.Length} Textures {texs.Length} Meshes {mshs.Length} Fonts {fonts.Length} Components {cmps.Length} GameObjects {gos.Length - nullCount} + {nullCount}\n";
        output += "\tMaterials:\n";
        foreach (var m in mats)
        {
            output += $"\t\t{m.name} id = {m.GetInstanceID()} shader = {(m.shader ? m.shader.name : "null")}\n";
        }
        output += "\tTextures:\n";
        foreach (var m in texs)
        {
            output += $"\t\t{m.name} id = {m.GetInstanceID()}\n";
        }
        output += "\tMeshes:\n";
        foreach (var m in mshs)
        {
            output += $"\t\t{m.name} id = {m.GetInstanceID()} vertexCount = {m.vertexCount} indexCount = {m.GetIndexCount(0)}\n";
        }
        output += "\tFonts:\n";
        foreach (var m in fonts)
        {
            output += $"\t\t{m.name} id = {m.GetInstanceID()}\n";
        }
        output += "\tComponents:\n";
        foreach (var m in cmps)
        {
            var t = m.GetType();
            if (cmpCount.TryGetValue(t, out List<Component> value))
            {
                value.Add(m);
            }
            else
            {
                cmpCount.Add(t,new List<Component>(){m});
            }
        }
        foreach (var m in cmpCount)
        {
            output += $"\t\t{m.Key.Name} namespace = {m.Key.Namespace} count = {m.Value.Count}\n";
        }

        output += "\tGameobjects:\n";
        foreach (var m in gos)
        {
            var t = m.scene.IsValid() ? m.scene.name : "null";
            if (goCount.TryGetValue(t, out List<GameObject> value))
            {
                value.Add(m);
            }
            else
            {
                goCount.Add(t,new List<GameObject>(){m});
            }
        }
        foreach (var m in goCount)
        {
            output += $"\t\tScene {m.Key} count = {m.Value.Count}\n";
            if (m.Key == "null")
            {
                foreach (var n in m.Value)
                {
                    output += $"\t\t\t{n.name} id = {n.GetInstanceID()} active = {n.activeInHierarchy}\n";
                }
            }
        }
        Debug.Log(output);
    }
1 Like