Repository: godot
Issue: Crash on Android with GLES2 ( signal 11, code 1, glGenerateMipmap)
Labels: bug,platform:android,topic:rendering,needs testing,crash

### Godot version

v3.4.4.stable.custom_build [419e713a2]

### System information

Android, GLES2, TCL TAB 8 4G, Tecno POP 4 LTE, more...

### Issue description

My app has recently received several crash reports in the Google Play console related to the GLES2 initialization code.
Custom build, with only XR modules disabled: `... module_mobile_vr_enabled="no" module_arkit_enabled="no" module_godot_remote_enabled="yes" godot_remote_disable_server="yes"`. Only the godot remote module was added, no other code changes were made.

Google crash report + ndk-stack (TCL TAB 8 4G):
```
********** Crash dump: **********
#00 0x000000000004f31c /apex/com.android.runtime/lib/bionic/libc.so (strlen_a15+72)
#00 0x0000000000080d4d /apex/com.android.runtime/lib/bionic/libc.so (__vfprintf+2984)
#00 0x00000000000952db /apex/com.android.runtime/lib/bionic/libc.so (vsnprintf+98)
#00 0x00000000000794e1 /vendor/lib/egl/libGLESv2_mtk.so
#00 0x000000000007929f /vendor/lib/egl/libGLESv2_mtk.so
#00 0x000000000003cb53 /vendor/lib/egl/libGLESv2_mtk.so
#00 0x000000000003d581 /vendor/lib/egl/libGLESv2_mtk.so
#00 0x000000000002ef2b /vendor/lib/egl/libGLESv2_mtk.so (glGenerateMipmap+562)
#00 0x00000000006d60e8 /data/app/com.dmitriysalnikov.godotremote-b1LM9CewMfx3En1_NwLdHA==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000) (RasterizerStorageGLES2::initialize()) (SourceCode: linux-atomic.c)
                                                                                                                                                            RasterizerStorageGLES2::initialize()
                                                                                                                                                            F:\Repositories\GodotRemoteClient\godot\godot_win\drivers\gles2\rasterizer_storage_gles2.cpp:6488:3
#00 0x000000000069a000 /data/app/com.dmitriysalnikov.godotremote-b1LM9CewMfx3En1_NwLdHA==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000) (RasterizerGLES2::initialize()) (SourceCode: linux-atomic.c)
                                                                                                                                                            RasterizerGLES2::initialize()
                                                                                                                                                            F:\Repositories\GodotRemoteClient\godot\godot_win\drivers\gles2\rasterizer_gles2.cpp:265:11
#00 0x0000000000086abc /data/app/com.dmitriysalnikov.godotremote-b1LM9CewMfx3En1_NwLdHA==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000) (OS_Android::initialize(OS::VideoMode const&, int, int)) (SourceCode: linux-atomic.c)
                                                                                                                                                            OS_Android::initialize(OS::VideoMode const&, int, int)
                                                                                                                                                            F:\Repositories\GodotRemoteClient\godot\godot_win\platform\android\os_android.cpp:180:17
#00 0x00000000000c6d9c /data/app/com.dmitriysalnikov.godotremote-b1LM9CewMfx3En1_NwLdHA==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000) (Main::setup2(unsigned long long)) (SourceCode: linux-atomic.c)
                                                                                                                                                            Main::setup2(unsigned long long)
                                                                                                                                                            F:\Repositories\GodotRemoteClient\godot\godot_win\main\main.cpp:1305:35
#00 0x00000000000938e0 /data/app/com.dmitriysalnikov.godotremote-b1LM9CewMfx3En1_NwLdHA==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000) (Java_org_godotengine_godot_GodotLib_step)
                                                                                                                                                            Java_org_godotengine_godot_GodotLib_step
                                                                                                                                                            F:\Repositories\GodotRemoteClient\godot\godot_win\platform\android\java_godot_lib_jni.cpp:245:3
#00 0x00000000000111bf /data/app/com.dmitriysalnikov.godotremote-b1LM9CewMfx3En1_NwLdHA==/oat/arm/base.odex (art_jni_trampoline+94)
#00 0x00000000000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68)
#00 0x000000000042e6db /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+246)
#00 0x00000000000dffcb /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+194)
#00 0x0000000000210b89 /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+280)
#00 0x000000000020c4cb /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+774)
#00 0x0000000000425df7 /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+310)
#00 0x00000000000d2994 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+20)
#00 0x000000000021fbdc /data/app/com.dmitriysalnikov.godotremote-b1LM9CewMfx3En1_NwLdHA==/oat/arm/base.vdex (org.godotengine.godot.GodotRenderer.onDrawFrame+20)
#00 0x0000000000424f89 /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1432)
#00 0x00000000000d2a14 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20)
#00 0x00000000002d9350 /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.guardedRun+2068)
#00 0x0000000000425959 /apex/com.android.runtime/lib/libart.so (MterpInvokeDirect+980)
#00 0x00000000000d2914 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_direct+20)
#00 0x00000000002d9d46 /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.run+114)
#00 0x00000000001ec405 /apex/com.android.runtime/lib/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.1734795622981118335)+192)
#00 0x00000000001f0be9 /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+124)
#00 0x0000000000418139 /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+808)
#00 0x00000000000dc5a1 /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32)
#00 0x00000000000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68)
#00 0x000000000042e5c7 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250)
#00 0x00000000000dffb7 /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+174)
#00 0x0000000000370367 /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54)
#00 0x0000000000371059 /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+304)
#00 0x00000000003a1b17 /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+978)
#00 0x0000000000099a63 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20)
#00 0x00000000000540e3 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30)
```

