guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

Bakery gets stuck at 55% with an error `KeyNotFoundException: The given key was not present in the dictionary.` #17

Closed darthdeus closed 3 years ago

darthdeus commented 3 years ago

Sometimes (recently basically all the time) Bakery fails with the following error when baking a lightmap, the progress gets stuck, and closing the progress window also doesn't work. When I click on "Cancel" it instantly re-opens, and the only way to get rid of the error is to restart Unity.

Also just as a note, I don't think this is related only to my project, since there was another person reporting the same exact thing in Discord yesterday.

The error stacktrace

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <fb001e01371b4adca20013e0ac763896>:0)
ftUniqueIDRegistry.GetUID (System.Int32 instanceId) (at Assets/Plugins/Bakery/ftUniqueIDRegistry.cs:42)
ftRenderLightmap.GetID (UnityEngine.Object obj) (at Assets/Plugins/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:6376)
ftRenderLightmap.GetLightName (UnityEngine.GameObject obj, System.Int32 lmid) (at Assets/Plugins/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:6381)
ftRenderLightmap+<RenderLMDirect>d__271.MoveNext () (at Assets/Plugins/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:7352)
ftRenderLightmap+<RenderLightmapFunc>d__252.MoveNext () (at Assets/Plugins/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:4848)
ftRenderLightmap.RenderLightmapUpdate () (at Assets/Plugins/Editor/x64/Bakery/scripts/ftRenderLightmap.cs:3743)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <d1bec46880064709a5e713ad543e6d96>:0)

progress

image

console

image

Bakery settings

image

GuillaumeCauvet commented 3 years ago

there was another person reporting the same exact thing in Discord yesterday.

It was me (Waidz), but user Kjarudi|Jan reported it too.

I didn't find any kind of trigger to this isssue, deleting previous baking data and bakery cache doesn't seem to necessary fix it either.

Sometimes restarting Unity fix it but it is very random and might need multiples restarts

guycalledfrank commented 3 years ago

I'm aware of this issue but wasn't able to find the root cause yet. Usually it goes away simply if you render again (you can fix the window by right-clicking any script, e.g. ftRenderLightmap.cs -> Reimport). Will notify when a reliable fix is found.

guycalledfrank commented 3 years ago

Pushed a possible fix: https://github.com/guycalledfrank/bakery-csharp/commit/5bb66c9415cf848cef0a6fb3d603fedf01721139

darthdeus commented 3 years ago

@guycalledfrank Seems to be fixed, I haven't had the error since :) Leaving it up to you if you want to close this

SamFZGames commented 7 months ago

Though this is closed, I'm commenting on it due to a sort of similar issue. I seem to get stuck on 55% "Exporting Scene - shaded surface colors...", and if I hit Cancel, the window just comes back up again, until I force quit Unity.

guycalledfrank commented 7 months ago

Do you possibly have just way too many lightmaps? Try enabling Checker Preview - it will print future lightmap count to console, and you can also look through their layouts in Atlas Preview before baking. If there are hundreds lightmaps... could explain it

SamFZGames commented 7 months ago

Yes, there are hundreds. Thousands, even. I'm not the original developer, just making an optimised port of the game, their scenes have a lot of separate meshes and it would take a very long time to combine them. Is there any workaround?

guycalledfrank commented 7 months ago

See: https://geom.io/bakery/wiki/index.php?title=Troubleshooting#I_get_too_many_lightmaps

SamFZGames commented 7 months ago

Ah! That's very useful. I had missed that part of the Troubleshooting. Thank you.