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

Importing numpy crashes Py.GIL()

Discussion in 'Formats & External Tools Previews' started by TrashestCoder, Jan 12, 2022.

  1. TrashestCoder

    TrashestCoder

    Joined:
    Jan 27, 2017
    Posts:
    14
    If you import numpy into default PySideExample.py code and run it in the play mode, Unity, after entering play mode for the second time, crashes. Strangely numpy works just fine for the first time it enters playmode. Both times I call this script using Py.GIL(), just like in the example. Even after using an empty .py file, that only imports numpy, it still crashes exactly after second play mode.
    As it crashes unity temporarily throws this error:

    SerializationException: Type 'UnityEngine.UnityLogWriter' in Assembly 'UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

    Any suggestions how to fix this problem? Maybe it has to do with garbage collection?

    Edit: Found easier way to replicate this issue: Open unity python console and execute "import numpy". Then enter play mode and this issue repeats again
     
    Last edited: Jan 12, 2022
  2. Klanawohm

    Klanawohm

    Joined:
    Apr 29, 2022
    Posts:
    1
    I also have this problem,have you solved it?
     
  3. TrashestCoder

    TrashestCoder

    Joined:
    Jan 27, 2017
    Posts:
    14
  4. MassiveTchnologies

    MassiveTchnologies

    Joined:
    Jul 5, 2016
    Posts:
    87
    Same issue, happens at every domain relode. How to fix this?

    The whole python api is pretty useless without numpy.
     
  5. guoxx_

    guoxx_

    Joined:
    Mar 16, 2021
    Posts:
    55
  6. MassiveTchnologies

    MassiveTchnologies

    Joined:
    Jul 5, 2016
    Posts:
    87
    Issue in our case happens when purely just importing numpy, even if we are doing no operations at all with numpy