Call to OpenGL ES API with no current context

cancel
Showing results for 
Search instead for 
Did you mean: 

Call to OpenGL ES API with no current context

Jump to solution
2,421 Views
matthewdavis
Contributor III

I'm trying to use a custom shader in the camera HAL to process images as they come off of the camera in libcamera2, but I'm running into a problem when I try to initialize the library.  When I call eglGetDisplay(), it returns successfully, but I see the following error in the log:

E/libEGL  (  154): call to OpenGL ES API with no current context (logged once per thread)

If I understand correctly, this happens when you try to make OpenGL calls without properly initializing the library or if you try to call OpenGL on a thread other than the one that opened the context.  In my case, all of the calls happen on one thread and the error happens on the first call.  Since this isn't application code (I'm in the Android framework itself), I'm wondering if there's something I need to do to properly access the GPU.

None of the OpenGL calls returns an error until I try to read the pixels back with glReadPixels like this:

glReadPixels(0,0, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, outRGB);

Then the library reports GL_INVALID_OPERATION.  I'm combing through the rest of the code to see if I did anything else wrong, but the context error in the logs makes me worry that the problem is related to threading / hardware access and not the GL code itself.  The OpenGL code works just fine when I run as a stand-alone process on my laptop.

Do I need to do something special to access OpenGL ES from within the Android framework?  I've seen other threads indicating that people have done it.

Labels (3)
1 Solution
643 Views
matthewdavis
Contributor III

To answer my own question:  yes, linking specifically against those libraries is the correct answer.  I don't see anything else in the Android tree that uses EGL and links against those libraries by name, but simply linking to -lEGL and -lGLESv2 causes problems.  Linking to the _VIVANTE versions compiles and runs as expected.

View solution in original post

4 Replies
643 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Matthew,

There is no anything special to access OpenGL Es with android framework on nxp bsps. However which imx android release package you are using? Which soc type you are using? Can it reproduced in our imx reference board? Please provide a detail info.

It seems you don’t include gpu library and gpu egl config into your rootfs. Typically you should have it included by default if you are using an nxp android release.

regards

643 Views
matthewdavis
Contributor III

Looking elsewhere in the Android tree, I see libGLESv2_VIVANTE.so and libEGL_VIVANTE.so in the device/fsl-proprietary/gpu-viv/lib/egl subdirectory?  Should I be explicitly linking against those libraries?  Searching through every .mk file in the project, none of them seem to use that version of the library--all of them use the generic OpenGL libraries like I am.

0 Kudos
644 Views
matthewdavis
Contributor III

To answer my own question:  yes, linking specifically against those libraries is the correct answer.  I don't see anything else in the Android tree that uses EGL and links against those libraries by name, but simply linking to -lEGL and -lGLESv2 causes problems.  Linking to the _VIVANTE versions compiles and runs as expected.

View solution in original post

643 Views
matthewdavis
Contributor III
Hello Alfred,

Thanks for the tip.  I don't have a reference platform available, so I'm afraid I can't tell you whether it works there or not.  The BSP version is imx_KK4.4.3_2.0.0-ga, but it was modified by our board vendor.  The CPU is an IMX6Q. 

My root filesystem contains both libEGL.so and libGLESv2.so, but I can't tell where they come from in the source tree.  The md5 checksum of the libraries in the built rootfs don't match the md5 checksum of any of the libraries in my source tree, so I assume they're getting stripped or something like that:

find ./ -name libEGL.so | xargs md5sum
f331bef178f132bbd61f46e45156d89b  ./prebuilts/ndk/8/platforms/android-14/arch-mips/usr/lib/libEGL.so
551b041e2c88c4cd5a3f0fb29ca2fe15  ./prebuilts/ndk/8/platforms/android-14/arch-x86/usr/lib/libEGL.so
7df93ee62fb5a943ad60dd342de2d2cc  ./prebuilts/ndk/8/platforms/android-14/arch-arm/usr/lib/libEGL.so
f331bef178f132bbd61f46e45156d89b  ./prebuilts/ndk/8/platforms/android-9/arch-mips/usr/lib/libEGL.so
551b041e2c88c4cd5a3f0fb29ca2fe15  ./prebuilts/ndk/8/platforms/android-9/arch-x86/usr/lib/libEGL.so
7df93ee62fb5a943ad60dd342de2d2cc  ./prebuilts/ndk/8/platforms/android-9/arch-arm/usr/lib/libEGL.so
abf0fbebf9a9affa7fa9d391b71d01b2  ./prebuilts/ndk/7/platforms/android-14/arch-x86/usr/lib/libEGL.so
e58ba7b38c68521010f4af7ed6d61857  ./prebuilts/ndk/7/platforms/android-14/arch-arm/usr/lib/libEGL.so
abf0fbebf9a9affa7fa9d391b71d01b2  ./prebuilts/ndk/7/platforms/android-9/arch-x86/usr/lib/libEGL.so
e58ba7b38c68521010f4af7ed6d61857  ./prebuilts/ndk/7/platforms/android-9/arch-arm/usr/lib/libEGL.so
efb196b88968176ec342d6e1b94c0df4  ./prebuilts/ndk/6/platforms/android-9/arch-x86/usr/lib/libEGL.so
88d9d351d0798a1e024f333c9f18dbc8  ./prebuilts/ndk/6/platforms/android-9/arch-arm/usr/lib/libEGL.so
189ca934b372507d7df3defb26c53836  ./prebuilts/ndk/9/platforms/android-18/arch-mips/usr/lib/libEGL.so
f6f22ae76d19fc349778d7db30bc5bd6  ./prebuilts/ndk/9/platforms/android-18/arch-x86/usr/lib/libEGL.so
e06af671e7b4e897b351a7c1f5a0ae29  ./prebuilts/ndk/9/platforms/android-18/arch-arm/usr/lib/libEGL.so
189ca934b372507d7df3defb26c53836  ./prebuilts/ndk/9/platforms/android-14/arch-mips/usr/lib/libEGL.so
f6f22ae76d19fc349778d7db30bc5bd6  ./prebuilts/ndk/9/platforms/android-14/arch-x86/usr/lib/libEGL.so
e06af671e7b4e897b351a7c1f5a0ae29  ./prebuilts/ndk/9/platforms/android-14/arch-arm/usr/lib/libEGL.so
189ca934b372507d7df3defb26c53836  ./prebuilts/ndk/9/platforms/android-9/arch-mips/usr/lib/libEGL.so
f6f22ae76d19fc349778d7db30bc5bd6  ./prebuilts/ndk/9/platforms/android-9/arch-x86/usr/lib/libEGL.so
e06af671e7b4e897b351a7c1f5a0ae29  ./prebuilts/ndk/9/platforms/android-9/arch-arm/usr/lib/libEGL.so
88d9d351d0798a1e024f333c9f18dbc8  ./prebuilts/ndk/5/platforms/android-9/arch-arm/usr/lib/libEGL.so
aa593c6811c0542a35a7a9219e7bd522  ./out/target/product/sbc_mx6_cid/symbols/system/lib/libEGL.so
4dc6132a75d08cf2f9dece7ff5bf2476  ./out/target/product/sbc_mx6_cid/system/lib/libEGL.so
aa593c6811c0542a35a7a9219e7bd522  ./out/target/product/sbc_mx6_cid/obj/SHARED_LIBRARIES/libEGL_intermediates/LINKED/libEGL.so
4dc6132a75d08cf2f9dece7ff5bf2476  ./out/target/product/sbc_mx6_cid/obj/lib/libEGL.so

The same thing is true for libGLESv2.so, so I can't be sure I have the right libraries.  The libraries do load and produce log entries in the Android log, but that doesn't mean I have the right versions in the right place.  Does this look right to you?  If not, is there a way for me to pull the libraries I need from the unmodified NXP reference BSP? 
0 Kudos