Bug 5715 - TexturedCube throwing EGL exceptions when build target set to 4.0.x
Summary: TexturedCube throwing EGL exceptions when build target set to 4.0.x
Status: RESOLVED UPSTREAM
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 4.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-06-18 17:41 UTC by PJ
Modified: 2017-02-08 22:56 UTC (History)
5 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 UPSTREAM

Description PJ 2012-06-18 17:41:16 UTC
Textured cube is throwing EGL exceptions.

This issue does *not* occur when the build target is set lower than (4.0) ICS.


Steps to reproduce:

Run app.
Do anything (touch cube)

Occurs on Debug and Release, TexturedCube-1.0 and TexturedCube.


Exception: 
OpenTK.Platform.Android.EglException: EglSwapBuffers failed with error 12301 (0x300d)
  at OpenTK.Platform.Android.AndroidGraphicsContext.Swap () [0x0004b] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.2.3-branch/410a5aba/source/monodroid/src/OpenGLES/Android/AndroidGraphicsContext.cs:145
  at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () [0x00017] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.2.3-branch/410a5aba/source/monodroid/src/OpenGLES/Android/AndroidGameView.cs:188
  at Mono.Samples.TexturedCube.PaintingView.RenderCube () [0x000e6] in /Users/pjbeaman/GitHubRepositories/monodroid-samples/TexturedCube/PaintingView.cs:234
  at Mono.Samples.TexturedCube.PaintingView.OnTouchEvent (Android.Views.MotionEvent) [0x00098] in /Users/pjbeaman/GitHubRepositories/monodroid-samples/TexturedCube/PaintingView.cs:193
  at Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.2.3-branch/410a5aba/source/monodroid/src/Mono.Android/platforms/android-14/src/generated/Android.Views.View.cs:10920
  at (wrapper dynamic-method) object.d79bcc26-eb95-4476-a9d3-9b4006542822 (intptr,intptr,intptr) <IL 0x00012, 0x0003b>

Logcat: https://gist.github.com/2950842

These outputs from an Acer IconiaTab (A200).

Found on
MD 3.0.3.2
MFA 4.2.3
Comment 1 Jonathan Pryor 2012-06-18 17:43:27 UTC
On a Galaxy Nexus, I get the alternative output:


> W/InputManagerService(  192): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@417465b0 (uid=10029 pid=444)
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> E/libEGL  (14309): called unimplemented OpenGL ES API
> I/MonoDroid(14309): UNHANDLED EXCEPTION: OpenTK.Platform.Android.EglException: EglSwapBuffers failed with error 12301 (0x300d)
> I/MonoDroid(14309): at OpenTK.Platform.Android.AndroidGraphicsContext.Swap () <0x000dc>
> I/MonoDroid(14309): at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () <0x0009f>
> I/MonoDroid(14309): at Mono.Samples.TexturedCube.PaintingView.RenderCube () <0x00257>
> I/MonoDroid(14309): at Mono.Samples.TexturedCube.PaintingView.OnTouchEvent (Android.Views.MotionEvent) <0x00173>
> I/MonoDroid(14309): at Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent_ (intptr,intptr,intptr) <0x00057>
> I/MonoDroid(14309): at (wrapper dynamic-method) object.28393790-3cf7-47c5-b0db-60f712fd318c (intptr,intptr,intptr) <0x00033>
> E/mono    (14309): 
> E/mono    (14309): Unhandled Exception: OpenTK.Platform.Android.EglException: EglSwapBuffers failed with error 12301 (0x300d)
> E/mono    (14309):   at OpenTK.Platform.Android.AndroidGraphicsContext.Swap () [0x00000] in <filename unknown>:0 
> E/mono    (14309):   at OpenTK.Platform.Android.AndroidGameView.SwapBuffers () [0x00000] in <filename unknown>:0 
> E/mono    (14309):   at Mono.Samples.TexturedCube.PaintingView.RenderCube () [0x00000] in <filename unknown>:0 
> E/mono    (14309):   at Mono.Samples.TexturedCube.PaintingView.OnTouchEvent (Android.Views.MotionEvent e) [0x00000] in <filename unknown>:0 
> E/mono    (14309):   at Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent_ (IntPtr jnienv, IntPtr native__this, IntPtr native_e) [0x00000] in <filename unknown>:0 
> E/mono    (14309):   at (wrapper dynamic-method) object:28393790-3cf7-47c5-b0db-60f712fd318c (intptr,intptr,intptr)

