Search Unity

Bug (Case 1115544) Array type 'baseOrElementTypeIndex' does not point to its element type

Discussion in 'Profiler Previews' started by Peter77, Jan 9, 2019.

  1. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    4,029
    Using the UnityEditor.MemoryProfiler API to capture a PackedMemorySnapshot, causes some array types to be detected with a missing element type.
    This issue seems to occur with ScriptingBackend .NET 4 only.

    The element type of the array "int[]", would be "int".
    The MemoryProfiler API in uses the "baseOrElementTypeIndex" of the "int[]" type, to point to the "int" type.
    In some cases, this does not seem to work.

    screenshot.png

    Reproduce
    • Open user attached project
    • Click Mainmenu > BugReport > Open TestCode Window
    • Click "Capture Memory" button

    Actual
    Various array types found with the message "Array '<name>' has no element type".

    Expected
    Array types should provide a baseOrElementTypeIndex to figure out its element type.
     
  2. alexrvn

    alexrvn

    Unity Technologies

    Joined:
    May 16, 2017
    Posts:
    19
    Hi Peter! When we collect types from mono we exclude uninitialized ones / unused. Meaning if I got a class A{} and then a array A[] a = new A[n]; (here the type is A[] and not A, it does not require A) as long as type A is not used the inner type is not initialized. This can happen even for more complex containers such as Dictionaries where some of the inner types will not be initialized if the Dictionary itself does not have any elements added. We will be changing this behavior to output all types in the coming versions of Unity.