Android: Attach CPU thread to JVM early

This commit is contained in:
JosJuice 2020-09-14 17:58:33 +02:00
parent 3a0917371e
commit e86d713600
2 changed files with 15 additions and 0 deletions

View File

@ -583,6 +583,11 @@ if (APPLE)
${IOB_LIBRARY}
${IOK_LIBRARY}
)
elseif (ANDROID)
target_link_libraries(core
PRIVATE
androidcommon
)
endif()
if(LIBUSB_FOUND)

View File

@ -85,6 +85,10 @@
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
#ifdef ANDROID
#include "jni/AndroidCommon/IDCache.h"
#endif
namespace Core
{
static bool s_wants_determinism;
@ -335,6 +339,12 @@ static void CpuThread(const std::optional<std::string>& savestate_path, bool del
// This needs to be delayed until after the video backend is ready.
DolphinAnalytics::Instance().ReportGameStart();
#ifdef ANDROID
// For some reason, calling the JNI function AttachCurrentThread from the CPU thread after a
// certain point causes a crash if fastmem is enabled. Let's call it early to avoid that problem.
static_cast<void>(IDCache::GetEnvForThread());
#endif
if (_CoreParameter.bFastmem)
EMM::InstallExceptionHandler(); // Let's run under memory watch