# Android crash on device orientation change

**URL:** <https://forum.juce.com/t/android-crash-on-device-orientation-change/35426>\
**Category:** Android\
**Created:** [September 26, 2019, 1:53pm UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426 "2019-09-26T13:53:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronaaron](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ronaaron/32/535_2.png) [@ronaaron](https://forum.juce.com/u/ronaaron)\
**Post date:** [September 26, 2019, 1:53pm UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/1 "2019-09-26T13:53:54Z")

</div>

I have OpenGL support running on Android, w/ JUCE 4 (I cannot upgrade to 5).

Everything is fine, with the exception of crashing on device orientation change, after a few rotations (usually between 3 and 6). Note: if I use the SW renderer instead, I don’t see the crash.

I believe this has been fixed in JUCE 5, but it’s untenable for me to upgrade. Has anyone solved this on JUCE 4? Specifically, the crash backtrace is:

- android/Surface/hook\_perform/ANativeWindow
- eglCreateWindowSurface
- OpenGLContext::CachedImage.runJob

Above that it’s calling a pure virtual function and then crashing.

---

<div class="post-metadata">

**Author:** ![ronaaron](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ronaaron/32/535_2.png) [@ronaaron](https://forum.juce.com/u/ronaaron)\
**Post date:** [October 24, 2019, 3:47pm UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/2 "2019-10-24T15:47:51Z")

</div>

Anyone?

---

<div class="post-metadata">

**Author:** ![ronaaron](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ronaaron/32/535_2.png) [@ronaaron](https://forum.juce.com/u/ronaaron)\
**Post date:** [November 11, 2019, 5:12am UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/3 "2019-11-11T05:12:09Z")

</div>

@fabian – any input?

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [November 11, 2019, 9:15am UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/4 "2019-11-11T09:15:04Z")

</div>

It’s hard to narrow it down as there were a lot of changes in the Android code between JUCE 4 and 5. If you know roughly where it was fixed then you can run `git bisect` to track down the specific commit which fixed it.

---

<div class="post-metadata">

**Author:** ![ronaaron](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ronaaron/32/535_2.png) [@ronaaron](https://forum.juce.com/u/ronaaron)\
**Post date:** [November 11, 2019, 10:02am UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/5 "2019-11-11T10:02:39Z")

</div>

I’m not even sure that 5 did fix the issue, though it sounds like it has since people have stopped complaining about GL crashes. I was hoping that someone who had worked on this would be able to give a more direct answer.

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [April 21, 2020, 10:35pm UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/6 "2020-04-21T22:35:14Z")

</div>

I seem to have hit this issue after adding landscape support for an Android app using JUCE.

I hit the assertion within

```cpp
if (window == nullptr) 

```

The stack trace:

```auto
juce::OpenGLContext::NativeContext::initialiseOnRenderThread(juce::OpenGLContext&) juce_OpenGL_android.h:163
juce::OpenGLContext::CachedImage::initialiseOnThread() juce_OpenGLContext.cpp:490
juce::OpenGLContext::CachedImage::runJob() juce_OpenGLContext.cpp:445
non-virtual thunk to juce::OpenGLContext::CachedImage::runJob() juce_OpenGLContext.cpp:0
juce::ThreadPool::runNextJob(juce::ThreadPool::ThreadPoolThread&) juce_ThreadPool.cpp:384
juce::ThreadPool::ThreadPoolThread::run() juce_ThreadPool.cpp:36
juce::Thread::threadEntryPoint() juce_Thread.cpp:96
juce::juce_threadEntryPoint(void*) juce_Thread.cpp:118
juce::threadEntryProc(void*) juce_posix_SharedCode.h:834
__pthread_start(void*) 0x000000797c0047bc
__start_thread 0x000000797bfa3578

```

I’ve tried detaching from the OpenGLContext in the Activity `onDestroy` and reattaching in `onCreate` but this seems to make no difference.

---

<div class="post-metadata">

**Author:** ![ronaaron](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ronaaron/32/535_2.png) [@ronaaron](https://forum.juce.com/u/ronaaron)\
**Post date:** [April 22, 2020, 4:02am UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/7 "2020-04-22T04:02:52Z")

</div>

Due to the lack of responsiveness of the JUCE team, I abandoned JUCE a while ago and though it was a lot of effort to do so, I’m a happier coder now. I wish you luck in finding a solution, but don’t count on the JUCErs to help you out.

---

<div class="post-metadata">

**Author:** ![adamwilson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/adamwilson/32/1387_2.png) [@adamwilson](https://forum.juce.com/u/adamwilson)\
**Post date:** [April 23, 2020, 11:05am UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/8 "2020-04-23T11:05:26Z")

</div>

TBH I think it’s just that Android issues are generally low priority. My recent experience (which does not include Android issues) has been that the JUCE team have been very responsive.

---

<div class="post-metadata">

**Author:** ![ronaaron](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ronaaron/32/535_2.png) [@ronaaron](https://forum.juce.com/u/ronaaron)\
**Post date:** [April 23, 2020, 11:38am UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/9 "2020-04-23T11:38:05Z")

</div>

Right, I know; but I was only using JUCE because of _multi-platform_ support; if they don’t actually _support_ the platforms, it’s much less useful to me. There are (or were) a lot of missing features in the Android port.

Anyway, best of luck!

---

<div class="post-metadata">

**Author:** ![TeotiGraphix](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/teotigraphix/32/2016_2.png) [@TeotiGraphix](https://forum.juce.com/u/TeotiGraphix)\
**Post date:** [April 23, 2020, 2:17pm UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/10 "2020-04-23T14:17:17Z")

</div>

> [@adamski](#):
>
> TBH I think it’s just that Android issues are generally low priority. My recent experience (which does not include Android issues) has been that the JUCE team have been very responsive.

I have read this for 10 years. 🙂

So the question is, in this new paradigm of JUCE 6, if there are experienced Android devs that can push the Android part farther, how hard is it to integrated fixes from the community. 😉

---

<div class="post-metadata">

**Author:** ![Bulien](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/bulien/32/3894_2.png) [@Bulien](https://forum.juce.com/u/Bulien)\
**Post date:** [April 23, 2020, 2:52pm UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/11 "2020-04-23T14:52:47Z")

</div>

I’m curious, did you adopt another cross platform framework? If so, which one?

---

<div class="post-metadata">

**Author:** ![ronaaron](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ronaaron/32/535_2.png) [@ronaaron](https://forum.juce.com/u/ronaaron)\
**Post date:** [April 23, 2020, 3:07pm UTC](https://forum.juce.com/t/android-crash-on-device-orientation-change/35426/12 "2020-04-23T15:07:16Z")

</div>

Yes. For GUI I adopted Nuklear; for sound miniaudio; for outer wrapper SDL2. The resultant binary is around half as big as it was with JUCE.
