Bug 6546 - EglCreateWindowSurface failed with error 12297 (0x3009)
Summary: EglCreateWindowSurface failed with error 12297 (0x3009)
Status: RESOLVED INVALID
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-08-15 15:40 UTC by dellis1972
Modified: 2012-08-17 11:29 UTC (History)
2 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:
RESOLVED INVALID

Description dellis1972 2012-08-15 15:40:20 UTC
Standard Mono for Android openGL app produces a UNHANDLED EXCEPTION: OpenTK.Platform.Android.EglException: EglCreateWindowSurface failed with error 12297 (0x3009). 

This happens on a Motorola Defy, but works on other devices.

Dean

This is the logcat.


D/dalvikvm( 2903): GC_CONCURRENT freed 101K, 46% free 3049K/5639K, external 577K/587K, paused 2ms+3ms
I/ActivityManager( 2278): No longer want com.skype.raider (pid 2709): hidden #16
I/ActivityManager( 2278): Starting: Intent { act=com.android.launcher.action.launcheraction flg=0x10000000 cmp=com.android.launcher/.CustomShirtcutActivity bnds=[192,770][288,854] (has extras) } from pid 2409
W/InputManagerService( 2278): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4090d338
I/ActivityManager( 2278): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=SampleGame.SampleGame/samplegame.Activity1 } from pid 2409
I/ActivityManager( 2278): Start proc SampleGame.SampleGame for activity SampleGame.SampleGame/samplegame.Activity1: pid=2916 uid=10077 gids={3003, 1015}
D/szipinf ( 2916): Initializing inflate state
I/ActivityThread( 2916): Pub SampleGame.SampleGame.mono.MonoRuntimeProvider.__mono_init__: mono.MonoRuntimeProvider
D/dalvikvm( 2916): Trying to load lib /data/data/SampleGame.SampleGame/lib/libmonodroid.so 0x40513ea8
D/dalvikvm( 2916): Added shared lib /data/data/SampleGame.SampleGame/lib/libmonodroid.so 0x40513ea8
E/mono    ( 2916): WARNING: The runtime version supported by this application is unavailable.
E/mono    ( 2916): Using default runtime: v2.0.50727
W/monodroid-gc( 2916): GREF GC Threshold: 46800
D/dalvikvm( 2916): GC_EXTERNAL_ALLOC freed 54K, 50% free 2698K/5379K, external 0K/0K, paused 25ms
D/libEGL  ( 2916): loaded /system/lib/egl/libEGL_POWERVR_SGX530_125.so
D/libEGL  ( 2916): loaded /system/lib/egl/libGLESv1_CM_POWERVR_SGX530_125.so
D/libEGL  ( 2916): loaded /system/lib/egl/libGLESv2_POWERVR_SGX530_125.so
I/MonoDroid( 2916): UNHANDLED EXCEPTION: OpenTK.Platform.Android.EglException: EglCreateWindowSurface failed with error 12297 (0x3009)
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidWindow.CreateSurface (Javax.Microedition.Khronos.Egl.EGLConfig) <0x0015c>
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidGraphicsContext.Init (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,OpenTK.Graphics.IGraphicsContext,int,OpenTK.Graphics.GraphicsContextFlags) <0x0044f>
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidGraphicsContext..ctor (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,OpenTK.Graphics.IGraphicsContext,OpenTK.Graphics.GLContextVersion,OpenTK.Graphics.GraphicsContextFlags) <0x00053>
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidGraphicsContext.CreateGraphicsContext (OpenTK.Graphics.GraphicsMode,OpenTK.Platform.IWindowInfo,OpenTK.Graphics.IGraphicsContext,OpenTK.Graphics.GLContextVersion,OpenTK.Graphics.GraphicsContextFlags) <0x00053>
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidGameView.CreateContext () <0x00057>
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidGameView.CreateFrameBuffer () <0x00013>
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidGameView.LoadInternal (System.EventArgs) <0x0001f>
I/MonoDroid( 2916): at OpenTK.Platform.Android.AndroidGameView.SurfaceCreated (Android.Views.ISurfaceHolder) <0x0014b>
I/MonoDroid( 2916): at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (intptr,intptr,intptr) <0x0005b>
I/MonoDroid( 2916): at (wrapper dynamic-method) object.578829a1-f308-40a2-a73c-310d05d3e23f (intptr,intptr,intptr) <0x00033>
E/mono    ( 2916):
E/mono    ( 2916): Unhandled Exception: OpenTK.Platform.Android.EglException: EglCreateWindowSurface failed with error 12297 (0x3009)
E/mono    ( 2916):   at OpenTK.Platform.Android.AndroidWindow.CreateSurface (Javax.Microedition.Khronos.Egl.EGLConfig config) [0x00000] in <filename unknown>:0
E/mono    ( 2916):   at OpenTK.Platform.Android.AndroidGraphicsContext.Init (OpenTK.Graphics.GraphicsMode mode, IWindowInfo win, IGraphicsContext sharedContext, Int32 major, GraphicsContextFlags flags) [0x00000] in <filename unknown>:0
E/mono    ( 2916):   at OpenTK.Platform.Android.AndroidGraphicsContext..ctor (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, IGraphicsContext sharedContext, GLContextVersion glesVersion, GraphicsContextFlags flags) [0x00000] in <filename unknown>:0
E/mono    ( 2916):   at OpenTK.Platform.Android.AndroidGraphicsContext.CreateGraphicsContext (OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, IGraphicsContext sharedContext, GLContextVersion glVersion, GraphicsContextFlags flags) [0x00000] in <filename unknown>:0
E/mono    ( 2916):   at OpenTK.Platform.Android.AndroidGameView.CreateCont
I/WindowManager( 2278): WIN DEATH: Window{4091c3c8 SampleGame.SampleGame/samplegame.Activity1 paused=false}
I/ActivityManager( 2278): Process SampleGame.SampleGame (pid 2916) has died.
D/Zygote  ( 2133): Process 2916 exited cleanly (1)
I/WindowManager( 2278): WIN DEATH: Window{4091d330 SurfaceView paused=false}
Comment 1 Jonathan Pryor 2012-08-17 11:29:11 UTC
Error 0x3009 is in <EGL/egl.h>

> #define EGL_BAD_MATCH			0x3009

http://www.khronos.org/opengles/sdk/1.1/docs/man/eglCreateWindowSurface.xml

> EGL_BAD_MATCH is generated if the attributes of native_window do not correspond
> to config or if config does not support rendering to windows (the EGL_SURFACE_TYPE
> attribute does not contain EGL_WINDOW_BIT).

What's that mean? It means that the default OpenGLES configuration that we're trying to use is incompatible with your device. The solution is (unfortunately) for your code to detect this situation and use a different configuration, because (doubly unfortunately) Android hardware has been known to "lie" about the "valid" configurations, in which an OpenGLES configuration that the device says is valid results in an error when trying to use it.

The fix? Support multiple configurations and try them in turn:

https://github.com/xamarin/monodroid-samples/blob/master/GLCube/PaintingView.cs#L40
https://github.com/xamarin/monodroid-samples/blob/master/GLTriangle20/PaintingView.cs#L40
https://github.com/xamarin/monodroid-samples/blob/master/TexturedCube/PaintingView.cs#L54

As a further sanity check, please ensure that the GLDiagnostics sample runs without crashing on your device. GLDiagnostics goes through every configuration that Android reports and attempts to use it, reporting which configurations are valid/invalid to `adb logcat`.

See also: http://lists.ximian.com/pipermail/monodroid/2012-May/010540.html