-
Notifications
You must be signed in to change notification settings - Fork 307
Credit system BP: fix crashes when unloading then reloading UE levels #1630
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
base: main
Are you sure you want to change the base?
Credit system BP: fix crashes when unloading then reloading UE levels #1630
Conversation
Thanks @GhisBntly ! I wonder if this fixes #1413. We'll take a look when we get the chance. |
@GhisBntly Apologies for taking so long to look at this. Do you have steps to reproduce the crash this is meant to fix? I've tried reloading the same level over and over again in a shipping build of the Unreal samples project, and I don't experience any issues no matter how many times I reload. Is there a specific dataset this happens with? |
@azrogers , no worries about the delay 👍 I don't think the crash was related to our particular Bentley tilesets, we had the crash whatever the selected one. It is probably more specific to the way we instantiate the tilesets: to simplify/summarize, I mentioned reloading UE levels because I thought it was the root cause of the crash, but since you don't reproduce, I guess it is only indirectly related to reloading a level. On the other hand, looking at AITwinCesiumCreditSystem::GetDefaultCreditSystem, I am wondering what is actually preventing Unreal's GC from collecting the static CesiumCreditSystemBP, since the bpLoader is destroyed as soon as it did its job to load the asset? The CesiumCreditSystemBP is then only used to spawn the pCreditSystem returned. |
@GhisBntly That's a very good question. On a cursory look over the code, I don't think I'm sure either. This PR might give us some more certainty there, but I'd like to get to the bottom of the credit system's behavior to figure out what's actually going on and going wrong here. @kring do you have any insight? |
Hmm yeah that I can't get this to happen, though, not even when @GhisBntly perhaps you are unloading and reloading levels in a built game? And creating them at runtime such that If that's what's happening, then calling |
Yes Kevin, that's exactly the situation you describe (unloading and reloading levels in a built game ...). Some say that |
Well, looks like |
IsValid was a first attempt at fixing these crashes which were witnessed only in Shipping mode, ie. with no way of exactly knowing what was going on. But IsValid itself was apparently using CesiumCreditSystemBP after its deletion, so I ended up adding the object to the GC's root set.
so that we don't have to manage its lifecycle and especially not CesiumCreditSystemBP's lifecycle either, which was causing issues when unloading then reloading levels in-game (Shipping).
046f175
to
966815c
Compare
@kring @azrogers If you want to have a look, I pushed a new version with a loader inheriting from About the implementation you'll see it is much simpler, at least if I did not misunderstand the APIs:
|
I have confirmed that the subsystem also fixes the crash. I don't see any regression in using this version instead of the static variable, but I may not have tested all that needs to be, so I'll let you decide how to proceed with this PR. |
IsValid was a first attempt at fixing these crashes which were witnessed only in Shipping mode, ie. with no way of exactly knowing what was going on. But IsValid itself was apparently using CesiumCreditSystemBP after its deletion, so I ended up adding the object to the GC's root set.