Bug 1918 - Rotating OpenGL app dies with egl.EglMakeCurrent failed: 0x3009
Summary: Rotating OpenGL app dies with egl.EglMakeCurrent failed: 0x3009
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.0
Hardware: PC Windows
: Highest normal
Target Milestone: ---
Assignee: Andreia Gaita
URL:
Depends on:
Blocks:
 
Reported: 2011-11-07 16:57 UTC by randyficker
Modified: 2014-01-21 07:44 UTC (History)
8 users (show)

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

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 randyficker 2011-11-07 16:57:54 UTC
1. Make a fresh “Mono for Android OpenGL Application”
2. Deploy it to a device
3. Rotate the device back and forth between portrait and landscape.
4. Within 2-4 rotates, the app dies with this exception:

I(   97:0x70) Setting rotation to 1, animFlags=0
I(   97:0x70) Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=1/1/2 nav=3/1 orien=2 layout=34 uiMode=17 seq=155}
D(25138:0x6232) SurfaceDestroyed
D(25138:0x6232) SurfaceCreated
D(  205:0xcd) GC_EXTERNAL_ALLOC freed 123K, 48% free 3277K/6279K, external 6224K/6227K, paused 61ms
E(25138:0x6251) eglMakeCurrent:1212 error 3009 (EGL_BAD_MATCH)
I(25138:0x6251) UNHANDLED EXCEPTION: System.InvalidOperationException: egl.EglMakeCurrent failed: 0x3009
I(25138:0x6251) at OpenTK.Platform.Android.AndroidGraphicsContext.MakeCurrent (OpenTK.Platform.IWindowInfo) <0x00134>
I(25138:0x6251) at OpenTK.Platform.Utilities.CreateGraphicsContext (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,int,int,OpenTK.Graphics.GraphicsContextFlags) <0x0006f>
I(25138:0x6251) at OpenTK.Platform.Android.AndroidGameView.CreateFrameBuffer () <0x000a7>
I(25138:0x6251) at OpenTK.Platform.Android.AndroidGameView.RunIteration () <0x0016b>
I(25138:0x6251) at OpenTK.Platform.Android.RepeatTimerTask.Run () <0x00023>
I(25138:0x6251) at Java.Util.TimerTask.n_Run (intptr,intptr) <0x00033>
I(25138:0x6251) at (wrapper dynamic-method) object.c83607bc-1f2b-4e22-b808-ffb4096c3a85 (intptr,intptr) <0x0002b>
E(25138:0x6251)
E(25138:0x6251) Unhandled Exception: System.InvalidOperationException: egl.EglMakeCurrent failed: 0x3009
E(25138:0x6251)   at OpenTK.Platform.Android.AndroidGraphicsContext.MakeCurrent (IWindowInfo window) [0x00000] in <filename unknown>:0
E(25138:0x6251)   at OpenTK.Platform.Utilities.CreateGraphicsContext (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, Int32 major, Int32 minor, GraphicsContextFlags flags) [0x00000] in <filename unknown>:0
E(25138:0x6251)   at OpenTK.Platform.Android.AndroidGameView.CreateFrameBuffer () [0x00000] in <filename unknown>:0
E(25138:0x6251)   at OpenTK.Platform.Android.AndroidGameView.RunIteration () [0x00000] in <filename unknown>:0
E(25138:0x6251)   at OpenTK.Platform.Android.RepeatTimerTask.Run () [0x00000] in <filename unknown>:0
E(25138:0x6251)   at Java.Util.TimerTask.n_Run (IntPtr jnienv, IntPtr native__this) [0x00000] in <filename unknown>:0
E(25138:0x6251)   at (wrapper dynamic-method) object:c83607bc-1f2b-4e22-b808-ffb4096c3a85 (intptr,intptr)
I(   97:0x61) Process OpenGLApplication6.OpenGLApplication6 (pid 25138) has died.
I(   97:0x66) WIN DEATH: Window{409685a0 OpenGLApplication6.OpenGLApplication6/openglapplication6.Activity1 paused=false}
I(   97:0x4492) WIN DEATH: Window{40975010 SurfaceView paused=false}
D(   67:0x43) Process 25138 exited cleanly (1)
I(   97:0x61) Setting rotation to 0, animFlags=1
I(   97:0x61) Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=1/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=156}
V(20325:0x4f65) surfaceCreated
V(20325:0x4f65) surfaceChanged


This repros 100% of the time for me.  I’m running a Nexus One with Android 2.3.6.
Comment 1 randyficker 2011-12-11 05:53:16 UTC
I've verified this still repros in 4.0, so I'm updating the version.  An update  on a fix to this bug would be appreciated.
Comment 2 randyficker 2012-01-25 23:32:19 UTC
I've verified this bug still repros in 4.0.3.  I also wanted to note that it doesn't specifically have anything to do with the rotation.  In place of the rotation, you could just launches a new activity then press the back button and the same error would come up.  It seems loading an OpenGL view randomly causes this error.

