1

I add SurfaceView to a FrameLayout to show video,then add the same one SurfaceView to another FrameLayout to show the same video continue,but show nothing with the error as follow: enter image description here

here is bad,it`s used to update video picture to the SurfaceTexture used OpenGLES

shumengma
  • 33
  • 6
  • It would be much easier if you put the error messages in the question as text, rather than as an image. The stack trace shows an `updateTexImage()` failure from code called by com.af56.qfvr.sdk.vrlib, org.rajawali3d.renderer, and com.google.vrtoolkit.cardboard, apparently kicked off from the GLSurfaceView `onDrawFrame()` method. It looks like the EGLContext that the SurfaceTexture is expecting is not current. Are you sure the SurfaceTexture should be updating from the GLSurfaceView renderer thread? – fadden Apr 15 '16 at 04:52

1 Answers1

0

You should not use multiple surface views as also mentioned here.

In general you would need to create a single openGL context for both of the views which might be a solution if it is possible.

If you can not avoid multiple contexts then you have quite a problem on a single thread. Only one context can be set as current per thread so for every operation you do you will need to set the correct context as current. So on beginning of each draw call the context must be set. Seems easy enough but if the view is already doing something with the openGL in a method you may not control then this will not work as well. But on the light side I would expect this is already done for you so you are left with the last problem: The contexts may not share resources, buffers such as a texture unless the contexts are "shared". To create a shared context you need to pass the main context as an argument in context construction which again leads to that you need to be able to control the context by yourself.

So try the following:

  • Check if you can use a single context for both of the views
  • Check if you can create 2 textures (1 for each context) and swap them when swapping the drawing view
  • Create a single surface view and use "viewport" method to control what part of the view you are drawing to
Community
  • 1
  • 1
Matic Oblak
  • 16,318
  • 3
  • 24
  • 43