Menu

Getting a lot of CompareBaseObjectsInternal errors

siavee
2014-12-08
2014-12-11
  • siavee

    siavee - 2014-12-08

    Hi Karl,

    I am getting a lot of the following error:

    CompareBaseObjectsInternal can only be called from the main thread.
    Constructors and field initializers will be executed from the loading thread when loading a scene.
    Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

    How do we solve this problem?

    Best regards,
    Taufik

     
    • Karl  Jones

      Karl Jones - 2014-12-08

      Hi,

      Can you send me your logs?
      How can I repeat this error?

      Karl

       

      Last edit: Karl Jones 2014-12-09
  • siavee

    siavee - 2014-12-09

    Hi Karl,

    To reproduce this error, I do the following:
    - Clone the repo
    - Checkout the vdevelop branch
    - Open the project in Unity (I use version 4.6.0f3)
    - Do the next steps in an empty scene, with the default MainCamera GameObject
    - Confirm that there is no error by pressing Play
    - Stop the game
    - Select Main Camera GameObject and add EntityState PDU component by clicking on Component > DISUnity > PDU > Entity Info Interaction > Entity State
    - Press Play
    - The error should be logged in the console
    - Press Play again to stop the game, the error should appear one more time in the console

    The interesting thing is that if we remove the Entity State Wrapper Component from Main Camera GameObject and then press Play, the error still happens.

    I also attached Unity Editor log for you to check.

    Thank you,
    Avi

     
    • Karl  Jones

      Karl Jones - 2014-12-09

      Thanks Avi. I'll take a look at it tonight.
      Karl

       

      Last edit: Karl Jones 2014-12-09
  • Karl  Jones

    Karl Jones - 2014-12-09

    Hi Avi,

    The error is being caused by MonoBehaviourSingleton on line 17.
    This is caused by the destructor attempting to destroy some objects using the MemoryManager class. This is all caused by the way I handle VariableParameters and similar data types. The Unity inspector does not support complex data types unless they inherit from Scriptable object.
    For example if I have a base class A and my MonoBehaviour had a list of this base class then any classes that are added to the list which inherit from A will be converted to the base class version in the inspector. However if I inherit my base class from ScriptableObject then it works but I now have issues where I can only create, delete, compare etc the object in the main thread. So a destructor which is not always called from the main thread causes issues. The ScriptableObjects are not garbage collected, they must be destroyed (like C++).

    I have tried a few different approaches before this method but I think I am going to scrap my current method in favour of using standard .net. This will make things much simpler and far less buggy however I will need to think of a way to allow the inspector to still work.
    My initial thought is to simply add multiple lists to the PDU that have all the supported data types, instead of a single list to the base data type. Its not ideal but there are not actually that many data types to support. I will start making the changes soon(probably now).

    Karl

     
  • Karl  Jones

    Karl Jones - 2014-12-09

    Ok all done. The entity state pdu should work with no errors now.

    I have not finished making changes to the fire and detonation PDU yet so the descriptor field is not shown in the inspector at the moment.

    K

     
  • siavee

    siavee - 2014-12-11

    Hi Karl,

    Thank you for the update! Sorry I haven't answered very quickly, our team is currently on site to do some testing on the hardwares.

    I see, so the problem is due to the use of ScriptableObjects. I have not used them myself in the projects that I've done because I think they are not very intuitive. However I agree with you that using multiple lists are is not the most elegant way to show data in the inspector.

    I have also made some minor changes to remove the error for the descriptor member variable in Fire & Detonation PDU in vdevelop branch.

    Thanks,
    Avi

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.