Search Unity

Editor crashes when calling Lightmapping.ClearLightingDataAsset()

Discussion in 'Global Illumination' started by Kichang-Kim, Dec 19, 2019.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    Hi. I have a issue about editor crash when calling Lightmapping.ClearLightingDataAsset().

    I used Unity 2019.2.10f1, and created automated lightmapping script (processing target scene and bake lightmap by calling Lightmapping.Bake() in batch mode).

    The problem is that editor simply crashes at Lightmapping.ClearLightingDataAsset(). Bake() calls Lightmapping.ClearLightingDataAsset() internally so regardless of calling Lightmapping.ClearLightingDataAsset() manually, it crashes.

    But not always, sometimes success, sometimes crashes. Is anyone suffering from this problem?

    Here is my crash log:
    Code (CSharp):
    1. 0x00007FF6DD448E4F (Unity) PPtr<Texture>::operator Texture * __ptr64
    2. 0x00007FF6E04F202D (Unity) LightingDataAsset::DeleteAssets
    3. 0x00007FF6E04F2685 (Unity) LightingDataAsset::DestroyLightingDataForScenes
    4. 0x00007FF6E04F234D (Unity) LightingDataAsset::DestroyLightingDataForLoadedScenes
    5. 0x00007FF6DEAD3820 (Unity) Lightmapping_CUSTOM_ClearLightingDataAsset
    6. 0x000001C5D95461B5 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.Lightmapping:ClearLightingDataAsset ()
     
  2. JenniferNordwall

    JenniferNordwall

    Unity Technologies

    Joined:
    Sep 19, 2016
    Posts:
    160
    Hi

    Could you maybe file a bug and attach a small repo project? It's very hard just looking at the stacktrace.

    Thanks :)
     
  3. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    @JenniferNordwall Unfortunately, this issue can't be reproduced new/small project.

    I tried to avoid this issue by calling Lightmapping.Clear() (not ClearLightingDataAsset) before Lightmapping.Bake(). It seems to work but I'm not sure.
     
  4. JenniferNordwall

    JenniferNordwall

    Unity Technologies

    Joined:
    Sep 19, 2016
    Posts:
    160
    Hm ok. If you can file a bug with a repo project, we should be able to have a look. Doesn't have to be a tiny one either, we just need to be able to make sure that we can repo it on our end so that we know if it's fixed :)
     
  5. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    After changing to Lightmapping.Clear(), editor does not crash "before baking". But after baking, it just crashes but stack trace is empty. error.log shows like this:

    It seems related to Pyhsx Cloth component, but I didn't use that.
     
  6. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    Additional crash log:
     
  7. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    @JenniferNordwall I found that enabling OptixDenoiser makes crashes after baking lightmaps. When I change denoiser to OpenImageDenoiser, it dones't crash anymore. Both Unity 2019.2.10f1 and 2019.2.17f1 has this issue.
    Edit : Disabling OptixDenoiser doesn't work for large scene. Still crashed.
     
    Last edited: Dec 25, 2019
  8. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    @JenniferNordwall I'm not sure it is related to this issue, but found that another issue about Lightmapping.

    (Case 1207484) Baked Global Illumination sections in Scene View doesn't work until baking lightmapping in editor

    It seems that right after opening the editor, the lightmap data does not seem to load correctly.
    Affected Untiy : 2019.2.10, 2019.2.17, 2019.3.0f4
     
  9. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    I think I found temporary workaround for this issue.

    Before scene loading, I deleted LightingData.asset manually by using File.Delete() (AssetDatabase.DeleteAsset doesn't work) and AssetDatabase.Refresh(), then open scene and calling Bake() from script. No more crashes.
    (But I should delete unused lightmap textures manually.)