Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions Modules/@babylonjs/react-native/shared/BabylonNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ namespace BabylonNative

~ReactNativeModule() override
{
if (g_graphicsDevice)
{
g_update->Finish();
g_graphicsDevice->FinishRenderingCurrentFrame();
}

*m_isRunning = false;
Napi::Detach(m_env);
}
Expand All @@ -94,13 +100,20 @@ namespace BabylonNative
}
else
{
if (m_isRenderingEnabled)
{
g_update->Finish();
g_graphicsDevice->FinishRenderingCurrentFrame();
}

g_graphicsDevice->UpdateWindow(m_graphicsConfig.Window);
g_graphicsDevice->UpdateSize(m_graphicsConfig.Width, m_graphicsConfig.Height);
}
g_graphicsDevice->UpdateMSAA(mMSAAValue);
g_graphicsDevice->UpdateAlphaPremultiplied(mAlphaPremultiplied);

g_graphicsDevice->EnableRendering();
g_graphicsDevice->StartRenderingCurrentFrame();
g_update->Start();

std::call_once(m_isGraphicsInitialized, [this]()
{
Expand Down Expand Up @@ -150,10 +163,10 @@ namespace BabylonNative
// Otherwise rendering can be implicitly enabled, which may not be desirable (e.g. after the engine is disposed).
if (g_graphicsDevice && m_isRenderingEnabled)
{
g_graphicsDevice->StartRenderingCurrentFrame();
g_update->Start();
g_update->Finish();
g_graphicsDevice->FinishRenderingCurrentFrame();
g_graphicsDevice->StartRenderingCurrentFrame();
g_update->Start();
}
}

Expand All @@ -166,6 +179,8 @@ namespace BabylonNative
{
if (g_graphicsDevice)
{
g_update->Finish();
g_graphicsDevice->FinishRenderingCurrentFrame();
g_nativeCanvas->FlushGraphicResources();
g_graphicsDevice->DisableRendering();
}
Expand Down