Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25854] Android: Grant WebView permissions for Audio/Video WebRTC streams

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2020-11-25T15:26:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 9.3.0
ComponentsAndroid
Labelsaudio, engTriage, permissions, video, webview
ReporterMichael Gangolf
AssigneeJoshua Quick
Created2018-03-11T18:33:18.000+0000
Updated2020-11-25T15:26:08.000+0000

Description

*Problem* When opening a WebRTC streaming page in an Android Webview the camera won't be visible since the permissions are not granted in the Webview itself. *How to/Example* * Go to https://palava.tv/ and click "secret conference" * use this url for the webview [PALAVA_URL] * App will connect to this conference room
var win = Ti.UI.createWindow({
        title: 'Form',
        backgroundColor: 'blue'
});

var www = Ti.UI.createWebView({
        url: "[PALAVA URL]"
});

win.add(www);

var btn  = Ti.UI.createButton({
        title:"refresh",
        bottom:10
})
btn.addEventListener("click",function(){
        www.url = "[PALAVA_URL]";
})
win.add(btn);
win.open();
Add the permissions to tiapp.xml
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest >
	<uses-permission android:name="android.permission.RECORD_AUDIO" />
	<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
	<uses-permission android:name="android.permission.CAMERA"/>
</manifest>
</android>
*Current status* * Not working with 7.0.2.GA and 7.1.0 (master) *Test env* * Android 7 * HTC A9 *Solution* * Grand permission in Webview

Attachments

FileDateSize
webrtc.mp42018-03-11T18:43:23.000+0000244306

Comments

  1. Michael Gangolf 2018-03-11

    PR: https://github.com/appcelerator/titanium_mobile/pull/9928 webrtc.mp4 shows a Chromium browser with my phone connected using a webview
  2. Sharif AbuDarda 2018-03-11

    Hello, I was able to verify the issue in Android 8.0.0 With SDK 7.0.2.GA. Need Audio/Video permission. Thanks.
  3. Hans Knöchel 2018-06-28

    PR put on hold during more API design required. See details in the linked PR.
  4. Nikos Poulios 2018-10-03

    This applies also to pages using User gets only the file picker, no dialog to select camera or gallery and no user prompt to grant external storage and camera permissions. If those permissions are manually enabled by device's App Settings everything works ok
  5. Michael Gangolf 2018-10-03

    [~nipoul] if you can enable them in the app settings you could also use the normal camera/file permissions dialog (Ti.Android.requestPermissions) to enable them.
  6. Nikos Poulios 2018-10-03

    You can use request permissions and then it would be ok, but you don't want to do that before the user is about to use the camera and there is no clean way to figure out that the user clicked on . This should be handled by TiWebChromeClient
  7. Michael Gangolf 2018-10-03

    Thats true. But at least you can use the workaround before. For the WebRTC part there is no workaround because you can't enable that permission by hand. But you are right, it should be taken into consideration when creating a new PR
  8. Nikos Poulios 2018-10-03

    @Joshua Quick Do you think I should make another ticket for camera/storage permissions or do you plan to include those as well?
  9. kosso 2019-05-12

    I've just come up against this issue trying to do something simple with webRTC in a webView. Could this be part of a solution? https://developer.android.com/reference/android/webkit/WebChromeClient.html#onPermissionRequest(android.webkit.PermissionRequest) public void onPermissionRequest (PermissionRequest request) Notify the host application that web content is requesting permission to access the specified resources and the permission currently isn't granted or denied. The host application must invoke PermissionRequest#grant(String[]) or PermissionRequest#deny(). If this method isn't overridden, the permission is denied.
  10. Michael Gangolf 2019-05-12

    @kosso: see the PR for more details: https://github.com/appcelerator/titanium_mobile/pull/9928 There I was using onPermissionRequest which "solves" the problem but it will allow all permissions and doesn't ask the user. A better system with a user-permission needs to be added
  11. Joshua Quick 2020-09-16

    This can also be tested with...
        var window = Ti.UI.createWindow();
        window.add(Ti.UI.createWebView({
        	url: 'https://mozilla.github.io/webrtc-landing/gum_test.html',
        }));
        window.open();
        
    Mozilla's webpage will test WebRTC for video-only, audio-only, and video+audio. Their webpage also has a test for WebRTC screensharing, but there doesn't appear to be a way of supporting this via Google's Java WebView.
  12. Joshua Quick 2020-09-19

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/12105
  13. Sohail Saddique 2020-10-08

    FR passed for this part of the PR
  14. Samir Mohammed 2020-11-25

    *Closing ticket*. Fix verified in SDK version 9.3.0.v20201125050632. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/12105

JSON Source