Skip to content

Commit

Permalink
Attach the current thread to the JVM before calling jni routines.
Browse files Browse the repository at this point in the history
  • Loading branch information
vauradkar committed Jun 1, 2024
1 parent 51d749f commit 0f13107
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions filament/src/details/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include <filament/MaterialEnums.h>

#include <private/backend/PlatformFactory.h>
#if defined(__ANDROID__)
#include <private/backend/VirtualMachineEnv.h>
#endif


#include <backend/DriverEnums.h>

Expand Down Expand Up @@ -637,6 +641,11 @@ void FEngine::flushAndWait() {

int FEngine::loop() {
if (mPlatform == nullptr) {
#if defined(__ANDROID__)
// this thread might call jni routines. Attach the current thread. The
// return value is unused
(void)filament::VirtualMachineEnv::get().getEnvironment();
#endif
mPlatform = PlatformFactory::create(&mBackend);
mOwnPlatform = true;
const char* const backend = backendToString(mBackend);
Expand Down

0 comments on commit 0f13107

Please sign in to comment.