Articy objects being GCed - causes crash
Posted: Wed 20. Dec 2017, 18:38
Hi,
There are a few issues here. First when ArticyDatabase object is cloned form the original asset it is held as a static weak pointer. This causes the object to be GCed after a while and forces it to be recreated from asset (which may take a significant amount of time because the asset is also GCed). The same happens with ArticyGlobalVariables object - this can reset the state of the game. The solution for this is to put the objects into UPROPERTYied class member variable or cache in a blueprint variable or call AddToRoot() on cloned objects.
But this doesn't produce the crash. Unfortunately similar case relates to all articy objects. Cloned articy objects are held in two maps: LoadedObjectsById and LoadedObjectsByName. Both of these maps are not UPROPERTY variables so they will get GCed. When this happens the first call to PlayBranch will crash in
To fix this I've added a UPROPERTYied
I'm not sure if this is a good solution. What do you think?
There are a few issues here. First when ArticyDatabase object is cloned form the original asset it is held as a static weak pointer. This causes the object to be GCed after a while and forces it to be recreated from asset (which may take a significant amount of time because the asset is also GCed). The same happens with ArticyGlobalVariables object - this can reset the state of the game. The solution for this is to put the objects into UPROPERTYied class member variable or cache in a blueprint variable or call AddToRoot() on cloned objects.
But this doesn't produce the crash. Unfortunately similar case relates to all articy objects. Cloned articy objects are held in two maps: LoadedObjectsById and LoadedObjectsByName. Both of these maps are not UPROPERTY variables so they will get GCed. When this happens the first call to PlayBranch will crash in
- Code: Select all
ArticyDatabase::GetOrClone<T>()
- Code: Select all
bool UObjectBaseUtility::IsA<T>() const
To fix this I've added a UPROPERTYied
- Code: Select all
TArray<UArticyPrimitive *>
- Code: Select all
UArticyDatabase::LoadPackage()
I'm not sure if this is a good solution. What do you think?