1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Android: Fixed a rare race-condition in android OpenGL startup which could occur if the OpenGL context is destroyed before it is fully initialised

This commit is contained in:
hogliux 2017-09-26 16:32:41 +01:00
parent fd20804ed9
commit bd0ec0ca8c

View file

@ -608,6 +608,7 @@ public:
};
//==============================================================================
friend class NativeContext;
ScopedPointer<NativeContext> nativeContext;
OpenGLContext& context;
@ -1213,12 +1214,16 @@ void OpenGLContext::NativeContext::surfaceCreated (jobject holder)
{
ignoreUnused (holder);
if (juceContext != nullptr)
if (auto* cachedImage = CachedImage::get (component))
{
if (OpenGLContext::CachedImage* cachedImage = juceContext->getCachedImage())
cachedImage->resume();
juceContext->triggerRepaint();
if (auto* pool = cachedImage->renderThread.get())
{
if (! pool->contains (cachedImage))
{
cachedImage->resume();
cachedImage->context.triggerRepaint();
}
}
}
}
@ -1228,9 +1233,13 @@ void OpenGLContext::NativeContext::surfaceDestroyed (jobject holder)
// unlike the name suggests this will be called just before the
// surface is destroyed. We need to pause the render thread.
if (juceContext != nullptr)
if (OpenGLContext::CachedImage* cachedImage = juceContext->getCachedImage())
cachedImage->pause();
if (auto* cachedImage = CachedImage::get (component))
{
cachedImage->pause();
if (auto* threadPool = cachedImage->renderThread.get())
threadPool->waitForJobToFinish (cachedImage, -1);
}
}
#endif