guycalledfrank / bakery-issues

Bug tracker for Bakery
4 stars 0 forks source link

Bakery bloating scene files over time. #61

Closed Zurigan closed 3 years ago

Zurigan commented 3 years ago

Noticed that over time Unity scene files seemed to be growing. Trying to work out why at least part of the issue seems to be in the data Bakery is saving for lights.

As far as I understand the file format it looks like Bakery is saving details for hundreds of lights even though there are only 11 in the scene.

Files attached are an original scene then a new scene with its contents copied from the original. The new scene is ~1/6th the size on disk.

Scene Files.zip

Zurigan commented 3 years ago

Ha, so ... the bigger bloat issue is because Bakery is saving the Real-Time Preview texture into the scene file.

guycalledfrank commented 3 years ago

Oh well :) Fixed: https://github.com/guycalledfrank/bakery-rtpreview-csharp/commit/bac3998b2ae40e539a50ad0f1b62fc191e8de83e

Was it the only issue? In this case the scene file won't bloat over time, but would only become a bit larger once after using the preview for the first time.

Zurigan commented 3 years ago

That URL doesn't work for me ... the two issues I saw were hundreds of lights in the file that shouldn't be there (which I think grows over time, search for 'tform:') and the RTP image getting saved which adds a few MB one time only.

guycalledfrank commented 3 years ago

The URL is private, but you can add yourself automatically: https://geom.io/bakery/github-access-rtpreview.html

Lights... it is the lights array, right? And you don't have too many of them in the scene? Are there just duplicates?

Zurigan commented 3 years ago

Yes the lights array ... Home.unity has 11 lights in it, the .unity file array has 431!

guycalledfrank commented 3 years ago

Did you have many lights at some point? Or create/delete them often before bakes? The lights are only added to the list if it can't find the light with the same UID. I can purge unused/deleted light entries, shouldn't be hard to fix...

Zurigan commented 3 years ago

11 is the most there have ever been, no repeat creation/deletion going on. Removing array entries that aren't in the scene sounds like a sensible thing to do!

guycalledfrank commented 3 years ago

That should work: https://github.com/guycalledfrank/bakery-csharp/commit/b8a49fd7a97f3de6425f28115bc08291875ea045

The only reason for storing light information was to make it possible to skip rendering unmodified lights (disabled "Update unmodified lights" checkbox), as current lights are compared against previously used values. In practice disabling this checkbox is very rare, as any changes to geometry/maps still require it to be on... so the light array is now always reset if the checkbox is not disabled. Just went 40 -> 9 in one of my test scenes. Nice.

EDIT: forgot a line https://github.com/guycalledfrank/bakery-csharp/commit/1dddc6dc8ba66a52279c799c3449449f2d720297

Zurigan commented 3 years ago

This works ... my scene files are now ~7MB instead of 26MB total. Nice.

guycalledfrank commented 3 years ago

Phew!