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

Android: Fixed an OpenGL crash that would occur due to failing to get a pointer to the native window

This commit is contained in:
ed 2017-11-30 10:11:40 +00:00
parent 5f834225e0
commit 6894e04356
6 changed files with 49 additions and 14 deletions

View file

@ -88,7 +88,7 @@ public:
}
//==============================================================================
void initialiseOnRenderThread (OpenGLContext& aContext)
bool initialiseOnRenderThread (OpenGLContext& aContext)
{
jassert (hasInitialised);
@ -100,9 +100,25 @@ public:
// get a pointer to the native window
ANativeWindow* window = nullptr;
if (jobject jSurface = env->CallObjectMethod (surfaceView.get(), NativeSurfaceView.getNativeSurface))
window = ANativeWindow_fromSurface (env, jSurface);
{
window = ANativeWindow_fromSurface(env, jSurface);
jassert (window != nullptr);
// if we didn't succeed the first time, wait 25ms and try again
if (window == nullptr)
{
Thread::sleep (25);
window = ANativeWindow_fromSurface (env, jSurface);
}
}
if (window == nullptr)
{
// failed to get a pointer to the native window after second try so
// bail out
jassertfalse;
return false;
}
// create the surface
surface = eglCreateWindowSurface(display, config, window, 0);
@ -116,6 +132,8 @@ public:
jassert (context != EGL_NO_CONTEXT);
juceContext = &aContext;
return true;
}
void shutdownOnRenderThread()