title: Android - GlSurfaceView in Fragment is running twice at the same time
body: <p>I have an android app that uses a <code>GlSurfaceView</code> to render a 3D fullscreen scene inside a fragment. I have noticed in the profiler, that the <code>GlSurfaceView</code> is actually running <strong>twice</strong> (in two threads), hogging resources and tanking the FPS. I have confirmed the issue by rendering the same OpenGL scene (using the same <code>Renderer</code> implementation) to a live wallpaper and profiling it, which only runs it once.</p>
  
  <p>Am I doing anything wrong here?</p>
  
  <hr>
  
  <p>The code is as follows:</p>
  
  <p><strong>MySurfaceView</strong></p>
  
  <pre><code>class MySurfaceView(ctx: Context): GLSurfaceView(ctx)
  {
      init
      {
          setEGLContextClientVersion(3)
          preserveEGLContextOnPause = true
          setRenderer( /* instantiating the renderer class */ )
      }
  }
  </code></pre>
  
  <p><strong>OpenGLFragment</strong></p>
  
  <pre><code>class OpenGLFragment: Fragment()
  {
      private lateinit var glView: GLSurfaceView
  
      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
                                savedInstanceState: Bundle?): View?
      {
          this.glView = MySurfaceView(this.activity)
          return this.glView
      }
  }
  </code></pre>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>class MainActivity : FragmentActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          val fm = supportFragmentManager
          for (i in 0 until fm.getBackStackEntryCount()) {
              fm.popBackStack()
          }
  
          supportFragmentManager.beginTransaction().add(R.id.main_container, OpenGLFragment())
                      .addToBackStack(null).commit()
      }
  
  }
  </code></pre>