Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't crash when building lighting for a level with a Cesium3DTileset #1181

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

kring
Copy link
Member

@kring kring commented Jul 31, 2023

Fixes #1180

UnrealLightmass.exe is a separate process run via Swarm when building lighting. As reported in #1180, it (always? usually?) crashes when we attempt to build lighting (Build -> Build Lighting Only) for a level that has a Cesium3DTileset in it. Unfortunately it's build without any debug symbols, so I had to build it myself to debug it.

Having done that, I learned that the problem is that every FStaticMeshLightingMesh pointed to the same FStaticMesh instance, which really couldn't be right. And I learned that that was happening because, on import, all the static mesh references had the same GUID (all zeros!). Ok, so the problem seemed to be back in the Unreal Editor on the export side.

So, I traced through the code that exported the lightmass data, and yep, it was writing a GUID of all zeros. It got that GUID from a property on the UStaticMesh called LightingGuid. So how is that property set? I searched for it in the UE source code, and saw that things like DatasmithStaticMeshImporter call SetLightingGuid on the static just before they called InitResources. I added the same to our code that creates the static mesh in CesiumGltfComponent, and the lightmass crash went away.

I'll spare everyone the rant about how ridiculous it is that we have to call some random undocumented method on every static mesh we create in order to prevent UE's static lighting baking system from crashing. 🤷

@cesium-concierge
Copy link

Thanks for the pull request @kring!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

@j9liu
Copy link
Contributor

j9liu commented Jul 31, 2023

Thanks @kring , I confirmed this removes the crash when building lighting data. I'll merge once CI passes!

@j9liu j9liu merged commit 5746e2c into ue5-main Jul 31, 2023
25 checks passed
@j9liu j9liu deleted the lighting-guid branch July 31, 2023 20:02
@kring
Copy link
Member Author

kring commented Aug 1, 2023

This page was helpful to me in learning how to debug the lightmass executable:
https://ikrima.dev/ue4guide/graphics-development/lightmass-lightmapping/debugging-lightmass/

The really short version is you can run lightmassdebug in the console, and then launch a light build normally, and Swarm will wait for you to start UnrealLightmass.exe manually rather than launching it itself. So you can run your debug version of it in the Visual Studio debugger, and it will pick up and execute the waiting job.

Just putting this here for possible future reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lightmass crashed when build lighting(ue 5.2)
3 participants