2016-11-27 94 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上。