I also had the opportunity to try this on a Kindle Fire.  The bug does repro on the Fire, but it took quite a few more rotates before it crashed.  On my Nexus One, it always crashes within 2-4 rotates, whereas the Kindle Fire it took around 20.  I was still always able to make the Fire crash with this error.
Comment 3 dbh1997 2012-02-26 02:29:52 UTC
Crashes immediately on Motorola Xoom with same error, no rotations necessary.  Tried forcing to API levels 8 and 10 to no avail.  Using 4.0.4.  Dead in the water without a workaround or fix...
Comment 4 randyficker 2012-02-26 05:29:17 UTC
One of my beta testers has a Samsung Galaxy Nexus running Android 4.0.2 and he also reported getting this error as soon as the OpenGL view loads -- he's dead in the water, too.

It's a shame Xamarin doesn't seem to care about this bug, as this pretty much makes OpenGL apps unusable. I've been able to repro it on every device I've gotten my mitts on.

I've been waiting almost 4 months now without a single word from Xamarin.  This is the problem with closed source products - my only recourse is to abandon MonoDroid.
Comment 5 Andreia Gaita 2012-02-27 12:58:24 UTC
Hi,

This bug did indeed take a long while to fix, we're sorry for not providing you with more feedback.
We are currently getting ready to release a new MfA beta update that contains a complete rewrite of the OpenTK/Android backend which addresses all these issues - MfA 4.0.5.  This should be out in a day or two.
Comment 6 randyficker 2012-02-28 23:37:37 UTC
Hi Andreia,

I'm glad to hear that OpenTK/Android is getting some attention!

I see MfA 4.0.5 is available on the Beta channel.  I installed it and tried to repro this bug.  Unfortunately it does not look like it's fixed, however it gives a different error message now.  Instead of "egl.EglMakeCurrent failed: 0x3009", it gets "Operation requires a GraphicsContext, which hasn't been created yet."

Here's the full error message from logcat:


E( 6971:0x1b3b) call to OpenGL ES API with no current context (logged once per thread)
I( 6971:0x1b3b) UNHANDLED EXCEPTION: System.InvalidOperationException: Operation requires a GraphicsContext, which hasn't been created yet.
I( 6971:0x1b3b) at OpenTK.Platform.Android.AndroidGameView.AssertContext () <0x00044>
I( 6971:0x1b3b) at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () <0x0001b>
I( 6971:0x1b3b) at OpenGLApplication11.GLView1.OnRenderFrame (OpenTK.FrameEventArgs) <0x002c7>
I( 6971:0x1b3b) at OpenTK.Platform.Android.AndroidGameView.RenderFrameInternal (OpenTK.FrameEventArgs) <0x00027>
I( 6971:0x1b3b) at OpenTK.Platform.Android.AndroidGameView.<RunIteration>m__4 (object) <0x0001b>
I( 6971:0x1b3b) at Android.App.SyncContext/<Send>c__AnonStorey1A.<>m__1 () <0x00023>
I( 6971:0x1b3b) at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
I( 6971:0x1b3b) at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x00037>
I( 6971:0x1b3b) at (wrapper dynamic-method) object.5f466832-1c3b-42cb-af58-8d9b95596713 (intptr,intptr) <0x0002b>
E( 6971:0x1b3b)
E( 6971:0x1b3b) Unhandled Exception: System.InvalidOperationException: Operation requires a GraphicsContext, which hasn't been created yet.
E( 6971:0x1b3b)   at OpenTK.Platform.Android.AndroidGameView.AssertContext () [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at OpenGLApplication11.GLView1.OnRenderFrame (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at OpenTK.Platform.Android.AndroidGameView.RenderFrameInternal (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at OpenTK.Platform.Android.AndroidGameView.<RunIteration>m__4 (System.Object _) [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at Android.App.SyncContext+<Send>c__AnonStorey1A.<>m__1 () [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at Java.Lang.Thread+RunnableImplementor.Run () [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at Java.Lang.IRunnableInvoker.n_Run (IntPtr jnienv, IntPtr native__this) [0x00000] in <filename unknown>:0
E( 6971:0x1b3b)   at (wrapper dynamic-method) object:5f466832-1c3b-42cb-af58-8d9b
I(   97:0x117) Process OpenGLApplication11.OpenGLApplication11 (pid 6971) has died.
I(   97:0x67) WIN DEATH: Window{4093bb60 OpenGLApplication11.OpenGLApplication11/openglapplication11.Activity1 paused=false}
Comment 7 Andreia Gaita 2012-03-01 06:45:26 UTC
Are you creating the app on VisualStudio or MonoDevelop? If it's on MonoDevelop, which version is it?
Comment 8 randyficker 2012-03-01 06:48:01 UTC
Visual Studio 2010
Comment 9 Andreia Gaita 2012-03-01 08:44:46 UTC
Ah, a race condition slipped through there, I'm sorry about that. We're working on it and getting a workaround in the meantime, I'll get back to you as soon as I have it.
Comment 10 Andreia Gaita 2012-03-01 11:30:59 UTC
To work around this issue while a fixed version isn't released, wrap the call to SwapBuffers in a try/catch so  it doesn't take down your app.
Comment 11 Andreia Gaita 2012-03-22 20:03:23 UTC
Fixed in MfA 4.0.6
Comment 12 Prashant manu 2014-01-21 07:44:23 UTC
I have checked this issue with following builds:

All Windows
X.S 1.2.3(build 146)
X.Android 4.13.0-4

I am not seeing any crash for Open GL sample on android device when changing device view. This is gist of Application Output: https://gist.github.com/saurabh360/aea96ef89048818c80f3

Android device
Samsung S4 version 4.3