Page 1 of 1
[2.2] Help understanding initialise resource group crash [SOLVED]
Posted: Fri Oct 08, 2021 12:25 am
by old_man_auz
Hi,
I recently decided to see if I could get the Terra terrain component working in my project. Before implementation, the flow of my code was:
Code: Select all
1) Create and initialise Ogre::Root
2) Add my resources into an "Assets" resource group (ResourceGroupManager::addResourceLocation())
3) Load PBS + Unlit HLMS resources
4) Load Texture & HLMS disk caches
5) Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(true);
6) Create scene manager
7) Create camera
8) Setup compositor
So looking at "Tutorial_Terrain.cpp" from the Ogre source, I made the following changes:
Code: Select all
2) Add my resources into an "Assets" resource group & Add the needed terrain resources into a "Terrain" resource group (ResourceGroupManager::addResourceLocation())
3) Load PBS + Unlit + Terra HLMS resources
As far as I can tell, I'm doing everything in exactly the same order as the tutorial. This resulted in just a straight crash to desktop with no errors in the Ogre log file. The last line in the log file was: "Parsing script Terra.material.json". The outcome was the same with either the DirectX11 or OpenGL3+ rendersystem.
To fix the crash, this I did the following:
Code: Select all
1) Create and initialise Ogre::Root
2) Add my resources into an "Assets" resource group & Add the needed terrain resources into a "Terrain" resource group (ResourceGroupManager::addResourceLocation())
3) Load PBS + Unlit HLMS resources
4) Ogre::ResourceGroupManager::getSingleton().initialiseResourceGroup("Terrain", true);
5) Load Terra HLMS resources
6) Load Texture & HLMS disk caches
7) Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(true);
8) Create scene manager
9) Create camera
10) Setup compositor
So what makes Ogre crash silently in "Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(true);"?
Thanks.
Re: [2.2] Help understanding initialise resource group crash
Posted: Fri Oct 08, 2021 12:54 am
by dark_sylinc
Hi!
Do you have a callstack?
Just to be sure I'd put the terrain resources in "General" rather than "Terrain" group. I don't see step 4 needs to be done separately. You should be able to do it in step 7.
That should be fine as long as you create your Ogre::Terra pointer after step 10. You should be able to create your HlmsTerra pointer at step 3 alongside PBS and Unlit.
Cheers
Matias
Re: [2.2] Help understanding initialise resource group crash
Posted: Fri Oct 08, 2021 9:02 am
by old_man_auz
Call stack is below. Is that saying that it is crashing in rapidjson? If it matters:
- I'm using rapidjson version: 1.1.0
- If I remove "Terra.material.json" then it stops crashing at "initialiseAllResourceGroups"
- I recopied "Terra.material.json" from the sdk to make sure I hadn't accidently edited it
- In "Terra.material.json" what is "unique_name" supposed to be from line: "sampler" : "unique_name"
Code: Select all
ucrtbased.dll!00007ffdaec31a65() Unknown
ucrtbased.dll!00007ffdaec31883() Unknown
ucrtbased.dll!00007ffdaec341cf() Unknown
> total_destruction_win_d.exe!rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::FindMember<rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> & name) Line 1154 C++
total_destruction_win_d.exe!rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::FindMember(const char * name) Line 1134 C++
total_destruction_win_d.exe!rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::FindMember(const char * name) Line 1137 C++
total_destruction_win_d.exe!Ogre::HlmsJsonTerra::loadMaterial(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> & json, const Ogre::HlmsJson::NamedBlocks & blocks, Ogre::HlmsDatablock * datablock, const std::string & resourceGroup) Line 229 C++
total_destruction_win_d.exe!Ogre::HlmsTerra::_loadJson(const rapidjson::GenericValue<rapidjson::UTF8<char>,rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> & jsonValue, const Ogre::HlmsJson::NamedBlocks & blocks, Ogre::HlmsDatablock * datablock, const std::string & resourceGroup, Ogre::HlmsJsonListener * listener, const std::string & additionalTextureExtension) Line 699 C++
[External Code]
total_destruction_win_d.exe!RenderManager::Initialise(std::string windowtitle) Line 84 C++
total_destruction_win_d.exe!Engine::Initialise() Line 136 C++
total_destruction_win_d.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 23 C++
[External Code]
Re: [2.2] Help understanding initialise resource group crash
Posted: Fri Oct 08, 2021 3:16 pm
by old_man_auz
More info if this is useful:
Does the "HlmsTerra::_loadJson" call initiate from inside the "OgreMain.dll" or "OgreHlmsPbs.dll"?
Re: [2.2] Help understanding initialise resource group crash
Posted: Fri Oct 08, 2021 4:27 pm
by dark_sylinc
Ahh! Something you posted made me suspect of what's going on.
I think you're mixing a Release build of Ogre with your Debug build. You have 2 choices:
- Use a Debug build of Ogre with the Debug build of your app
- In your compiler set the macro OGRE_DEBUG_MODE to 0, i.e. in Visual Studio go to Alt+F7 C++ -> Preprocessor Directives -> Preprocessor Defintitions and add "OGRE_DEBUG_MODE=0;" (no quotes).
I'd recommend a Debug Ogre build because there are more debug checks performed to detect incorrect usage.
Cheers
Matias
PS btw to reveal [External Code] in the call stack right click and tick "Show External Code".
PS 2 Please make sure the Rapidjson you're using is
exactly the same that Ogre was built with. Otherwise you'll get nasty crashes.
Re: [2.2] Help understanding initialise resource group crash
Posted: Fri Oct 08, 2021 11:41 pm
by old_man_auz
I didn't think I was mixing my debug with Ogre release? My debug configuration:
- I have the "_DEBUG" prepocessor definition.
- Linking against "ogre-sdk-v2.2.5-vc19-x64\lib\Debug" folder in the sdk
- Additional dependencies are "OgreHlmsPbs_d.lib;OgreHlmsUnlit_d.lib;OgreMain_d.lib"
- Using the "*_d.dll" files
1) Or do I need to compile Ogre from source in debug mode?
2) Just to clarift, your option number 2 > "OGRE_DEBUG_MODE=0;" is if I want my code in debug mode, but Ogre's in release?
3) Yep, it was a rapidjson version error. I recompiled with the Rapidjson code from the "ogre-next-deps" and it is working now.
4) Is it worth putting a link to the "ogre-next-deps" git hub repo at "
https://www.ogre3d.org/download/sdk/sdk-ogre-next"? It wasn't obvious to me that it existed. Or a reference to it in the readme at "OGRECave/ogre-next"?
Thanks for the help
Re: [2.2] Help understanding initialise resource group crash
Posted: Fri Oct 08, 2021 11:56 pm
by dark_sylinc
old_man_auz wrote: Fri Oct 08, 2021 11:41 pm
I didn't think I was mixing my debug with Ogre release? My debug configuration:
- I have the "_DEBUG" prepocessor definition.
- Linking against "ogre-sdk-v2.2.5-vc19-x64\lib\Debug" folder in the sdk
- Additional dependencies are "OgreHlmsPbs_d.lib;OgreHlmsUnlit_d.lib;OgreMain_d.lib"
- Using the "*_d.dll" files
1) Or do I need to compile Ogre from source in debug mode?
No need. You did it well. That is enough
2) Just to clarift, your option number 2 > "OGRE_DEBUG_MODE=0;" is if I want my code in debug mode, but Ogre's in release?
That's right. If you want to use Ogre in Release while your code in Debug (hopefully I didn't miss anything; ensuring Release Ogre works in Debug is in my long TODO list, but there's a lot of platforms we support where that may be an issue).
3) Yep, it was a rapidjson version error. I recompiled with the Rapidjson code from the "ogre-next-deps" and it is working now.
Yay!
It's usually part of the building instructions in the
manual, since you're using our prebuilt SDK I guess you couldn't possibly see it.
I didn't realize not knowing the existence of ogre-next-deps could be an issue if you're integrating some of our code due to rapidjson. I'll update the front page in Github at the very least.
Re: [2.2] Help understanding initialise resource group crash
Posted: Sat Oct 09, 2021 12:16 am
by old_man_auz
So, linking against Ogre debug, should I be able to step into the external ogre code contained in dll?
Re: [2.2] Help understanding initialise resource group crash
Posted: Sat Oct 09, 2021 12:57 am
by dark_sylinc
old_man_auz wrote: Sat Oct 09, 2021 12:16 am
So, linking against Ogre debug, should I be able to step into the external ogre code contained in dll?
Yes, you said you are already linking against OgreMain
_d & co. so you could be able to step into them.
Just tell Visual Studio to "Show External Code". And you may also need to download our source code from
Github and tell Visual Studio where it is located.
Re: [2.2] Help understanding initialise resource group crash
Posted: Sat Oct 09, 2021 1:43 am
by old_man_auz
Thanks!