Bug 10569 - OpenTK.EglSwapBuffers crash
Summary: OpenTK.EglSwapBuffers crash
Status: RESOLVED ANSWERED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Radek Doulik
URL:
Depends on:
Blocks:
 
Reported: 2013-02-22 03:39 UTC by john.zhang
Modified: 2017-06-30 01:30 UTC (History)
8 users (show)

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


Attachments
Zip of Modified GLCube-1.0 (115.22 KB, application/octet-stream)
2014-04-11 13:44 UTC, Jared Oates
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:
RESOLVED ANSWERED

Description john.zhang 2013-02-22 03:39:17 UTC
WARNING: The runtime version supported by this application is unavailable.
Using default runtime: v2.0.50727
GREF GC Threshold: 46800
loaded /system/lib/egl/libGLES_android.so
loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
Enabling debug mode 0
Loading with default settings
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
called unimplemented OpenGL ES API
UNHANDLED EXCEPTION: OpenTK.Platform.Android.EglException: EglSwapBuffers failed with error 12301 (0x300d)
at OpenTK.Platform.Android.AndroidGraphicsContext.Swap () <0x000dc>
at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () <0x0009f>
at HelloAndroid.GLView1.OnRenderFrame (OpenTK.FrameEventArgs) <0x0021f>
at OpenTK.Platform.Android.AndroidGameView.RenderFrameInternal (OpenTK.FrameEventArgs) <0x00033>
at OpenTK.Platform.Android.AndroidGameView.RunIteration (System.Threading.CancellationToken) <0x0034b>
at OpenTK.Platform.Android.AndroidGameView/<StartThread>c__AnonStorey1.<>m__B (object) <0x00027>
at Android.App.SyncContext/<Send>c__AnonStorey29.<>m__14 () <0x00023>
at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x00037>
at (wrapper dynamic-method) object.060cf77d-5ca6-436a-82d4-9d96470fb26e (intptr,intptr) <0x0003b>

Unhandled Exception:
OpenTK.Platform.Android.EglException: EglSwapBuffers failed with error 12301 (0x300d)
  at OpenTK.Platform.Android.AndroidGraphicsContext.Swap () [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () [0x00000] in <filename unknown>:0 
  at HelloAndroid.GLView1.OnRenderFrame (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView.RenderFrameInternal (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView.RunIteration (CancellationToken token) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView+<StartThread>c__AnonStorey1.<>m__B (System.Object _) [0x00000] in <filename unknown>:0 
  at Android.App.SyncContext+<Send>c__AnonStorey29.<>m__14 () [0x00000] in <filename unknown>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00000] in <filename unknown>:0 
  at Java.Lang.IRunnableInvoker.n_Run (IntPtr jnienv, IntPtr nati
[ERROR] FATAL UNHANDLED EXCEPTION: OpenTK.Platform.Android.EglException: EglSwapBuffers failed with error 12301 (0x300d)
  at OpenTK.Platform.Android.AndroidGraphicsContext.Swap () [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () [0x00000] in <filename unknown>:0 
  at HelloAndroid.GLView1.OnRenderFrame (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView.RenderFrameInternal (OpenTK.FrameEventArgs e) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView.RunIteration (CancellationToken token) [0x00000] in <filename unknown>:0 
  at OpenTK.Platform.Android.AndroidGameView+<StartThread>c__AnonStorey1.<>m__B (System.Object _) [0x00000] in <filename unknown>:0 
  at Android.App.SyncContext+<Send>c__AnonStorey29.<>m__14 () [0x00000] in <filename unknown>:0 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00000] in <filename unknown>:0 
  at Java.Lang.IRunnableInvoker.n_Run (IntPtr jnienv
Comment 1 john.zhang 2013-02-22 03:40:46 UTC
android device: HUAWEI U9500, android 4.0.3
Comment 2 zelyony 2013-08-13 15:18:07 UTC
do u forgot to call MakeCurrent() at begining OnRenderFrame(..)?
default OpenGL project forgot it
Comment 3 Radek Doulik 2014-04-02 11:37:56 UTC
Yes, looks like wrong context to me as well. try to add MakeCurrent () call at the beginning of your OnRenderFrame method in GLView1.

you can also just update to Xamarin Android 4.12.x, where we now call MakeCurrent by default, before entering OnRenderFrame, see http://docs.xamarin.com/releases/android/xamarin.android_4/xamarin.android_4.12/#Xamarin.Android_4.12.0

Did it help or is that something else?
Comment 4 Jared Oates 2014-04-04 15:22:46 UTC
I've updated to Xamarin Android 4.12.3. I call MakeCurrent() at the beginning of my OnRenderFrame method and I'm still seeing an intermittent crash when the call to SwapBuffers() is made.
Comment 5 Radek Doulik 2014-04-07 11:32:46 UTC
Could you please attach your source code or simplified test case so that I can try to replicate it?
Comment 6 Jared Oates 2014-04-11 13:44:19 UTC
Created attachment 6559 [details]
Zip of Modified GLCube-1.0

This is a modified version of the GLCube-1.0 sample app that consistently produces the crash. The kicker seems to be the addition of Holder.SetFormat(Format.Transparent) in the RenderCube() method. I need the GameView to be transparent and allow users to see the CameraView behind it. Any advice on how better to accomplish that would be welcome.
Comment 7 dean.ellis 2014-04-15 04:41:33 UTC
Jared

The Surface format probably needs to be set before the GL Context is created. You best bet would be to try setting it in the CreateFrameBuffer method before calling base. You should only need to call the SetFormat once there is no need to call it every frame.

Its worth noting that not all devices will support what you are trying to do, especially older ones.

Dean
Comment 8 Jared Oates 2014-04-15 17:31:56 UTC
I've tried setting it in CreateFrameBuffer without success. I've found a way to do what I need, however, using a regular GLSurfaceView rather than OpenTK, so I'm ok with closing investigation of this issue.
Comment 9 Chris Hardy [MSFT] 2017-06-30 01:30:03 UTC
Marking as resolved based on Comment 8