title: WebRTC on RPi3 fails on getUserMedia() using WebView
body: <p>I am tinkering with <a href="https://developer.android.com/things/" rel="nofollow noreferrer">Android Things v1.0</a> and am trying to get WebRTC working using <a href="https://developer.android.com/reference/android/webkit/WebView" rel="nofollow noreferrer">WebView</a> on RaspberryPi 3.  <a href="https://www.onsip.com/blog/lollipop-webview-allows-webrtc-to-run-natively-inside-android-apps" rel="nofollow noreferrer">Which in theory should be possible</a>.  </p>
  
  <p>I understand it's possible that the <a href="https://github.com/androidthings/doorbell/issues/10" rel="nofollow noreferrer">camera HAL pipeline only supports 1 stream</a> on RPi 3, which might be part of the problem.  But, unless <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia" rel="nofollow noreferrer">getUserMedia()</a> is trying to grab more than the single stream, and I don't think it is, it should just return the local video stream:</p>
  
  <pre><code>navigator.mediaDevices.getUserMedia({
          audio: false,
          video: true
      })
      .then(
          gotUserMedia, 
          didntGetUserMedia
      );
  </code></pre>
  
  <p><code>gotUserMedia</code> is never called, only <code>didntGetUserMedia</code> is called.  Furthermore: </p>
  
  <pre><code>If the browser cannot find all media tracks with the specified types that meet the 
  constraints given, then the returned promise is rejected with NotFoundError.
  </code></pre>
  
  <p>Which is not the error thrown:</p>
  
  <pre><code>object NavigatorUserMediaError
  </code></pre>
  
  <p>I am doing all this with a working WebRTC web application that works with Chrome browser on Mac, Windows, and Ubuntu.  The problem appears to be around the RPi.  If I load a Raspbian OS and use Chromium (<a href="https://www.raspberrypi.org/forums/viewtopic.php?t=161613" rel="nofollow noreferrer">which supports WebRTC</a>), it still does not get the local video stream.  Perhaps the issues are related?  </p>
  
  <p>The camera <strong>works</strong> if I open it with native app on <code>Raspbian</code>, and it <strong>also works</strong> in <code>Android Things</code> if i simply preview it using a <code>textureView</code> from within the same Android app that the Webview is in - but not at the same time.  </p>
  
  <p>The permissions granted have been done so manually, and are declared in the Manifest:</p>
  
  <pre><code>adb shell pm grant com.rpi.garagetinker android.permission.CAMERA
  adb shell pm grant com.rpi.garagetinker android.permission.INTERNET
  adb shell pm grant com.rpi.garagetinker android.permission.WRITE_EXTERNAL_STORAGE
  
  
  &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  </code></pre>
  
  <p>I have not dug into the errors on Chromium, but the logcat for Android Things RPi and Webview shows a permissions issue, which may be related to the problem (given the getUserMedia() error above):</p>
  
  <pre><code>12-31 18:00:07.491 772-772/? E//system/bin/webview_zygote32: Failed to make and chown /acct/uid_99000: Permission denied
  12-31 18:00:07.491 299-310/? I/ActivityManager: Start proc 772:com.android.webview:sandboxed_process0/u0i0 for webview_service com.rpi.garagetinker/org.chromium.content.app.SandboxedProcessService0
  </code></pre>
  
  <p>I don't know if this is the problem, and am uncertain how to fix if it is. <strong>I really think this is a permissions issue</strong>, but what other permissions might I grant? Any guidance is appreciated.</p>
  
  <p>Notes: </p>
  
  <ul>
  <li>Pi has been rebooted many times.  </li>
  <li>HTTPS protocol (CA issued cert) is being used.  </li>
  <li><p>There is only ONE WebView in use, and this is the only app installed on new Android Things image.</p>
  
  <p>Posts solving issue when multiple browsers are involved <a href="https://stackoverflow.com/questions/17793599/why-is-getusermedia-throwing-a-object-navigatorusermediaerror-when-i-click-al">like this</a> are not directly helpful, but suggest that something else might be consuming the media handle.</p></li>
  </ul>
  
  <p>Also, also, Chromium on Raspbian does not prompt for access to video (audio which is not present) like it does on Chrome other OS's.  </p>
  
  <p>WebRTC is now working on Raspbian with Chromium.  </p>