2016-11-27 90 views
0

我正在使用webGL和android webview(chrome 54.0)编写增强现实应用程序。这就是我得到JS应用视频流(这工作得很好):Android WebView + WebGL + Camera:BufferQueue已被放弃

return navigator 
     .mediaDevices 
     .getUserMedia({video: { 
      "facingMode": "environment", 
      "width": cameraWidth, 
      "height": cameraHeight 
     }}) 
     .then((stream) => { 
      let cameraURL = URL.createObjectURL(stream); 

      // create Three.js texture with updated camera picture 
     }) 
     .catch(function(exception) { 
      // ... 
     }); 

我必须表现出一定的UI视图在我的web视图,所以我从视图中捕捉位图,并把它上传到JS应用:

Bitmap viewBitmap = Bitmap.createBitmap(
     myView.getMeasuredWidth(), 
     myView.getMeasuredHeight(), 
     Bitmap.Config.ARGB_8888 
); 

Canvas canvas = new Canvas(viewBitmap); 
myView.draw(canvas); 

ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); 
viewBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteStream); 
String base64EncodedBitmap = "data:image/png;base64," 
     + Base64.encodeToString(
       byteStream.toByteArray(), 
       Base64.DEFAULT 
     ); 

mWebView.loadUrl(
    String.format(
     "javascript:someFunction(\"%s\");void(0);", 
     base64EncodedBitmap 
    ) 
); 

那我的设备,华为P8精简版(6.0)上工作,但无法在Nexus 5(6.0.1) - 加载一些意见后(也许以后垃圾收集器的工作)它从相机冻结的视频和continiously重复日志内:

E/BufferQueueProducer: [ImageReader-640x480f23m2-7366-1] dequeueBuffer: BufferQueue has been abandoned 

有谁知道,怎么了,怎么解决这个问题? 任何帮助将不胜感激!

回答

0

嗯,我没有找到正确的解决方案。最后,我结束了WebView的透明背景,放置在显示来自摄像头的视频的Android TextureView上。