mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Workaround for problems on Android when the OS reuses a posix thread for the openGL thread.
This commit is contained in:
parent
2022663c6b
commit
17863a45b6
2 changed files with 16 additions and 5 deletions
|
|
@ -290,13 +290,23 @@ public:
|
|||
if (android.activity != nullptr)
|
||||
{
|
||||
jvm->DetachCurrentThread();
|
||||
removeCurrentThreadFromCache();
|
||||
}
|
||||
}
|
||||
|
||||
const pthread_t thisThread = pthread_self();
|
||||
void removeCurrentThreadFromCache()
|
||||
{
|
||||
const pthread_t thisThread = pthread_self();
|
||||
|
||||
SpinLock::ScopedLockType sl (addRemoveLock);
|
||||
for (int i = 0; i < maxThreads; ++i)
|
||||
if (threads[i] == thisThread)
|
||||
threads[i] = 0;
|
||||
SpinLock::ScopedLockType sl (addRemoveLock);
|
||||
|
||||
for (int i = 0; i < maxThreads; ++i)
|
||||
{
|
||||
if (threads[i] == thisThread)
|
||||
{
|
||||
threads[i] = 0;
|
||||
envs[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ bool OpenGLHelpers::isContextActive()
|
|||
|
||||
JUCE_JNI_CALLBACK (GL_VIEW_CLASS_NAME, contextCreated, void, (JNIEnv* env, jobject view))
|
||||
{
|
||||
threadLocalJNIEnvHolder.removeCurrentThreadFromCache();
|
||||
threadLocalJNIEnvHolder.getOrAttach();
|
||||
|
||||
if (OpenGLContext::NativeContext* const context = OpenGLContext::NativeContext::findContextFor (env, view))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue