Editor crashes when calling Lightmapping.ClearLightingDataAsset()

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:

0x00007FF6DD448E4F (Unity) PPtr<Texture>::operator Texture * __ptr64
0x00007FF6E04F202D (Unity) LightingDataAsset::smile:eleteAssets
0x00007FF6E04F2685 (Unity) LightingDataAsset::smile:estroyLightingDataForScenes
0x00007FF6E04F234D (Unity) LightingDataAsset::smile:estroyLightingDataForLoadedScenes
0x00007FF6DEAD3820 (Unity) Lightmapping_CUSTOM_ClearLightingDataAsset
0x000001C5D95461B5 (Mono JIT Code) (wrapper managed-to-native) UnityEditor.Lightmapping:ClearLightingDataAsset ()

Hi

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

Thanks :slight_smile:

@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.

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 :slight_smile:

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.

Additional crash log:

@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.

@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

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.)