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:
parent
fd20804ed9
commit
bd0ec0ca8c
1 changed files with 17 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue