Bug 2210 - GLCube fails on ICS with egl.EglMakeCurrent failed
Summary: GLCube fails on ICS with egl.EglMakeCurrent failed
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.0
Hardware: All All
: Normal critical
Target Milestone: ---
Assignee: shana@xamarin.com
URL:
Depends on:
Blocks:
 
Reported: 2011-11-28 04:03 UTC by Jatin
Modified: 2013-05-16 05:21 UTC (History)
9 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Screenshot for the bug. (318.67 KB, image/jpeg)
2011-11-28 04:03 UTC, Jatin
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Jatin 2011-11-28 04:03:53 UTC
Created attachment 954 [details]
Screenshot for the bug.

Step to Reproduce:

1. Launch MonoDevelop.
2. Click on "Open the existing Solution" link.
3. Browse the "GLCube" application.
4. Build the application and select "Debug/Release" option under Active
Configuration.
5. Click on Run from the top menu bar and select API 14 from select device
window.
6. Application launches on emulator.

Actual Result:
When run the application on API-14, error "UNHANDLED EXCEPTION: System.InvalidOperationException displays and application getting closed from the emulator. However, on API-10 it runs successfully.

Expected Result:
Error should not occur in running the application and application should deploy
on all the emulator successfully. 

Environment:
MonoDevelop 2.8.2 with Addin 3.9.9.4
Mono for Android 4.0
Windows 7
Mac 10.6 (Snow Leopard)
Mac 10.7 (Lion)
Comment 1 Jatin 2011-11-28 04:19:02 UTC
This issue also works fine on API-7.
Comment 2 narayanp 2011-11-28 06:05:22 UTC
this issue exists on SnowLeopard also on API 14.
Comment 3 Nikita Kareev 2011-12-22 09:36:38 UTC
It's also occurs on Nexus S with Android 4.0.3:

12-22 18:25:07.867: E/SurfaceTexture(81): [SurfaceView] connect: already connected (cur=2, req=1)
12-22 18:25:07.867: E/libEGL(2326): EGLNativeWindowType 0x12e35d0 already connected to another API
12-22 18:25:07.867: E/libEGL(2326): eglCreateWindowSurface:358 error 300b (EGL_BAD_NATIVE_WINDOW)
12-22 18:25:07.875: E/libEGL(2326): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
12-22 18:25:07.875: E/libEGL(2326): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
12-22 18:25:07.902: E/SurfaceTexture(81): [SurfaceView] connect: already connected (cur=2, req=1)
12-22 18:25:07.902: E/libEGL(2326): EGLNativeWindowType 0x12e35d0 already connected to another API
12-22 18:25:07.902: E/libEGL(2326): eglCreateWindowSurface:358 error 300b (EGL_BAD_NATIVE_WINDOW)
12-22 18:25:07.902: E/libEGL(2326): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
12-22 18:25:07.902: E/libEGL(2326): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
12-22 18:25:07.918: I/MonoDroid(2326): UNHANDLED EXCEPTION: System.InvalidOperationException: egl.EglMakeCurrent failed: 0x3009
12-22 18:25:07.918: I/MonoDroid(2326): at OpenTK.Platform.Android.AndroidGraphicsContext.MakeCurrent (OpenTK.Platform.IWindowInfo) <0x00134>
12-22 18:25:07.918: I/MonoDroid(2326): at OpenTK.Platform.Utilities.CreateGraphicsContext (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,int,int,OpenTK.Graphics.GraphicsContextFlags) <0x0006f>
12-22 18:25:07.918: I/MonoDroid(2326): at OpenTK.Platform.Android.AndroidGameView.CreateFrameBuffer () <0x000b7>
12-22 18:25:07.918: I/MonoDroid(2326): at Microsoft.Xna.Framework.AndroidGameWindow.CreateFrameBuffer () <0x0003f>
12-22 18:25:07.918: I/MonoDroid(2326): at OpenTK.Platform.Android.AndroidGameView.RunIteration () <0x0016b>
12-22 18:25:07.918: I/MonoDroid(2326): at OpenTK.Platform.Android.RepeatTimerTask.Run () <0x00023>
12-22 18:25:07.918: I/MonoDroid(2326): at Java.Util.TimerTask.n_Run (intptr,intptr) <0x00033>
12-22 18:25:07.918: I/MonoDroid(2326): at (wrapper dynamic-method) object.baeddc2f-b169-4b8d-880e-dac76a26b582 (intptr,intptr) <0x0002b>
12-22 18:25:07.945: E/mono(2326): Unhandled Exception: System.InvalidOperationException: egl.EglMakeCurrent failed: 0x3009
12-22 18:25:07.945: E/mono(2326):   at OpenTK.Platform.Android.AndroidGraphicsContext.MakeCurrent (IWindowInfo window) [0x00000] in <filename unknown>:0 
12-22 18:25:07.945: E/mono(2326):   at OpenTK.Platform.Utilities.CreateGraphicsContext (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, Int32 major, Int32 minor, GraphicsContextFlags flags) [0x00000] in <filename unknown>:0 
12-22 18:25:07.945: E/mono(2326):   at OpenTK.Platform.Android.AndroidGameView.CreateFrameBuffer () [0x00000] in <filename unknown>:0 
12-22 18:25:07.945: E/mono(2326):   at Microsoft.Xna.Framework.AndroidGameWindow.CreateFrameBuffer () [0x00000] in <filename unknown>:0 
12-22 18:25:07.945: E/mono(2326):   at OpenTK.Platform.Android.AndroidGameView.RunIteration () [0x00000] in <filename unknown>:0 
12-22 18:25:07.945: E/mono(2326):   at OpenTK.Platform.Android.RepeatTimerTask.Run () [0x00000] in <filename unknown>:0 
12-22 18:25:07.945: E/mono(2326):   at Java.Util.TimerTask.n_Run (IntPtr jnienv, IntPtr native__this) [0x00000] in <filename unknown>:0 
12-22 18:25:07.945: E/mono(2326):   at (wrapper dynamic-method) object:baeddc2f-b169-4b8d-880e-dac76a26b582 (intptr,intptr)
12-22 18:25:07.964: I/ActivityManager(153): Process LuntikAndroid9.LuntikAndroid9 (pid 2326) has died.
Comment 4 Miguel de Icaza [MSFT] 2012-01-09 15:37:38 UTC
Andreia, can you evaluate the bug and the priority for this?
Comment 5 Heiko Schmitt 2012-01-10 13:22:52 UTC
We have the same issue here, preventing all our games to work on Android 4.
(Tested on Asus Transformer Prime)

It looks like there is already some surface bound to the native window,
hence egl.EglCreateWindowSurface fails.

We have overridden CreateFrameBuffer / GraphicsContext creation.
So if you find a fix, please post it here in detail :)

Thanks,
Heiko (exDream)
Comment 6 Heiko Schmitt 2012-01-11 09:03:43 UTC
Investigating show that somehow another API seems to be connected to our native window, namely: NATIVE_WINDOW_API_CPU

Now looking into preventing this connect, or just disconnecting it...
Comment 7 Andreia Gaita 2012-01-11 09:22:39 UTC
This problem occurs in ICS due to changes in the way the android opengl api reacts to certain opengl calls. Essentially, the ICS opengl layer bails out in calls that are normally not fatal in other implementations. From user code it's not possible to avoid these calls, we're working on fixing this at the library layer.
Comment 8 Heiko Schmitt 2012-01-17 12:48:48 UTC
I tried implementing my own AndroidGameView.
Removing following calls in RunIteration, just before calling CreateFrameBuffer helps a little:

Canvas canvas = Holder.LockCanvas();
if (canvas == null)
{
  Log.Debug("DeltaGameView", "Surface is invalid??");
}
Holder.UnlockCanvasAndPost(canvas);

According to nvidia those lines will bind the CPU_API, which cause the known error.

Removing those lines get me a bit further (I was able to draw a red background using GL.ClearColor and GL.Clear).

Although I am stuck with:
01-17 18:34:33.160: E/libEGL(3788): called unimplemented OpenGL ES API
error spamming now.
Altough I make sure to use an ES2 EGLConfig (RenderableType OpenglES2Bit) and pass contextversion 2 to CreateContext.

int[] attribList2 = new int[]
{
  ContextClientVersion, 2,
  EGL10.EglNone
};
EGLContext = egl.EglCreateContext(display, config, EGL10.EglNoContext, attribList2);


How is your current status on this issue?

Greetings,
Heiko
Comment 9 Andreia Gaita 2012-01-17 16:53:46 UTC
Hi,

The work is ongoing and I hope to have things done before the end of the month, preferably sooner. As soon as it's ready, we'll very likely do a preview so you can get your hands on it sooner rather than later. Sorry about the delay, hopefully it won't be for much longer.
Comment 10 Nikita Kareev 2012-02-29 03:59:14 UTC
Is it any progress with this issue?
Comment 11 Andreia Gaita 2012-02-29 06:29:03 UTC
Yes, this bug is fixed in MfA 4.0.5, which has just been released on the beta channel.
Comment 12 narayanp 2013-05-16 05:21:24 UTC
Today we have checked this issue with following details:

X.S 4.0.6(build 4)
Mono2.10.12
Xamarin.Android 4.6.6-11
Windows 7 and Windows 8

Application working fine on API14 and above.

Changing the status to Verified.