3

I have an FragmentActivity where I switch a fragments. One of my fragments contains GLSurfaceView. Everithing works well except first appearance of fragment that contains GLSurfaceView. It turns whole the activity area (notification bar and buttons in the bottom of the screen are not included) goes black for few millis. The most interesting is that GLSurfaceView does not take all the fragment's area and the fragment does not take all the activity's are but all of them blink with black color and another interesting thing is that it happens only for the first time until activity recreates. I marked GLSurfaceView with blue Fragment with green and Activity with red colors. enter image description here

Android native controls does not blink with black color.

Does anyone know what happens here or at least how to debug this behaviour ?

UPD: I create Fragment without GLSurfaceView and it works perfect. Then I add a GLSurfaceView on touch a button and it blink when I do mRootView.addView(mGLSurfaceView); and also only for the firs time.

oleg.semen
  • 2,901
  • 2
  • 28
  • 56
  • How are you configuring your GLSurfaceView? In particular, are you using `setZOrderOnTop()`? – fadden May 12 '14 at 16:24
  • `setEGLConfigChooser(8, 8, 8, 8, 16, 0); getHolder().setFormat(PixelFormat.TRANSLUCENT); setZOrderOnTop(true);` – oleg.semen May 12 '14 at 16:25
  • Sounds like you're getting a frame of opaque black from the SurfaceView. It's on top of the app content, but not the system UI, which is why those don't "blink". Are you calling glClear() on the Surface with opaque black? – fadden May 12 '14 at 17:28
  • No, I dont call `glClear()` in my code. Bu I'm using [Rajawali lib](https://github.com/MasDennis/Rajawali) and i seams that they do it in `render()` method of `RajawaliScene` class [GitHub](https://github.com/MasDennis/Rajawali/blob/master/src/rajawali/scene/RajawaliScene.java#L676). But shouldn't `setFormat(PixelFormat.TRANSLUCENT)` make it transparent instead of black ? – oleg.semen May 12 '14 at 17:40
  • The pixel format just makes the alpha channel available, so transparency is *possible*. If you `glClearColor(0, 0, 0, 1)`, it will clear to opaque black rather than transparent black. It looks like RajawaliScene defaults alpha to zero; are you calling `setBackgroundColor()` with an opaque color value? – fadden May 12 '14 at 18:30
  • I don't `setBackgroundColor()` at all. – oleg.semen May 13 '14 at 15:46
  • In that case, try setting it to zero (or 0,0,0,0) and see if that makes any difference. *Something* is drawing on that surface or it wouldn't appear. – fadden May 13 '14 at 17:05
  • 4
    You might want to check out this answer: http://stackoverflow.com/questions/8772862/surfaceview-flashes-black-on-load/12636285#12636285 It sounds like the answer to a very similar issue. – Cypress Frankenfeld Jul 23 '14 at 20:28
  • Many thanks @CypressFrankenfeld, exactly the same issue!!! – oleg.semen Jul 24 '14 at 09:53
  • @oleg.semen Did you get any solution or workaround to this problem ? – shaktiman_droid Jan 07 '15 at 19:15
  • hi @Jabbar_Jigariyo, I user solution suggested by CypressFrankenfeld above. – oleg.semen Jan 08 '15 at 16:01
  • Possible duplicate of [SurfaceView flashes black on load](https://stackoverflow.com/questions/8772862/surfaceview-flashes-black-on-load) – Björn Kechel Jun 06 '17 at 11:16

0 Answers0