Search Issue Tracker


Fixed in 2023.2.10f1, 2023.3.0b7, 2024.1.0a1



Found in





Issue ID




"IndexOutOfRangeException" in "UIElements.Layout.LayoutManager.DestroyNode" when changing UXMLs



Reproduction steps:
1. Open the attached "" project
2. Open the "Main" Scene
3. Go to "File > Build Settings..."
4. Make sure that "WebGL" is selected as the Platform and press "Build And Run"
5. When the Player opens, press on the lobby desk (it will glow when you hover over it with your mouse)
6. Press the arrow button in the top-left to go back
7. Repeat these two steps a few times

Expected result: The application runs without any issues
Actual result: The "IndexOutOfRangeException: Index was outside the bounds of the array" error is shown, the application buttons become unresponsive and show the "InvalidOperationException: Stack Empty" error after subsequent clicks

Reproduced with: 2023.1.0b4, 2023.1.7f1, 2023.2.0b3
Not reproduced with: 2021.3.29f1 (tested on macOS because the project builds only with Vulkan graphics API), 2022.3.6f1, 2023.1.0b3

Reproduced on: Windows 10, macOS 13.4 (M1, Intel)

Note: Reproducible on Google Chrome (115.0.5790.110), Firefox (115.0.2), Edge (115.0.1901.183), Opera (100.0.4815.76)

Comments (2)

  1. KamilCSPS

    Dec 27, 2023 12:37

    Another user mentioned this cause and workaround. Not ideal as a solution as it may create additional issues down the road and will be hard to keep compatibility...

  2. BadgerMeles

    Dec 18, 2023 20:37

    I also encountered this issue when building WebGL [Unity 2023.1.20f1], playing in Firefox 120.0.1 (64-bit).

    However, I encountered it while switching between scenes (ie: Back and forth between MainMenu <-> InGame) where each scene had it's own UIDocument.

    Two particular observations of note:
    1) In my situation, the error only happens when LoadSceneAsync() is used - LoadScene() does not appear to cause the issue.
    2) There are two different Exceptions that will be thrown at the same point, which Exception is thrown appears to be intermittent. One is the "Stack Empty" noted above, the other is "Failed to Free handle with Index=0 Version=0" noted in this related thread:

    I tried multiple approaches, and documented everything with multiple tests and examples here:

    If a root-cause has not already been found to resolve this issue, hopefully this additional information may be of use to you.

    Please, do not hesitate to ask if you have any questions.

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.