Android “cpu may be pegged” bug

前端 未结 2 1032
星月不相逢
星月不相逢 2020-12-29 10:41

Foreword: This severe bug can cause Android devices to lock up (unable to press Home/Back buttons, needs hard reset). It is associated with OpenGL surfaces and audio pla

相关标签:
2条回答
  • 2020-12-29 11:35

    In the case of my game the "waitForCondition" problem has been noticed on Samsung Galaxy S (Android 2.3.3). Of course I don't know if the issue has been noticed on different devices, but probably the problem exists there too. Fortunately I was able to reproduce it as one of my friends has got the device and he was kind enough to lent me one for a week. In my case the game is practically all written in Java (few calls through NDK to OpenGL functions), so I'm not really sure if this will apply to your problem too.

    Anyway it seems that the problem is somehow related to OpenGL internal buffers. In the code presented below the line which has been commented out (1) has been changed to (2) - manual config selection. I didn't test it thoroughly yet, but since that change I haven't noticed any freezes, so there is a hope..

    UPDATE 1: As an additional info, I think I read somewhere that somebody had the same problem with his CPU gets pegged and his solution was to set up all the OpenGL Surface components to 8 bits (alpha component too) rather than 565 or 4 bits (I don't remember exactly what was the faulty configuration)

    UPDATE 2: Also one may consider to use the following implementation of the EGLConfigChooser: GdxEglConfigChooser.java. If this doesn't help eventually use the approach presented in GLSurfaceView20.java.

    UPDATE 3: Additionally simplifying the program shaders as much as it's possible helped a bit too.

    // in Activity...
    glView = new GLSurfaceView(this);
    glView.setEGLContextClientVersion(2); // OpenGL ES 2.0
    //      glView.setEGLConfigChooser(false); // (1) false - no depth buffer
    glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    glView.setEGLConfigChooser(8,8,8,8,0,0); // (2) TODO: crashes on devices which doesn't support this particular configuration
    glView.setRenderer(new MyRenderer(this));
    
    0 讨论(0)
  • 2020-12-29 11:39

    Increasing the virtual memory of the device lowers the occurrences in which this issue happens. Of course this is not an option unless you are the manufacturer of the device.

    0 讨论(0)
提交回复
热议问题