flutter_inappwebview icon indicating copy to clipboard operation
flutter_inappwebview copied to clipboard

Calling enumerateDevices() will always return null value for labels

Open wer-mathurin opened this issue 3 years ago • 2 comments

Environment

Technology Version
Flutter version 3.0.5
Plugin version ^5.4.3+7
Android version 12

Device information: Google Pixel 6 Pro

Description

When running this command when inspecting the webview (in the console) after giving all permissions need for WebRTC

await navigator.mediaDevices.enumerateDevices();

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.VIDEO_CAPTURE" />
<uses-permission android:name="android.permission.AUDIO_CAPTURE" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

Expected behavior: This is the result of calling await navigator.mediaDevices.enumerateDevices() in a normal chrome browswer. You can see there is 7 devices. image

Current behavior: This is the result of calling await navigator.mediaDevices.enumerateDevices() in a normal chrome browswer. You can see there is 6 devices. image

Note that the missing audioinput is the Bluetooth device and the labels are blank

Steps to reproduce

The code to test it.

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:permission_handler/permission_handler.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Permission.camera.request();
  await Permission.microphone.request();

  if (Platform.isAndroid) {
    await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);
  }

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Flutter Demo',
      home: WebRTCWebview(),
    );
  }
}

class WebRTCWebview extends StatelessWidget {
  const WebRTCWebview({super.key});

  @override
  Widget build(BuildContext context) {
    return InAppWebView(
      initialOptions: InAppWebViewGroupOptions(
        crossPlatform: InAppWebViewOptions(
          mediaPlaybackRequiresUserGesture: false,
        ),
      ),
      initialUrlRequest: URLRequest(
        url:
            Uri.parse('https://www.pubnub.com/developers/demos/webrtc/launch/'),
      ),
      androidOnPermissionRequest: (controller, origin, resources) async {
        return PermissionRequestResponse(
          resources: resources,
          action: PermissionRequestResponseAction.GRANT,
        );
      },
    );
  }
}
  1. Open the chrome://inspect/#devices
  2. Inspect the webview
  3. In the console run this command: await navigator.mediaDevices.enumerateDevices()
  4. Now connect your bluetooth device
  5. In the console run this command: await navigator.mediaDevices.enumerateDevices()

Stacktrace/Logcat

E/chromium( 8461): [ERROR:web_contents_delegate.cc(232)] WebContentsDelegate::CheckMediaAccessPermission: Not supported.

wer-mathurin avatar Jul 15 '22 19:07 wer-mathurin

👋 @wer-mathurin

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

github-actions[bot] avatar Jul 15 '22 19:07 github-actions[bot]

Im seeing this also, and i also have a pixel 6 pro, i checked it on a samsung s8 running android 10 and the issue is reproducible there too

martipello avatar Sep 03 '22 11:09 martipello

navigator.mediaDevices returns null for label as well.

hy-net avatar Nov 01 '22 08:11 hy-net

Same here

HoseinHaqiqian avatar Mar 02 '23 15:03 HoseinHaqiqian

Hi,

Did anyone find a way to solve that problem?

Muhammad-Mohsen avatar May 28 '23 20:05 Muhammad-Mohsen