Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27299] Camera access from WebView, causing permission error.

GitHub Issuen/a
TypeBug
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterSharif AbuDarda
AssigneeUnknown
Created2019-07-30T17:01:52.000+0000
Updated2019-11-11T16:10:14.000+0000

Description

Hello, I am trying to run a video-chat page inside of a webview. Below is the code I have index.xml
<Alloy>
	<Window id="winTest" class="container" modal="true">

		<View id="vMain">	

			<View id="vTop" width="50" height="50" top="0">
				<Label id="MainTitle" top="15" left="8">Fireworks Over America</Label>
				<ImageView id="imgClose" onClick="closeWindow" image="/images/close-white.png" height="35" width="35" top="8" right="8"/>
			</View>
		
            <View width="100%" height="2" class="HRView" id="HRView"></View>
			<!-- 
			<View id="wvLoginContainerContainer">
				<View id="wvLoginContainer">
				   <WebView id="wvLogin" />
		      </View>
		   </View>
			--> 
		<View id="wvLoginContainerContainer" visible="false">
			<View id="wvLoginContainer">
			   
	      </View>
	   </View> 
		<WebView id="wvTest" aheight="100%" width="Ti.UI.FILL" width="Ti.UI.FILL" width="95%" borderWidth="0" borderColor="#00ff00" url=""/> 
		   
		   
		</View>
	</Window>
</Alloy>
index.js
blnShowingLogin=true;

$.winTest.addEventListener('open',function(e){
	if (OS_ANDROID) {  
      $.winTest.activity.actionBar.hide();
   }		
});

function closeWindow(){
	$.winTest.close({animated:true});
}

Ti.App.addEventListener('HandleOrientationChange', function(e) {
	RedrawWindow();	
});

function RedrawWindow(){

}


if (OS_IOS) {
	$.winTest.statusBarStyle=Ti.UI.iOS.StatusBar.LIGHT_CONTENT;
}


if (OS_IOS) {
	if (!Ti.Media.hasCameraPermissions()) {
		Ti.Media.requestCameraPermissions(function (e) {
		    if (e.success) {
				$.wvTest.url="https://www.christianrock.net/chat-test.asp";
		    } else {
		        Ti.API.error('Could not obtain camera permissions!');
		    }
		});
	} else {
		$.wvTest.url="https://www.christianrock.net/chat-test.asp";
	}
}
else
{
	$.wvTest.url="https://www.christianrock.net/chat-test.asp";
}

RedrawWindow();
$.winTest.open();
index.tss
".container": {
	backgroundColor:"#001780"
}

"#vTop":{
   backgroundColor:"#001780"
}

"#wvLogin":{
	backgroundColor : "#000000"
}

"#MainTitle":{
	color: "#ffffff",
	font: {
		fontSize: 16
	}
}

"Label": {
	width: Ti.UI.SIZE,
	height: Ti.UI.SIZE,
	color: "#000"
}

"#wvLoginContainer":{
  top:10,
  borderWidth: "1",
  borderColor: "#000000",
  borderRadius: 6
}

"#wvLoginContainerContainer":{
  aborderWidth: "2",
  aborderColor: "#00ff00",
   backgroundImage:"images/cover.jpg",
   width:Ti.UI.FILL,
	height:Ti.UI.FILL
}

"#vMain":{
  aborderWidth: "2",
  aborderColor: "#ff0000",
  backgroundColor:"#001780",
  abackgroundGradient: {
        type: 'linear',
        startPoint: { x: '0%', y: '50%' },
        endPoint: { x: '100%', y: '50%' },
        colors: [ { color: '#001780', offset: 0.0}, { color: '#0d48ac', offset: 1.0 } ],
    }
}

"#lblVersion[formFactor=tablet]":{
	color: "#ffffff",
	font: {
		fontSize: 14
	}
}
"#lblVersion[formFactor=handheld]":{
	color: "#ffffff",
	font: {
		fontSize: 12
	}
}
".HRView":{
   height:1,
	width:Ti.UI.SIZE,
	backgroundColor:"#eeeeee"
}
alloy.js
// The contents of this file will be executed before any of
// your view controllers are ever executed, including the index.
// You have access to all functionality on the Alloy namespace.
//
// This is a great place to do any initialization for your app
// or create any global variables/functions that you'd like to
// make available throughout your app. You can easily make things
// accessible globally by attaching them to the Alloy.Globals
// object. For example:
//
// Alloy.Globals.someGlobalFunction = function(){};


Alloy.Globals.ImageCount=0;
Alloy.Globals.ImageNumber=0;
Also in my tiapp.xml I have the permission set for camera and microphone
<android 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools">
    <manifest android:versionCode="2516">
      <uses-permission android:name="android.permission.CAMERA"/>
      <uses-feature android:name="android.hardware.camera"/>
      <uses-permission android:name="android.permission.RECORD_AUDIO"/>
    </manifest>
</android>


<ios>
    <plist>
        <dict>
            <key>NSCameraUsageDescription</key>
            <string>To take a picture we want to use the camera</string>
 
            <!-- needed for video -->
            <key>NSCameraUsageDescription</key>
            <string>For Video recording we want to use the microphone</string>
        </div>
    </plist>
</ios>
Now, After the app opens, when I click on the 'click to start video chat' button inside of the webview, In Android, I get the attached error in my console:
[ERROR] chromium: [ERROR:web_contents_delegate.cc(196)] WebContentsDelegate::CheckMediaAccessPermission: Not supported.
[ERROR] chromium: [ERROR:web_contents_delegate.cc(196)] WebContentsDelegate::CheckMediaAccessPermission: Not supported.
[WARN] cr_media: Requires MODIFY_AUDIO_SETTINGS and RECORD_AUDIO. No audio device will be available for recording
[INFO] CameraManagerGlobal: Connecting to camera service
[WARN] CameraBase: An error occurred while connecting to camera 1: Service not available
[ERROR] cr_VideoCapture: Camera.open:
[ERROR] cr_VideoCapture: java.lang.RuntimeException: Fail to connect to camera service
[ERROR] cr_VideoCapture: at android.hardware.Camera.<init>(Camera.java:519)
[ERROR] cr_VideoCapture: at android.hardware.Camera.open(Camera.java:364)
[ERROR] cr_VideoCapture: at cFx.d(PG:32)
[ERROR] cr_VideoCapture: at org.chromium.media.VideoCaptureFactory.getDeviceSupportedFormats(PG:20)
In both iOS and Android, the attached image error in the screen shows up. I can load the URL in Safari and it works. After I click, a dialog opens for accessing camera and microphone, this dialog is not showing up in the Appcelerator app. What's the issue here? Tested this issue with the above environment. The issue was reproducible. Thanks.

Attachments

FileDateSize
IMG_0353.PNG2019-07-30T19:12:38.000+000029515

Comments

No comments

JSON Source