Java.lang.RuntimeException: eglSwapBuffers failed: EGL_SUCCESS report

I have an Android game using libgdx framework

there is a report in the Google Play store:

java.lang.RuntimeException: eglSwapBuffers failed: EGL_SUCCESS at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1085) at android.opengl.GLSurfaceView$EglHelper.swap(GLSurfaceView.java:1043) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1369) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1123) 

What can I do?

devices reported: Samsung GT-S5830i, Samsung Galaxy Y, LGE LG-P990, Motorola Photon 4G, Motorola Droid X2,

+6
source share
3 answers

This issue has been reported here before . Already have a problem .

You can help by providing more details on this issue.

+6
source

I did some research and found out that this problem occurs in low-maintenance devices because they have low memory. Loading and unloading textures between two SwapBuffer scripts and therefore eliminates this Runtime exception.

The most unpleasant thing about this problem is that when I tested on such devices, I did not get such an error, but in the game store I have too many messages with this problem.

So, we can solve this problem in two ways:

1) Filter low-level devices from a compatible list.

2) Catch the exception with UncaughtExceptionHandler() and tell the user about the low memory problem.

+1
source

The solution is in the last edit.


This really happened on my younger devices ( GT-S5830 and GT-S5830i ).

The fact is that this did not happen due to low memory; I registered the current memory usage in my game and it did not cross 3 megabytes when I was 80 or more megabytes of free bar. I even executed System.gc() sequentially, which tells the garbage collector to free up space in space.

I have no workaround, but I will update this answer as soon as I find it.


After some searching, gpu-related material (e.g. textures) is not managed by the garbage collector (therefore, they should be deleted manually). Therefore, calling System.gc() is somehow pointless. However, I delete all my textures, and the memory usage in my game is pretty low.


I tried all kinds of solutions and nothing worked, but here is something that should fix the problem (I have not tried this, but should work nonetheless):

  • Just don't load so many textures over and over again. My game was used to recycle and then initialize all textures whenever the user moved from the screen. Perhaps this is causing the problem. What you need to do is save the loaded textures / texture atlases in memory (do not lose their link). Thus, switching to the screen will not reload all textures.

  • Avoid using raw Texture and use POT (Power Of Two) TextureAtlas .

I will apply these two steps to my project, and if the problem goes away, I will return to confirm my decision.


It's not a problem. I spent a very long cycle of utilization and loading of textures, there were no exceptions / errors. My suggestion above is not a solution. The problem is probably related to the excessive Screen switching, but I think not, because this problem also occurs when the screen orientation changes from portrait to landscape mode and vice versa.


Decision:

I thought that Game setScreen(screen) automatically calls Screen dispose() (which is not the case). dispose() used to remove all my base textures. I just solved the problem by calling dispose() in Screen hide() overridden method.

Using TextureAtlas very important because you reduce the number of descriptors attached to each Texture . (What could be causing the EGL_SUCCESS error)

Tested on both the GT-S5830 and GT-S5830i (Samsung Galaxy Ace and Samsung Galaxy Y). The problem no longer arises.

0
source

Source: https://habr.com/ru/post/917301/


All Articles