Crash due to body material not being available on start
I'm just running into one error after another here. But this seems unrelated to my previous problems, and I didnt find any open issue for it either. This is with Gothic 2, and running on Manjaro Linux, plus latest master (408a0db0f06155470014d4b8d5bdf605e152210b).
I am getting this error after running ./REGoth ~/workspace/gothic2/ with an empty cache:
[INFO] [GameWorld] Insert Character PC_HERO at STARTPOINT
[FATAL] A fatal error occurred and the program has to terminate!
- Error: InternalErrorException
- Description: Trying to access an object that has been destroyed.
- In function: void bs::GameObjectHandleBase::throwIfDestroyed() const
- In file: workspace/regoth-bs/lib/bsf/Source/Foundation/bsfCore/Scene/BsGameObjectHandle.cpp:32
Stack trace:
0) workspace/regoth-bs/build/bin/../lib/libbsf.so.1: bs::CrashHandler::getStackTrace[abi:cxx11]()+0x1f2 [0x7fa487e9e0e2]
1) workspace/regoth-bs/build/bin/../lib/libbsf.so.1: bs::CrashHandler::logErrorAndStackTrace(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, unsigned int) const+0x354 [0x7fa487e7d954]
2) workspace/regoth-bs/build/bin/../lib/libbsf.so.1: bs::CrashHandler::reportCrash(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, unsigned int) const+0x5f [0x7fa487e9daaf]
3) workspace/regoth-bs/build/bin/../lib/libbsf.so.1: bs::GameObjectHandleBase::throwIfDestroyed() const+0xc4 [0x7fa488265234]
4) ./REGoth: REGoth::VisualSkeletalAnimation::material(unsigned int) const+0x18 [0x5624c3979fe8]
5) ./REGoth: REGoth::VisualCharacter::setBodyTexture(bs::TResourceHandle<bs::Texture, false>)+0x39 [0x5624c3969259]
6) ./REGoth: REGoth::VisualCharacter::onInitialized()+0xa1 [0x5624c3969661]
7) workspace/regoth-bs/build/bin/../lib/libbsf.so.1: bs::SceneManager::_notifyComponentCreated(bs::GameObjectHandle<bs::Component> const&, bool)+0x112 [0x7fa488282002]
8) ./REGoth: REGoth::Character::onInitialized()+0x3c8 [0x5624c38ea0f8]
9) /home/felix/workspace/regoth-bs/build/bin/../lib/libbsf.so.1: bs::SceneManager::_notifyComponentCreated(bs::GameObjectHandle<bs::Component> const&, bool)+0x112 [0x7fa488282002]
10) ./REGoth: REGoth::GameWorld::insertCharacter(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, bs::Transform const&)+0x271 [0x5624c39218f1]
11) ./REGoth: REGoth::GameWorld::insertCharacter(std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, bs::StdAlloc<char, bs::GenAlloc> > const&)+0x16f [0x5624c39229bf]
12) ./REGoth: REGoth::Gothic2Game::setupScene()+0x918 [0x5624c38d6ca8]
13) ./REGoth: REGoth::runEngine(REGoth::Engine&)+0x3ef [0x5624c38d78df]
14) ./REGoth: main+0x158 [0x5624c389c8b8]
15) /usr/lib/libc.so.6: __libc_start_main+0xf3 [0x7fa487260153]
16) ./REGoth: _start+0x2e [0x5624c38a81fe]
Interesting. Looks like the players body material has not been copied. That error is also thrown for handles which did not ever point to a valid object, so most likely Destroyed is not correct here, but that's an other issue! :smile:
Can you delete bin/cache/* and try again? Maybe the player model got corrupted because of a crash while caching resources...
I'll take a look at it when I get home!
PS: I would suggest changing the issue title to "Crash due to body material not being available on start" or something...
I already retried it with a cleared cache a few times, but the same error always happens. And I updated the title, but you can also do that yourself ;)
There are some other executables, such as REGothCharacterMovementTester. Does that work?
I tried REGothCharacterMovementTester, it has the exact same error (with cleared cache). REGothWorldCacheTest, REGothWorldMeshViewer and REGothCharacterViewer seem to work (there are no errors).
EDIT: Looking into a little closer. Commit e08094825f6a10d5240897d0c62030ae36faf407 was a bugfix so it works from cache, but the two lines in VisualCharacters onInitialized are always executed even if the objects are not loaded.
I am running into the same problem. From my quick research at the point where setBodyTexture is called https://github.com/REGoth-project/REGoth-bs/blob/408a0db0f06155470014d4b8d5bdf605e152210b/src/components/VisualCharacter.cpp#L40-L46 The mSubRenderable has not been initialized yet https://github.com/REGoth-project/REGoth-bs/blob/408a0db0f06155470014d4b8d5bdf605e152210b/src/components/VisualSkeletalAnimation.cpp#L26-L38 I dont know enough about the component, but maybe it is enough to call buildObjectSubtree in the onInitialize function.
When onInitialized is called, the Visual does not even know what it should be drawing if I'm not mistaken. The subtree is only built after a visual has been assigned. We should rather guard the calls which set the textures by whether a head and/or body mesh exists IMHO.