processing / processing-android

Processing mode and core library to create Android apps with Processing
http://android.processing.org
782 stars 293 forks source link

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

Closed rich-gg closed 6 years ago

rich-gg commented 7 years ago

Not 100% sure I am right to post this here but, you tell me

Running my sketch on Android Studio, everything runs fine but, if I switch out of the app, by hitting the Android home button or the menu button (aka going onPause) and then coming back to my app (onResume), i get E/libEGL: call to OpenGL ES API with no current context (logged once per thread) and my rendering gets jammed up, like the BlendMode going wrong or something

for the record, my sketch uses android:hardwareAccelerated="true" android:largeHeap="true"

codeanticode commented 7 years ago

Does this happen when you run your OpenGL sketches from the PDE as well?

rich-gg commented 7 years ago

I could not tell

I almost never use the PDE for Processing Android.

rich-gg commented 7 years ago

it also does it when I ran other apps, then "clear" my app selector, then launch my app

I then get this message: W/InputMethodManager: InputMethodSession is not set properly for processing.opengl.PSurfaceGLES$SurfaceViewGLES{c384448 VFE...... .F...... 0,0-1920,1200}, so force new focus to establish. E/libEGL: call to OpenGL ES API with no current context (logged once per thread)

so only then do I get this "_W/InputMethodManager: InputMethodSession..." line

codeanticode commented 7 years ago

Thanks for the additional info, I will look into this as soon as I can.

rich-gg commented 7 years ago

just looking around here but, could this lead to

 // Tells the default EGLContextFactory and EGLConfigChooser to create an GLES2 context.
      setEGLContextClientVersion(2);
      setPreserveEGLContextOnPause(true);

in https://github.com/processing/processing- android/blob/master/core/src/processing/opengl/PSurfaceGLES.java

?

rich-gg commented 7 years ago

Getting further into the issue, here is what I found:

I start and brand new project in Android Studio using this tutorial: http://android.processing.org/tutorials/android_studio/index.html

the sample code start like this

    public void settings() {
        size(600, 600);
    }

and it works fine

now if I just had "P3D" like so

    public void settings() {
        size(600, 600, P3D);
    }

then I get the E/libEGL: call to OpenGL ES API with no current context (logged once per thread) bug described above

The good thing is, it's not my code that break the thing ^^

codeanticode commented 7 years ago

@rich-gg ok thanks for the tests! Yes, I think this makes clear that the problem lies in the OpenGL renderer. I've been caught up with other work lately, but will look into this asap.

rich-gg commented 7 years ago

All the test I was doing on this problem was on a Nvidia Shield K1 with Android 7.0

I tried the same thing on Nexus 5X with Android 8.0.0 and I get the same E/libEGL: call to OpenGL ES API with no current context (logged once per thread) bug

but, I also get E/BpSurfaceComposerClient: Failed to transact (-1) E/BpSurfaceComposerClient: Failed to transact (-1) on both regular rendering and P3D might be absolutely not related but you never know :)

rich-gg commented 6 years ago

Hi @codeanticode any progress on this side ? My project is kind of done except for this bug. If there is something I can do to help, just point me in the right direction :)

codeanticode commented 6 years ago

Hi, I can reproduce this error error. It didn't come to my attention before because it does not seem to be associated with any visual artifacts, at least in my tests, but will see if it can be avoided.

codeanticode commented 6 years ago

@rich-gg In fact, I cannot reproduce this error consistently. It happens sometimes, and not others times. In no case I observed glitches after switching out from and back into the app. Do you have a simple code snippet that leads to the blend-like errors?

rich-gg commented 6 years ago

Hi

here is and debug unsigned apk of my app http://rich.gg/fuzo/fuzoUnsigned.apk

and here is a video capture of the graphical problem http://rich.gg/fuzo/fuzoBugOGLcut.mp4

I have another P3D app where you don't see a problem. With Fuzo, the thing may be related with the fact that my app runs a P3D scene inside a "PMatrix3D baseMatrix;" in order for me to develop the 2D interface in 2D and have the 3D scene behind

You can see that, pausing the app by going to the android menu, when I come back I get the error message AND :

if I can help, just ask :)

codeanticode commented 6 years ago

After installing you app on my device, what I see is that the sketch just restarts when switching back into the app. This is probably not a desirable behavior in general, and particularly on large apps with complex states. How did you manage to not restart?

rich-gg commented 6 years ago

I don't know ! With me the app doesn't restarts when I leave it and come back Nvidia Shield K1 + Android 7.0 here

Do you get the color changes when coming back to my app ?

ps: it looks like I don"t receive GITHUB notifications, ergo my delayed response :O

rich-gg commented 6 years ago
rich-gg commented 6 years ago

@codeanticode Was device / OS did you get that restarting behavior thing ? Here with Nexus 5X (Oreo) and Shield K1 (Nougat) it doesn't

So I ran the app on a Nexus 5X and, in addition to the E/libEGL: call to OpenGL ES API with no current context (logged once per thread) error, I get 2 E/BpSurfaceComposerClient: Failed to transact (-1)

I noticed that, once the rendering is jammed (white lines etc...), if I go in and out of the app, I don't get the E/libEGL: call to OpenGL ES API with no current context (logged once per thread) error anymore

codeanticode commented 6 years ago

Hey, I'm on it right now. Hopefully will have an update soon. I'm testing on a few different devices, but mainly on a N5X with Oreo. I will test on a few others as well.

codeanticode commented 6 years ago

@rich-gg thanks for sharing the code of your app, it was really useful to figure out this issue. As it turns out, the problem was caused by the getStyle/style() calls when pausing/resuming the sketch, as they were interfering with the blend modes in the UI. Saving/restoring the sketch style is not needed, the value of the style variables in PApplet is not lost when pausing the sketch (although saving the contents of the surface view is needed). Commit https://github.com/processing/processing-android/commit/62bfa775f9762ba98a12bd405127913398e3d420 fixes the issue.

rich-gg commented 6 years ago

Wow it is just like the light at at the end of the tunnel :D

thank you thank you thank you

codeanticode commented 6 years ago

You are welcome. Again, your project code was key to finding the fix.

I will try to push the 4.0.1 bugfix release of the mode as soon as possible, still need to work on some SDK installation/update issues.

codeanticode commented 6 years ago

@rich-gg The new version of the mode is not yet available on the CM, but you can download the core library from JCentral: https://bintray.com/p5android/processing-android/processing-core

rich-gg commented 6 years ago

Thanks you but I have no idea how to use this .pom thing :( not anymore than I can use the processing-core.zip from the release

using this tip

First, set up the repository where it can find the dependency.

repositories {
    maven {
        url  "https://dl.bintray.com/p5android/processing-android" 
    }
}

and then add the dependency itself by adding this line to your dependencies block:

compile 'org.p5android:processing-core:4.0.1'

but then I get an error telling me to add <meta-data tools:replace="android:value" />

to the manifest, and when I do I get

> Manifest merger failed with multiple errors, see logs...

any tip to a tutorial on this ? I'll be happy to learn or just the processing-core.jar file, even better

codeanticode commented 6 years ago

maybe you are using some other libraries that have incompatible versions with what processing-core' dependencies... looks like it may be a tricker issue (#434) but for the time being you can just keep using the zip from the mode. The contents are exactly the same.

rich-gg commented 6 years ago

the Android Studio Tutorial says "Copy android-core.jar to /app/libs"

but doesn't say where to get the android-core.jar file

Wouldn't it be better if it provided a link to the file or a way to make it ?

I know that for me, it would help :)

spaul13 commented 6 years ago

Hi @rich-gg and @codeanticode , I am going through your queries and comments, Right now I am using the ijkplayer (https://github.com/Bilibili/ijkplayer) to decode the video along with the EasyMovieTexture native plugin for Unity game engine to stream the video.

Previously I once used the game apk on Google PIXEL XL, it works fine. But now I am trying to make it working on Nexus 6P and every time I am getting,

Why it was working on Google PIXEL XL but not on Nexus 6P (both are using Nougat)

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

Also getting few errors from the OMX layer _01-30 09:29:10.259 2726-5635/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.storeANWBufferInMetadata not implemented 01-30 09:29:10.265 2726-2814/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeColorAspects not implemented 01-30 09:29:10.265 2726-5635/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeHDRStaticInfo not implemented 01-30 09:29:10.618 2726-5250/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.storeANWBufferInMetadata not implemented 01-30 09:29:10.624 2726-5756/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeColorAspects not implemented 01-30 09:29:10.624 2726-5250/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeHDRStaticInfo not implemented AudioPluginOculusSpatializer, libaudiopluginVRunity, libAudioPluginOculusSpatializer 01-30 09:31:36.372 2726-10397/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.storeANWBufferInMetadata not implemented 01-30 09:31:36.378 2726-5756/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeColorAspects not implemented 01-30 09:31:36.379 2726-6080/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeHDRStaticInfo not implemented 01-30 09:32:50.483 27830-27920/? E/jni: CreateFBO 4096 2048 68 01-30 09:32:50.484 27830-27920/? E/Unity: OPENGL NATIVE PLUG-IN ERROR: GL_INVALID_OPERATION: Operation illegal in current state 01-30 09:32:50.512 2726-5756/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.storeANWBufferInMetadata not implemented 01-30 09:32:50.524 2726-5757/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeColorAspects not implemented 01-30 09:32:50.524 2726-5250/? E/OMX-VDEC-1080P: Extension: OMX.google.android.index.describeHDRStaticInfo not implemented 01-30 09:32:50.629 2726-28445/? E/OMX-VDEC-1080P: Failed to call stream on OUTPUT due to HW_OVERLOAD 01-30 09:32:50.629 2726-28445/? E/OMX-VDEC-1080P: empty_this_buffer_proxy failure due to HW overload 01-30 09:32:50.629 2726-28445/? E/OMX-VDEC-1080P: ERROR: Sending OMXErrorInsufficientResources to Client 01-30 09:32:50.631 2726-28445/? E/OMX-VDEC-1080P: Failed to qbuf to driver 01-30 09:32:50.668 2729-28439/? E/ACodec: [OMX.qcom.video.decoder.avc] ERROR(0x80001000) 01-30 09:32:50.668 2729-28439/? E/ACodec: signalError(omxError 0x80001000, internalError -2147483648) 01-30 09:32:50.668 2729-28438/? E/MediaCodec: Codec reported err 0x80001000, actionCode 0, while in state 6 01-30 09:32:50.669 2729-28437/? E/NuPlayerDecoder: Decoder (video) reported error : 0x80001000 01-30 09:32:50.669 2729-28429/? E/NuPlayer: received error(0x80001000) from video decoder, flushing(0), now shutting down 01-30 09:32:50.669 27830-27842/? E/MediaPlayer: error (1, -2147479552) 01-30 09:32:50.669 27830-27830/? E/MediaPlayer: Error (1,-2147479552) 01-30 09:32:50.672 2729-28437/? E/NuPlayerDecoder: failed to flush OMX.qcom.video.decoder.avc (err=-38)

How can I resolve this issue? Please ask me for anything you want to resolve this issue?

Any help will highly be appreciated.

rich-gg commented 6 years ago

did you try the 4.0.1 version of processing core ? it did fix my issue :)

I realize your question doesn't say you are using Processing Android . ooops

spaul13 commented 6 years ago

This is my Gradle project settings. can you tell me where I have to include the processing core version?

screenshot 11

spaul13 commented 6 years ago

But although it doesn't include processing the android. Can u tell me where I am probably wrong? (N.B. I have a project version there in gradle.xml)

What might be faulty? Feel free to ask for anything or tell me to share anything if required.

rich-gg commented 6 years ago

@spaul13 this place deals with Processing Android questions. So I'm afraid you won't find your answers there