Skip to content
Merged
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
8 changes: 7 additions & 1 deletion Modules/@babylonjs/react-native/shared/BabylonNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace Babylon
}

g_graphics->EnableRendering();
m_isRenderingEnabled = true;

std::call_once(m_isGraphicsInitialized, [this]()
{
Expand All @@ -97,7 +98,9 @@ namespace Babylon

void RenderView()
{
if (g_graphics)
// If rendering has not been explicitly enabled, or has been explicitly disabled, then don't try to render.
// Otherwise rendering can be implicitly enabled, which may not be desirable (e.g. after the engine is disposed).
if (g_graphics && m_isRenderingEnabled)
{
g_graphics->StartRenderingCurrentFrame();
g_graphics->FinishRenderingCurrentFrame();
Expand All @@ -115,6 +118,8 @@ namespace Babylon
CreateInitPromise();
});
}

m_isRenderingEnabled = false;
}

void SetMouseButtonState(uint32_t buttonId, bool isDown, uint32_t x, uint32_t y)
Expand Down Expand Up @@ -198,6 +203,7 @@ namespace Babylon
Dispatcher m_jsDispatcher{};

std::shared_ptr<bool> m_isRunning{};
bool m_isRenderingEnabled{};
std::once_flag m_isGraphicsInitialized{};
Plugins::NativeInput* m_nativeInput{};
std::optional<Plugins::NativeXr> m_nativeXr{};
Expand Down