https://github.com/godotengine/godot/blob/8d287957f9c89d882f1126d62e894465f8d272d0/drivers/gles2/rasterizer_storage_gles2.cpp#L6488


<details>
<summary>More reports</summary>

After several crash reports, I updated the binaries so that they contain debug symbols, but I also have reports without symbols. For example, from Umidigi A3X:
```
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> com.dmitriysalnikov.godotremote <<<

backtrace:
  #00  pc 000000000007ea70  /apex/com.android.runtime/lib64/bionic/libc.so (strlen+16)
  #00  pc 00000000000bfe1c  /apex/com.android.runtime/lib64/bionic/libc.so (__vfprintf+4436)
  #00  pc 00000000000dd444  /apex/com.android.runtime/lib64/bionic/libc.so (vsnprintf+148)
  #00  pc 00000000000a8ac4  /apex/com.android.runtime/lib64/bionic/libc.so (__vsnprintf_chk+60)
  #00  pc 00000000000a2690  /vendor/lib64/egl/libGLESv2_mtk.so
  #00  pc 00000000000a2384  /vendor/lib64/egl/libGLESv2_mtk.so
  #00  pc 0000000000051d6c  /vendor/lib64/egl/libGLESv2_mtk.so
  #00  pc 0000000000052edc  /vendor/lib64/egl/libGLESv2_mtk.so
  #00  pc 0000000000041910  /vendor/lib64/egl/libGLESv2_mtk.so (glGenerateMipmap+352)
  #00  pc 0000000000078720  /vendor/lib64/egl/libGLES_meow.so
  #00  pc 00000000006ba390  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/split_config.arm64_v8a.apk!lib/arm64-v8a/libgodot_android.so (offset 0xe0000)
  #00  pc 000000000068bd7c  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/split_config.arm64_v8a.apk!lib/arm64-v8a/libgodot_android.so (offset 0xe0000)
  #00  pc 0000000000f584bc  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/split_config.arm64_v8a.apk!lib/arm64-v8a/libgodot_android.so (offset 0xe0000)
  #00  pc 000000000016e0bc  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/split_config.arm64_v8a.apk!lib/arm64-v8a/libgodot_android.so (offset 0xe0000)
  #00  pc 00000000001a30fc  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/split_config.arm64_v8a.apk!lib/arm64-v8a/libgodot_android.so (offset 0xe0000)
  #00  pc 0000000000178a3c  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/split_config.arm64_v8a.apk!lib/arm64-v8a/libgodot_android.so (offset 0xe0000) (Java_org_godotengine_godot_GodotLib_step+224)
  #00  pc 00000000000112d0  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/oat/arm64/base.odex (art_jni_trampoline+144)
  #00  pc 00000000001365b8  /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_static_stub+568)
  #00  pc 00000000001450cc  /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+276)
  #00  pc 00000000002e2698  /apex/com.android.runtime/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+384)
  #00  pc 00000000002dd724  /apex/com.android.runtime/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+900)
  #00  pc 00000000005a3030  /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+368)
  #00  pc 0000000000130994  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_static+20)
  #00  pc 000000000021fbdc  /data/app/com.dmitriysalnikov.godotremote-JHDkPBscff2rhQmNnVWWRw==/oat/arm64/base.vdex (org.godotengine.godot.GodotRenderer.onDrawFrame+20)
  #00  pc 00000000005a1f8c  /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1740)
  #00  pc 0000000000130a14  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20)
  #00  pc 00000000002d5300  /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.guardedRun+2068)
  #00  pc 00000000005a2b28  /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+1168)
  #00  pc 0000000000130914  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_direct+20)
  #00  pc 00000000002d5cf6  /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.run+114)
  #00  pc 00000000002b2fc8  /apex/com.android.runtime/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.13816097041842220810)+240)
  #00  pc 0000000000591928  /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1024)
  #00  pc 000000000013f468  /apex/com.android.runtime/lib64/libart.so (art_quick_to_interpreter_bridge+88)
  #00  pc 0000000000136334  /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548)
  #00  pc 00000000001450ac  /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+244)
  #00  pc 00000000004b09e0  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
  #00  pc 00000000004b1a90  /apex/com.android.runtime/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+416)
  #00  pc 00000000004f1fe0  /apex/com.android.runtime/lib64/libart.so (art::Thread::CreateCallback(void*)+1176)
  #00  pc 00000000000e2364  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36)
  #00  pc 0000000000083d98  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
```

