owt-client-android icon indicating copy to clipboard operation
owt-client-android copied to clipboard

OpenGL context leak

Open chenxiemin opened this issue 5 years ago • 0 comments

opengl context leak when start / stop the video capture, suggest the following change on MediaStreamFactory.java:

diff --git a/src/sdk/base/src/main/java/owt/base/MediaStreamFactory.java b/src/sdk/base/src/main/java/owt/base/MediaStreamFactory.java index e3eb83a..e997ac3 100644 --- a/src/sdk/base/src/main/java/owt/base/MediaStreamFactory.java +++ b/src/sdk/base/src/main/java/owt/base/MediaStreamFactory.java @@ -21,8 +21,27 @@ import owt.base.MediaConstraints.AudioTrackConstraints;

final class MediaStreamFactory {

  • private class VideoSourceBundle {
  •    public VideoSource videoSource;
    
  •    public SurfaceTextureHelper textureHelper;
    
  •    public VideoSourceBundle(VideoSource source, SurfaceTextureHelper helper) {
    
  •        videoSource = source;
    
  •        textureHelper = helper;
    
  •    }
    
  •    public void dispose() {
    
  •        if (null != videoSource)
    
  •            videoSource.dispose();
    
  •        videoSource = null;
    
  •        if (null != textureHelper)
    
  •            textureHelper.dispose();
    
  •        textureHelper = null;
    
  •    }
    
  • }
  • private static MediaStreamFactory instance;
  • private final HashMap<String, VideoSource> unsharedVideoSources = new HashMap<>();
  • private final HashMap<String, VideoSourceBundle> unsharedVideoSources = new HashMap<>(); private AudioSource sharedAudioSource; private int audioSourceRef = 0;

@@ -56,7 +75,9 @@ final class MediaStreamFactory { videoSource); videoTrack.setEnabled(true); mediaStream.addTrack(videoTrack);

  •        unsharedVideoSources.put(label, videoSource);
    
  •        VideoSourceBundle bundle = new VideoSourceBundle(videoSource, helper);
    
  •        unsharedVideoSources.put(label, bundle);
       }
    
       if (audioMediaConstraints != null) {
    

@@ -82,9 +103,9 @@ final class MediaStreamFactory {

 void onVideoSourceRelease(String label) {
     DCHECK(unsharedVideoSources.containsKey(label));
  •    VideoSource videoSource = unsharedVideoSources.get(label);
    
  •    VideoSourceBundle videoSourceBundle = unsharedVideoSources.get(label);
       unsharedVideoSources.remove(label);
    
  •    videoSource.dispose();
    
  •    videoSourceBundle.dispose();
    
    }

}

chenxiemin avatar Jan 21 '20 03:01 chenxiemin