Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

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

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    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.

    Update: Link to bug-report in issue tracker https://issuetracker.unity3d.com/is...ttypeindex-does-not-point-to-its-element-type
     
    Last edited: Dec 31, 2020
  2. alexrvn

    alexrvn

    Unity Technologies

    Joined:
    May 16, 2017
    Posts:
    53
    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.
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Do you know if the behavior has been changed to output all types? The bug-report was closed as "By Design" though.

    The issue is reproducible with Unity 2019.4.9f1 on some platforms. Perhaps the fix is available in newer versions?
    https://github.com/pschraut/UnityHeapExplorer/issues/2
     
    Last edited: Dec 31, 2020
  4. jerome-lacoste

    jerome-lacoste

    Joined:
    Jan 7, 2012
    Posts:
    206
    Happy to know which versions will support the change.
     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,456
    Just as a short term update: Alex is still on vacation and I'm not certain enough.
     
  6. alexrvn

    alexrvn

    Unity Technologies

    Joined:
    May 16, 2017
    Posts:
    53
    Heya,

    in 19.4.10+ we changed the memory profiler to forcefully expand the types that we get form the VM(mono/il2cpp), that means that the above shouldn't occur in any cases including int[][][], int[][]. Could you give it a spin?

    Cheers,
    Alex
     
    Peter77 and MartinTilo like this.