Tecno POP 4 LTE:
```
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> com.dmitriysalnikov.godotremote <<<

backtrace:
  #00  pc 000000000005b99c  /apex/com.android.runtime/lib/bionic/libc.so (strlen_a15+72)
  #00  pc 000000000008d37d  /apex/com.android.runtime/lib/bionic/libc.so (__vfprintf+2984)
  #00  pc 00000000000a190b  /apex/com.android.runtime/lib/bionic/libc.so (vsnprintf+98)
  #00  pc 0000000000079939  /vendor/lib/egl/libGLESv2_mtk.so
  #00  pc 00000000000796f7  /vendor/lib/egl/libGLESv2_mtk.so
  #00  pc 000000000003d0b7  /vendor/lib/egl/libGLESv2_mtk.so
  #00  pc 000000000003dae5  /vendor/lib/egl/libGLESv2_mtk.so
  #00  pc 000000000002f48f  /vendor/lib/egl/libGLESv2_mtk.so (glGenerateMipmap+562)
  #00  pc 00000000006d62e8  /data/app/com.dmitriysalnikov.godotremote--0e0qWxtPWG4fSIVlAU7GQ==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000)
  #00  pc 000000000069a200  /data/app/com.dmitriysalnikov.godotremote--0e0qWxtPWG4fSIVlAU7GQ==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000)
  #00  pc 0000000000086abc  /data/app/com.dmitriysalnikov.godotremote--0e0qWxtPWG4fSIVlAU7GQ==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000)
  #00  pc 00000000000c6d9c  /data/app/com.dmitriysalnikov.godotremote--0e0qWxtPWG4fSIVlAU7GQ==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000)
  #00  pc 00000000000938e0  /data/app/com.dmitriysalnikov.godotremote--0e0qWxtPWG4fSIVlAU7GQ==/split_config.armeabi_v7a.apk!lib/armeabi-v7a/libgodot_android.so (offset 0x89000) (Java_org_godotengine_godot_GodotLib_step+276)
  #00  pc 00000000000111bf  /data/app/com.dmitriysalnikov.godotremote--0e0qWxtPWG4fSIVlAU7GQ==/oat/arm/base.odex (art_jni_trampoline+94)
  #00  pc 00000000000d7bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68)
  #00  pc 000000000042e4ab  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+246)
  #00  pc 00000000000dffcb  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+194)
  #00  pc 0000000000210a09  /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+280)
  #00  pc 000000000020c34b  /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+774)
  #00  pc 0000000000425bc7  /apex/com.android.runtime/lib/libart.so (MterpInvokeStatic+310)
  #00  pc 00000000000d2994  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static+20)
  #00  pc 000000000021fbdc  /data/app/com.dmitriysalnikov.godotremote--0e0qWxtPWG4fSIVlAU7GQ==/oat/arm/base.vdex (org.godotengine.godot.GodotRenderer.onDrawFrame+20)
  #00  pc 0000000000424d59  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1432)
  #00  pc 00000000000d2a14  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20)
  #00  pc 00000000002cbab8  /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.guardedRun+1920)
  #00  pc 0000000000425729  /apex/com.android.runtime/lib/libart.so (MterpInvokeDirect+980)
  #00  pc 00000000000d2914  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_direct+20)
  #00  pc 00000000002cc346  /system/framework/framework.jar (android.opengl.GLSurfaceView$GLThread.run+114)
  #00  pc 00000000001ec285  /apex/com.android.runtime/lib/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.llvm.1734795622981118335)+192)
  #00  pc 00000000001f0a69  /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+124)
  #00  pc 0000000000417f09  /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+808)
  #00  pc 00000000000dc5a1  /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32)
  #00  pc 00000000000d7bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68)
  #00  pc 000000000042e397  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250)
  #00  pc 00000000000dffb7  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+174)
  #00  pc 0000000000370137  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54)
  #00  pc 0000000000370e29  /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+304)
  #00  pc 00000000003a18e7  /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+978)
  #00  pc 00000000000a6093  /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20)
  #00  pc 0000000000060763  /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30)
```

</details>

### Steps to reproduce

I do not know how to reproduce it. None of my devices are affected by this crash.
But you can try to download and run the app: https://play.google.com/store/apps/details?id=com.dmitriysalnikov.godotremote (all PowerVR GE8*** are blocked for now) or https://dmitriysalnikov.itch.io/godot-remote

### Minimal reproduction project

_No response_