Crash when releasing IView object
Hi,
I've implemented NoesisGUI with Urho3D and some of the samples (ImageAtlas.xaml and Palette.xaml) crashes the program during the destruction (mPtr->Release()) of the xamlView Ptr.
I compiled the D3D11 sample that came with the package and no crash ocurred. I couldn't find anything in the docs but do I need to do additional cleanup/handling of noesis objects ?
Here's the code I'm using:
I've implemented NoesisGUI with Urho3D and some of the samples (ImageAtlas.xaml and Palette.xaml) crashes the program during the destruction (mPtr->Release()) of the xamlView Ptr.
I compiled the D3D11 sample that came with the package and no crash ocurred. I couldn't find anything in the docs but do I need to do additional cleanup/handling of noesis objects ?
Here's the code I'm using:
Code: Select all
Game::Game(Context* context) :
Application(context),
scene_(nullptr)
{
// NoesisGUI is initialized here. Resources will be loaded from current working directory
Noesis::GUI::Init(NoesisErrorHandler);
Noesis::GUI::SetResourceProvider(".");
}
Game::~Game()
{
// Shutdown Noesis Engine
Noesis::GUI::Shutdown();
}
void Game::Start()
{
Graphics* graphics = this->GetSubsystem<Graphics>(); // Urho3D Graphics Object
// --------------------------------------------------
// Noesis Context Initialization
Noesis::Ptr<Noesis::D3D11RenderDevice> nsDevice = *new Noesis::D3D11RenderDevice(graphics->GetImpl()->GetDeviceContext());
Noesis::Ptr<Noesis::VGContext> nsContext = Noesis::GUI::CreateVGContext(nsDevice.GetPtr(), Noesis::VGOptions());
// Noesis Views
Noesis::Ptr<Noesis::FrameworkElement> mainXaml = Noesis::GUI::LoadXaml<Noesis::FrameworkElement>("Samples\\ImageAtlas.xaml");
this->nsMainView = Noesis::GUI::CreateView(mainXaml.GetPtr());
this->nsMainView->GetRenderer()->Init(nsContext.GetPtr());
this->nsMainView->SetSize(graphics->GetWidth(), graphics->GetHeight());
this->nsMainView->SetAntialiasingMode(Noesis::AntialiasingMode::AntialiasingMode_PPAA);
// --------------------------------------------------
// Urho3D stuff
// ...
}
void Game::Stop()
{
this->nsMainView.Reset();
}
// ======================================================================
// Core events
// ======================================================================
void Game::OnUpdate(StringHash type, VariantMap &args)
{
static double timestep = 0;
timestep += args[Update::P_TIMESTEP].GetFloat();
this->nsMainView->Update(timestep);
}
// ======================================================================
// Graphics events
// ======================================================================
void Game::OnScreenMode(StringHash type, VariantMap &args)
{
int width = args[ScreenMode::P_WIDTH].GetInt();
int height = args[ScreenMode::P_HEIGHT].GetInt();
// ...
this->nsMainView->SetSize(width, height);
}
void Game::OnBeginRendering(StringHash type, VariantMap &args)
{
// Performs rendering operations.
Noesis::IRenderer* nsRenderer = this->nsMainView->GetRenderer();
// Applies changes to the render tree
nsRenderer->UpdateRenderTree();
// Renders offscreen textures. This step must be done before binding the main render target
if (nsRenderer->NeedsOffscreen())
{
nsRenderer->RenderOffscreen();
}
}
void Game::OnEndRendering(StringHash type, VariantMap &args)
{
this->nsMainView->GetRenderer()->Render();
}
- ai_enabled
- Posts: 231
- Joined:
- Contact:
Re: Crash when releasing IView object
Cannot find where you're calling Release() in the posted source code. Could you include this too?
In C#, we're calling Shutdown() for the renderer object in the view object first. It seems xamlView.Reset() is doing the same in C++. From NoesisGUI DX11 C++ sample:
UPD. Ok I see you're calling nsMainView.Reset() in the Stop method. Please ensure it's called before Noesis::GUI::Shutdown().
In C#, we're calling Shutdown() for the renderer object in the view object first. It seems xamlView.Reset() is doing the same in C++. From NoesisGUI DX11 C++ sample:
Code: Select all
// Free global resources and shutdown kernel
g_XamlView.Reset();
Noesis::GUI::Shutdown();
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
Re: Crash when releasing IView object
Try attaching the debugger to see the call stack and what caused the crash (null pointer access etc).
If you are using a dedicated rendering thread, you may also want to check that. You need to make sure the thread is stopped before the clean up sequence.
If you are using a dedicated rendering thread, you may also want to check that. You need to make sure the thread is stopped before the clean up sequence.
Re: Crash when releasing IView object
@ai_enabled
The Game::Stop() method is called before the destructor, so the xamlView would be properly released before Noesis shutdown.
@nikobarli
Both Rendering/Update of the Game/Noesis happens in the main thread. Here's the callstack:
The Game::Stop() method is called before the destructor, so the xamlView would be properly released before Noesis shutdown.
@nikobarli
Both Rendering/Update of the Game/Noesis happens in the main thread. Here's the callstack:
Code: Select all
First-chance exception at 0x00000000778F3290 (ntdll.dll) in Game_debug.exe: 0xC0000005: Access violation reading location 0x00000FD2B9959E58.
ntdll.dll!00000000778f3290() Unknown
kernel32.dll!00000000777a300a() Unknown
Noesis.dll!000007fede2b8a98() Unknown
[External Code]
Noesis.dll!000007feddfc1353() Unknown
Noesis.dll!000007fede2ac53e() Unknown
Noesis.dll!000007fede2ac4b4() Unknown
Noesis.dll!000007feddfc1353() Unknown
Noesis.dll!000007fede014bcf() Unknown
Noesis.dll!000007feddfc1353() Unknown
Noesis.dll!000007fede136a56() Unknown
Noesis.dll!000007fede135efb() Unknown
Noesis.dll!000007fede13529f() Unknown
Noesis.dll!000007fede135164() Unknown
Noesis.dll!000007feddfc1353() Unknown
Noesis.dll!000007fede13369d() Unknown
Noesis.dll!000007fede133524() Unknown
Noesis.dll!000007feddfc1353() Unknown
Noesis.dll!000007fede1a2cd6() Unknown
Noesis.dll!000007fede1a2c54() Unknown
Noesis.dll!000007feddfc1353() Unknown
> Game_debug.exe!Noesis::Core::Ptr<Noesis::Gui::IView>::Reset() Line 160 C++
Game_debug.exe!Game::Stop() Line 108 C++
[External Code]
Game_debug.exe!RunApplication() Line 6 C++
Game_debug.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * prevInstance, char * cmdLine, int showCmd) Line 6 C++
[External Code]
Re: Crash when releasing IView object
If I understand, you want exit program without crash?
If yes, you need reset everything from Noesis, not only IView.
That means all:
FrameworkElements
IViews
RenderDevices (OpenGL, DX, or another)
Contexts
If it is not this case, please explain when you call IView.reset() and why you call it.
If yes, you need reset everything from Noesis, not only IView.
That means all:
FrameworkElements
IViews
RenderDevices (OpenGL, DX, or another)
Contexts
If it is not this case, please explain when you call IView.reset() and why you call it.
Re: Crash when releasing IView object
Yes, I want to terminate the program without crashes.
I tested all of the samples and the ones that are crashing is using <ImageBrush> in the xaml.
I tested all of the samples and the ones that are crashing is using <ImageBrush> in the xaml.
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Crash when releasing IView object
Hi,
I just tried the D3D11 sample that comes with the C++ SDK, added some Image elements and ImageBrushes to the test xaml and it closes without crashes.
Please make sure you are releasing all the resources allocated by the render device before calling Noesis::GUI::Shutdown(). You can also force to end all pending rendering commands in Noesis Renderer by calling this->nsMainView->GetRenderer()->Shutdown() before the global Shutdown.
Let me know if any of this works.
I just tried the D3D11 sample that comes with the C++ SDK, added some Image elements and ImageBrushes to the test xaml and it closes without crashes.
Please make sure you are releasing all the resources allocated by the render device before calling Noesis::GUI::Shutdown(). You can also force to end all pending rendering commands in Noesis Renderer by calling this->nsMainView->GetRenderer()->Shutdown() before the global Shutdown.
Let me know if any of this works.
Re: Crash when releasing IView object
I tried calling the IRenderer::Shutdown() and unfortunately, it throws the same exception.
Everything but D3D context (It's using Urho3D's context) is the same as the project sample included in the Noesis package.
Is there anything specific that has to be set in the D3D context?
Everything but D3D context (It's using Urho3D's context) is the same as the project sample included in the Noesis package.
Is there anything specific that has to be set in the D3D context?
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: Crash when releasing IView object
Could you please create a ticket in our bugtracker and add a link to your project data so we can debug it and see where exactly the crash is happening?
Who is online
Users browsing this forum: No registered users and 89 guests