What's error 12301 (0x300d)?

    #define EGL_BAD_SURFACE	 0x300D
Comment 2 PJ 2012-06-18 17:51:52 UTC
I can still reproduce this issue on MFA 4.2.2 and MD 3.0.2.
Comment 3 Dominique Louis 2012-06-18 18:39:46 UTC
pj, jonp : I'm unable to run that sample on the emulator. GLCube works fine however. The Error I'm getting is java.lang.UnsatisfiedLinkError: Couldn't load monodroid: findLibrary returned null related - https://gist.github.com/4167ebacf48f05a66e21

It is not even calling the PaintingView constructor on my Mac. Ideas?
Comment 4 Dominique Louis 2012-06-18 19:06:37 UTC
Ok please ignore, I found that uninstalling everything on the emulator and allowing it to reinstall works.

So in an ICS 4.0.3 emulator setting the Target to 4.0 and 4.0.3 works and no bad surface errors are raised :S

Will I need hardware to debug this further, as the emulator appears to be fine for me? What about others, doe the emulator work for you too?
Comment 5 Dominique Louis 2012-06-21 09:07:43 UTC
As crazy as this seems, it appears to be related to how the AndroidManifest.xml is read.

If the uses-sdk tag appears above the application tag (usually if these are left as automatic), then the error as described occurs as OpenGL is initialised incorrectly as libs are loaded before CreateFrameBuffer is called. If the uses-sdk tag appears below the application tag, then OpenGL is initialised correctly.

This gist shows what happens depending on where the uses-sdk tag appears..
https://gist.github.com/c0848affc08e0aae0d8d
Comment 6 Jonathan Pryor 2012-06-21 11:46:15 UTC
Worked around in:

https://github.com/xamarin/monodroid-samples/commit/645eaad1f8c424cec0b78e275aabda5430450b6d

The problem is that things go "south" if Application or Activity hardware acceleration is enabled, and Android v4.0 changed the default so that hardware acceleration was enabled instead of disabled (which is why things worked if you targeted an earlier SDK version, or moved <uses-sdk/> after <application/> {which causes Android to not parse the targetSdkVersion attribute}).
Comment 7 PJ 2012-08-24 16:25:25 UTC
We need to work around this problem in all the samples. I've filed a bug 6684 for that issue.

Keeping this bug open as it describes the actual problem in comment 5 and comment 6. I've added a test case that should result in this bug being updated when the issue is resolved.
Comment 8 Atin 2013-02-05 05:36:21 UTC
We have verified this issue.It is working fine on HTC One V device without throwing any exception, We are able to rotate cube on device in landscape mode as well as in portrait mode successfully. Also able to move cube by taping on cube.


Enviroment info:
XS 4.0 - 233a86f33176e03e90ab78c67ad70d68c211dcfb
MFA 4.6.0.20

Device info:
HTC One V
Version: 4.0.3
Comment 9 Adam Hill 2017-02-08 22:54:30 UTC
This error is still occurring for me in Xamarin.Forms 2.3.3.180 on a Samsung S7 running API 23.

The app is complex, so no repro, but in a nutshell:

The XAML Page contains a Google Map control, two Entry fields (with opacity) and the crash occurrs immediately when I show a longish ListView (only text, no images, via IsVisible = true) with opacity as well, that overlays the Map control. 

Using the #if __ANDROID_11__ HardwareAccelerated = false, #endif fix worked for me.
Comment 10 Adam Hill 2017-02-08 22:56:41 UTC
Ignore, I was on the wrong bug.