- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 11.3k
 
backends/opengl3: Always validate texture before uploading data #9043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
* The key addition is checking glIsTexture() before attempting to update. * This will prevent a crash in android platforms using opengl3 by catching invalid texture handles before they reach the driver, and will automatically trigger texture recreation if needed. Signed-off-by: 0xA11CE613 <[email protected]>
          
 This is a XY Problem. As you pointed this is the root cause so let’s focus on the root cause only, not on a workaround. This should not happen, if it does please elaborate this and provide a proper repro or proof of any kind of help to figure out the reason. Next week I’ll add IM_ASSERT(glIsTexture()) calls to see if I can repro this locally, but I see no reason for this happening otherwise other backends would have crashed earlier.  | 
    
| 
           I was using dear imgui till the commit 201899b611c34d35e6e38778abab91d76b0451c0 that is 2025-06-04: OpenGL: Made GLES 3.20 contexts not access GL_CONTEXT_PROFILE_MASK nor GL_PRIMITIVE_RESTART. (#8664) After merging latest changes that crash was occuring regularly and i noticed there is a commit Using my patch , it made my lib work randomly. It is a texture-related problem but honestly I dont know what is happening may be its driver issue or god knows. I have reverted back to 201899b  | 
    
| 
           Use Style Editor>Scale sliders to scale fonts and trigger textures update if you need to trigger the issue.  | 
    
| 
           I am using imgui inside a hooked eglswapbuffers Drawing occurs before the surface updates  | 
    
| 
           Well please first try to confirm if this happens with unmodified ImGui example + narrow down to precise commit using bisect.  | 
    
| 
           I added a check in local code and could not detect any issue when resizing: IM_ASSERT(glIsTexture((GLuint)(intptr_t)pcmd->GetTexID())
GL_CALL(glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()));The issue is on your side and you should investigate why you have a draw call with invalid texture id, it seems like textures may be modified or destroyed? If you need to run with a hack like the one you made in this PR, you can perfectly preprocess the texture list yourself without making any change to the OpenGL3 backend, and apply the same code on your side. But there's no reason to add it to official backend right now, it seems like a workaround to hide a more important bug. I am also afraid that moving the  If you want to help: 
  | 
    
CHIPSET: QUALCOMM
PLATFORM: ANDROID 15 (Qualcomm Adreno)
COMPILER: NDK Version 28.2.13676358
ISSUE: SIGSEGV crash in Adreno GPU driver during glTexSubImage2D operations
PROBLEM:
The current ImGui_ImplOpenGL3_UpdateTexture function attempts texture operations without validating if the OpenGL texture handle is still valid, causing crashes in the Adreno driver when processing destroyed or invalid textures.
ROOT CAUSE:
SOLUTIONS: