# Android glBindTexture crashing in offline trace

**URL:** <https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065>\
**Category:** PowerVR Insider\
**Tags:** pvrtrace, pvrhub\
**Created:** [May 8, 2014, 5:30pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065 "2014-05-08T17:30:40Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mercutiogeek-2](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mercutiogeek-2](https://forums.imgtec.com/u/mercutiogeek-2)\
**Post date:** [May 8, 2014, 5:30pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/1 "2014-05-08T17:30:40Z")

</div>

I’m trying to get traces working in my android app. Currently the first call to glBindTexture is crashing with the following callstack

````auto
 	libPVRTrace.so!CEs2ContextState::SetBoundTexture(unsigned int, unsigned int)()	C/C++<br />
libPVRTrace.so!Es2::_glBindTexture(unsigned int, unsigned int)()	C/C++<br />
libGLESv2_PVRTRACE.so!glBindTexture()	C/C++<br />
>	load_texture()	C/C++<br />
load_png_asset_into_texture()	C/C++<br />
LoadTextureInternal()	C/C++<br />
Render::LoadTexture()	C/C++<br />
BMFLoader::LoadTexture()	C/C++<br />
BaseModel::LoadModel()	C/C++<br />
OrbModel::Init()	C/C++<br />
OrbModel::OrbModel()	C/C++<br />
GMRenderTest::Update()	C/C++<br />
Java_com_novasapiens_Bacchus_BacchusView_GameLoopStep()	C/C++<br />
0x4179ba54	C/C++<br />
0x4179ba54	C/C++
```<br />
<br />
The call succeeds if I delete the profile settings file /data/data/com.powervr.PVRHub/pvrtraceconfig.json<br />
<br />
This is the code that is running:<br />
<code>	GLuint texture_object_id;<br />
glGenTextures(1, &texture_object_id);<br />
assert(texture_object_id != 0);<br />
<br />
glBindTexture(GL_TEXTURE_2D, texture_object_id);<br />
<br />
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);<br />
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);<br />
glTexImage2D(<br />
GL_TEXTURE_2D, 0, type, width, height, 0, type, GL_UNSIGNED_BYTE, pixels);<br />
glGenerateMipmap(GL_TEXTURE_2D);<br />
<br />
glBindTexture(GL_TEXTURE_2D, 0);<br />
return texture_object_id;<br />
</code><br />
The glGenTextures succeeds and I have a valid texture handle to bind to. I tried moving the glTexParameters up to before the glBindTexture and they still succeeded. It seems to specifically be an issue with glBindTexture.<br />
<br />
Any assistance would be appreciated.
````

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [May 9, 2014, 8:01am UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/2 "2014-05-09T08:01:18Z")

</div>

Hi,  
  
  
  
If you can share the following information with us, it will help us investigate the issue.

  
1. Which version of the PVRTrace recorder libraries are you using?  
2. What version of Android are you recording your application on?
  
3. What graphics API are you using?
  
4. What happens if you call glGetError() after each call?
  
5. Can you share your pvrtraceconfig.json with us?
  
6. Do you also have a pvrtrace.cfg in the same location? The recorder will search for the new style config first (pvrtraceconfig.json), but will fall back to pvrtrace.cfg. This could explain why the behaviour changes when your pvrtraceconfig.json is deleted
  

  
  
Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![mercutiogeek-2](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mercutiogeek-2](https://forums.imgtec.com/u/mercutiogeek-2)\
**Post date:** [May 9, 2014, 11:49am UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/3 "2014-05-09T11:49:10Z")

</div>

Hi Joe 🙂

1. Recorder Version: 3.3@2850432  
2. Android version 4.4.2, cyanogen image running on a Galaxy S (GT-I9000)  
3. OpenGL ES 2.0  
4. glError returns GL\_NO\_ERROR on all calls previous to the glBindTexture  
5. contents of /data/data/com.powervr.PVRHub/pvrtraceconfig.json  
  
`
{
“Tracing”: {
“OutputFilename”: “/data/data/com.powervr.PVRHub/recordings/%pname.pvrt”,
“RecordData”: true,
“OptimiseFileSize”: false,
“StartFrame”: 0,
“EndFrame”: 9999,
“ExitOnLastFrame”: true,
“ClientBufferRecordFrequency”: 1,
“SaveFrameBuffer”: false
},
“Debug”: {
“Level”: 1
},
“Network”: {
“Wait”: true,
“Enabled”: false,
“BufferSize”: 256
},
“Host”: {
“Es2LibraryPath”: “”,
“Es1LibraryPath”: “”,
“EglLibraryPath”: “”,
“Es3LibraryPath”: “”
},
“Process”: {
“Exclude”: [
“com.powervr.PVRHub”,
"/system/bin/bootanimation",
"/system/bin/surfaceflinger",
“com.android.systemui”,
“com.android.settings”,
“system_server”,
“com.google.android.googlequicksearchbox”
]
},
“Profiling”: {
“SoftwareCounters”: true,
“FunctionTimelineLevel”: 1,
“Enabled”: false,
“RenderstateOverride”: true
}
}
`  
6. There isn’t a pvrtrace.cfg in the /data/data/com.powervr.PVRHub/ directory nor in my app directory.  
  
  
  
Bonus info, full LogCat output up to the crash:  
  
`05-09 10:22:09.278 8990 8990 Zygote Switching descriptor 33 to /dev/null
05-09 10:22:09.282 8990 8990 Zygote Switching descriptor 9 to /dev/null
05-09 10:22:09.317 8990 8990 dalvikvm Late-enabling CheckJNI
05-09 10:22:09.368 8990 8990 dalvikvm Enabling JNI app bug workarounds for target SDK version 4…
05-09 10:22:09.899 8990 8990 ActivityThread Application com.novasapiens.Bacchus is waiting for the debugger on port 8100…
05-09 10:22:09.907 8990 8990 System.out Sending WAIT chunk
05-09 10:22:12.024 8990 8996 dalvikvm Debugger is active
05-09 10:22:12.176 8990 8990 System.out Debugger has connected
05-09 10:22:12.188 8990 8990 System.out waiting for debugger to settle…
05-09 10:22:12.395 8990 8990 System.out waiting for debugger to settle…
05-09 10:22:12.598 8990 8990 System.out waiting for debugger to settle…
05-09 10:22:12.798 8990 8990 System.out waiting for debugger to settle…
05-09 10:22:13.001 8990 8990 System.out waiting for debugger to settle…
05-09 10:22:13.102 8990 8996 dalvikvm Debugger has detached; object registry had 25 entries
05-09 10:22:13.200 8990 8990 jdwp dvmJdwpLastDebuggerActivity: no active debugger
05-09 10:22:13.200 8990 8990 System.out debugger detached?
05-09 10:22:13.243 8990 8990 dalvikvm Trying to load lib /data/app-lib/com.novasapiens.Bacchus-1/libPVRTrace.so 0x41ad65a8
05-09 10:22:13.508 8990 8990 dalvikvm Added shared lib /data/app-lib/com.novasapiens.Bacchus-1/libPVRTrace.so 0x41ad65a8
05-09 10:22:13.508 8990 8990 dalvikvm No JNI_OnLoad found in /data/app-lib/com.novasapiens.Bacchus-1/libPVRTrace.so 0x41ad65a8, skipping init
05-09 10:22:13.508 8990 8990 dalvikvm Trying to load lib /data/app-lib/com.novasapiens.Bacchus-1/libEGL_PVRTRACE.so 0x41ad65a8
05-09 10:22:13.708 8990 8990 dalvikvm Added shared lib /data/app-lib/com.novasapiens.Bacchus-1/libEGL_PVRTRACE.so 0x41ad65a8
05-09 10:22:13.708 8990 8990 dalvikvm No JNI_OnLoad found in /data/app-lib/com.novasapiens.Bacchus-1/libEGL_PVRTRACE.so 0x41ad65a8, skipping init
05-09 10:22:13.708 8990 8990 dalvikvm Trying to load lib /data/app-lib/com.novasapiens.Bacchus-1/libGLESv2_PVRTRACE.so 0x41ad65a8
05-09 10:22:13.938 8990 8990 dalvikvm Added shared lib /data/app-lib/com.novasapiens.Bacchus-1/libGLESv2_PVRTRACE.so 0x41ad65a8
05-09 10:22:13.938 8990 8990 dalvikvm No JNI_OnLoad found in /data/app-lib/com.novasapiens.Bacchus-1/libGLESv2_PVRTRACE.so 0x41ad65a8, skipping init
05-09 10:22:13.938 8990 8990 dalvikvm Trying to load lib /data/app-lib/com.novasapiens.Bacchus-1/libbacchus.so 0x41ad65a8
05-09 10:22:14.274 8990 8990 dalvikvm Added shared lib /data/app-lib/com.novasapiens.Bacchus-1/libbacchus.so 0x41ad65a8
05-09 10:22:14.274 8990 8990 dalvikvm No JNI_OnLoad found in /data/app-lib/com.novasapiens.Bacchus-1/libbacchus.so 0x41ad65a8, skipping init
05-09 10:22:14.934 8990 9078 BacchusView creating OpenGL ES 2.0 context
05-09 10:22:14.993 8990 8990 ActivityManager Timeline: Activity_idle id: android.os.BinderProxy@41ad27b0 time:152561745
05-09 10:22:15.001 8990 9078 PVRTrace(I) Config file found: /data/data/com.powervr.PVRHub/pvrtraceconfig.json
05-09 10:22:15.005 8990 9078 PVRTrace(I) Setting the default host paths to the Android shim as PVRTrace appears to be compiled in
05-09 10:22:15.005 8990 9078 PVRTrace Setting EglLibraryPath default to ‘/system/lib/libEGL.so’.
05-09 10:22:15.005 8990 9078 PVRTrace Setting Es1LibraryPath default to ‘/system/lib/libGLESv1_CM.so’.
05-09 10:22:15.005 8990 9078 PVRTrace Setting Es2LibraryPath default to ‘/system/lib/libGLESv2.so’.
05-09 10:22:15.005 8990 9078 PVRTrace(I) Processes excluded from recording: com.powervr.PVRHub
05-09 10:22:15.005 8990 9078 PVRTrace(I) Opening trace file ‘/data/data/com.powervr.PVRHub/recordings/com.novasapiens.Bacchus.pvrt’ for record recording.
05-09 10:22:15.008 8990 9078 PVRTrace(I) ‘/data/data/com.powervr.PVRHub/recordings/com.novasapiens.Bacchus.pvrt’ already exists so will be overwritten.
05-09 10:22:15.012 8990 9078 PVRTrace(I) Recorder Version: 3.3@2850432
05-09 10:22:15.012 8990 9078 PVRTrace(I) Loading host library '/system/lib/libGLESv2.so’
05-09 10:22:15.012 8990 9078 PVRTrace(I) Host library ‘/system/lib/libGLESv2.so’ loaded
05-09 10:22:15.020 8990 9078 android-main GL Version = OpenGL ES 2.0 build 1.8.GOOGLENEXUS.ED945322@2112805
05-09 10:22:15.020 8990 9078 android-main GL Vendor = Imagination Technologies
05-09 10:22:15.020 8990 9078 android-main GL Renderer = PowerVR SGX 540 + PVRTrace 3.3 (3.3@2850432)
05-09 10:22:15.020 8990 9078 android-main GL Extensions = GL_EXT_debug_marker GL_OES_rgb8_rgba8 GL_OES_depth24 GL_OES_vertex_half_float GL_OES_texture_float GL_OES_texture_half_float GL_OES_element_index_uint GL_OES_mapbuffer GL_OES_fragment_precision_high GL_OES_compressed_ETC1_RGB8_texture GL_O
`  
  
And here is the contents of the .pvrt up to the crash  
  
`NoCalls:16
NoFrames:1

Writing to file:

Frame:1/1`

* * *
ES2 glGetString(GL\_VERSION) ==\> OpenGL ES 2.0 build 1.8.GOOGLENEXUS.ED945322@2112805 Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR  
ES2 glGetString(GL\_VENDOR) ==\> Imagination Technologies Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR  
ES2 glGetString(GL\_RENDERER) ==\> PowerVR SGX 540 + PVRTrace 3.3 (3.3@2850432) Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR  
ES2 glGetString(GL\_EXTENSIONS) ==\> GL\_EXT\_debug\_marker GL\_OES\_rgb8\_rgba8 GL\_OES\_depth24 GL\_OES\_vertex\_half\_float GL\_OES\_texture\_float GL\_OES\_texture\_half\_float GL\_OES\_element\_index\_uint GL\_OES\_mapbuffer GL\_OES\_fragment\_precision\_high GL\_OES\_compressed\_ETC1\_RGB8\_texture GL\_OES\_EGL\_image GL\_OES\_EGL\_image\_external GL\_OES\_required\_internalformat GL\_OES\_depth\_texture GL\_OES\_get\_program\_binary GL\_OES\_packed\_depth\_stencil GL\_OES\_standard\_derivatives GL\_OES\_vertex\_array\_object GL\_OES\_egl\_sync GL\_EXT\_multi\_draw\_arrays GL\_EXT\_texture\_format\_BGRA8888 GL\_EXT\_discard\_framebuffer GL\_EXT\_shader\_texture\_lod GL\_IMG\_shader\_binary GL\_IMG\_texture\_compression\_pvrtc GL\_IMG\_texture\_npot GL\_IMG\_texture\_format\_BGRA8888 GL\_IMG\_read\_format GL\_IMG\_program\_binary GL\_IMG\_multisampled\_render\_to\_texture Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR  
ES2 glClearColor(1.000000,0.410000,0.710000,1.000000) Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR  
ES2 glClear(GL\_DEPTH\_BUFFER\_BIT | GL\_COLOR\_BUFFER\_BIT) Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR  
ES2 glViewport(0,0,800,480) Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR  
ES2 glGenTextures(1,70001) Error: GL\_NO\_ERROR  
ES2 glGetError() ==\> GL\_NO\_ERROR Error: GL\_NO\_ERROR

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [May 9, 2014, 12:00pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/4 "2014-05-09T12:00:07Z")

</div>

Hi,  
  
  
  
Thanks for the information. We have some follow up questions:

  
1. Are you using PVRHub to install the recorder libraries, or have you compiled them into your APK?
  
2. We can't see any EGL calls in your logs. Have you removed them?
  
3. Are you calling EGL from native, or from Java? There's a known limitation where we cannot record EGL calls from Java if the recorder libraries are built into your APK
  

  
  
Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![mercutiogeek-2](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mercutiogeek-2](https://forums.imgtec.com/u/mercutiogeek-2)\
**Post date:** [May 9, 2014, 12:11pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/5 "2014-05-09T12:11:27Z")

</div>

1. Compiled in to my APK. Somewhat related note, I wasn’t able to install the libs with PVRHub, my device is rooted and normally when an application requests root access I get a popup to confirm authorization but I don’t get one for PVRHub. PVRHub simply informs me it couldn’t get root access and I didn’t find a way to grant authorization without the app first making the request.  
  
2/3. The only EGL calls in the project are in Java, no particular reason, that’s just how the sample project I built off of worked.

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [May 9, 2014, 12:21pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/6 "2014-05-09T12:21:37Z")

</div>

Are you running SuperSU or a similar application on your device? PVRHub should cause a dialog to popup and confirm that you’re allowing the app to have root access. If this isn’t working, you should be able to configure application permissions within SuperSU. As an alternative, you can launch the PVRHubDaemon from a root terminal to enable PVRHub to execute commands as root. Here’s an ADB command for this:  
  
`adb shell su -c ‘/data/data/com.powervr.PVRHub/bin/PVRHubDaemon’&`  
  
  
  
As you’re using EGL through Java, you will have to use PVRHub to install the recorder libraries to the system. Alternatively, you can modify your application to issue all EGL calls from native, which will allow the APK recorder library packaging approach to work.  
  
  
  
Cheers,  
  
Joe

---

<div class="post-metadata">

**Author:** ![mercutiogeek-2](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mercutiogeek-2](https://forums.imgtec.com/u/mercutiogeek-2)\
**Post date:** [May 9, 2014, 12:46pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/7 "2014-05-09T12:46:23Z")

</div>

Cyanogenmod uses an app called Superuser, it is supposed to work as you described where when I run PVRHub I get a popup to confirm root access. A little research indicated that SuperSU will play nice with cyanogenmod so I installed that but same results, when I ran PVRHub I didn’t get a popup requesting access. I then tried running the Daemon and that worked (I had tried running it previously from the adb shell without success but that is likely due to my unfamiliarity with adb/linux). With the Daemon running PVRHub was able to install the libs and that seems to have solved my issue. My app now runs and it looks like I’m getting full trace logs 🙂  
  
  
  
Thanks for your help Joe!

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [May 9, 2014, 12:55pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/8 "2014-05-09T12:55:03Z")

</div>

No problem. Glad to hear the issue is solved 🙂  
  
  
  
Joe

---

<div class="post-metadata">

**Author:** ![mercutiogeek-2](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mercutiogeek-2](https://forums.imgtec.com/u/mercutiogeek-2)\
**Post date:** [May 9, 2014, 12:58pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/9 "2014-05-09T12:58:12Z")

</div>

Dear god. Now that the libs are installed the phone has become basically unusable. Is that normal? How do I uninstall the libs?

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [May 9, 2014, 1:23pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/10 "2014-05-09T13:23:01Z")

</div>

If the entire system feels sluggish, it may be the case that the recorder libraries are capturing every process (the splash screen, launcher etc.). On KitKat devices, this suggests that the config’s Exclude list is empty or missing system processes.  
  
  
  
You can restore your device using PVRHubDaemon with this command:  
  
`adb shell su -c ‘/data/data/com.powervr.PVRHub/bin/PVRHubDaemon -r’`

---

<div class="post-metadata">

**Author:** ![mercutiogeek-2](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mercutiogeek-2](https://forums.imgtec.com/u/mercutiogeek-2)\
**Post date:** [May 9, 2014, 2:31pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/11 "2014-05-09T14:31:24Z")

</div>

Thanks Joe, it was an issue with the exclusion list.

---

<div class="post-metadata">

**Author:** ![mercutiogeek-2](https://avatars.discourse-cdn.com/v4/letter/m/e36b37/32.png) [@mercutiogeek-2](https://forums.imgtec.com/u/mercutiogeek-2)\
**Post date:** [May 9, 2014, 5:27pm UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/12 "2014-05-09T17:27:31Z")

</div>

Just when I thought I was good…  
  
  
  
I ran PVRHubDaemon -r to restore my device. It failed because it couldn’t find a .so. I then tried reinstalling the libs with PVRHub and now the phone is in an infinite boot cycle. Is there a way to manually restore the phone short of wiping it?

---

<div class="post-metadata">

**Author:** ![JoeDavis](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.imgtec.com/joedavis/32/71_2.png) [@JoeDavis](https://forums.imgtec.com/u/JoeDavis)\
**Post date:** [May 12, 2014, 5:50am UTC](https://forums.imgtec.com/t/android-glbindtexture-crashing-in-offline-trace/2065/13 "2014-05-12T05:50:16Z")

</div>

Did you run PVRHubDaemon from a root terminal session, or use the command I mentioned before to execute as root on the target with adb?  
  
  
  
Appendix A of the PVRHub manual explains how the daemon works, what options are available and how it modifies the file system. As discussed there, you can execute the daemon with the ‘-g’ flag to generate a report of the system status.  
  
`adb shell su -c '/data/data/com.powervr.PVRHub/bin/PVRHubDaemon -g’`  
  
If you can send us this report (either through the forum or as [a support ticket](https://pvrsupport.imgtec.com/new-ticket)), we can help you investigate the cause of the problem. It may be the case that the Cyanogen file system is for some reason different than vanilla Android builds we’ve tested.
