Agora-Flutter-SDK icon indicating copy to clipboard operation
Agora-Flutter-SDK copied to clipboard

Apple M1 Chrome Screenshare Permission Denied

Open dbrezack opened this issue 3 years ago • 9 comments
trafficstars

Describe the bug Permission Denied On Chrome w/ Error: PlatformException(error, AgoraRTCError PERMISSION_DENIED: NotAllowedError: Permission denied by system, null, null)

Screen Recording IS Enabled. This feature IS working as expected on Firefox.

Please let me know if there is anything I can do to help ya'll further with this issue, I understand it may be a Chrome issue. Any ideas for how to test that ?

To Reproduce Steps to reproduce the behavior: Start a screenshare with the agora engine.

  engine!.startScreenCaptureByScreenRect(
    Rectangle( x: 0, y: 0, height: window.screen?.width, width: window.screen?.height)
  );

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • MacOS 12.1 (21C52) M1 Silicone.
  • Chrome Version 100.0.4896.127 (Official Build) (arm64)
  • Agora flutter SDK 5.1.0 - Agora flutter SDK 5.0.1 (Tested both versions)
  • Flutter 2.10.4

dbrezack avatar Apr 15 '22 13:04 dbrezack

have you granted the permission for chrome?

LichKing-2234 avatar Apr 24 '22 06:04 LichKing-2234

@LichKing-2234 Yes, also zoom and google hangouts both work on this particular chrome instance.

dbrezack avatar Apr 25 '22 19:04 dbrezack

Hello @dbrezack, I'm sorry that I can't reproduce this issue on my machine, I think a reproducible demo is helpful for this case.

littleGnAl avatar Apr 27 '22 03:04 littleGnAl

@littleGnAl This Gist is based off of the main flutter demo ya'll have. Should only have to edit the token and app id https://gist.github.com/dbrezack/1f4d6e686c9de924013da60174b7f74f

dbrezack avatar Apr 29 '22 15:04 dbrezack

May be related https://github.com/AgoraIO/Agora-Flutter-SDK/issues/669

dbrezack avatar Apr 29 '22 15:04 dbrezack

@dbrezack Hi Data, I'm hoping to address the sharing issue that you brought up on the call, regarding screensharing using our Flutter wrapper. This is based on the Agora Web 4.x SDK, which can only publish one videoTrack per client engine instance.

https://docs.agora.io/en/Video/screensharing_web_ng?platform=Web#enable-both-screen-sharing-and-video

There are two issues I see in the sample you've provided here:

https://gist.github.com/dbrezack/1f4d6e686c9de924013da60174b7f74f

The API you are calling is for sharing specific sections of the active display, and I'm pretty sure it's meant to only be used for Windows native SDK apps built via Flutter, not the Web SDK:

https://docs.agora.io/en/Video/API%20Reference/flutter/v5.1.0/API/class_irtcengine.html#api_startscreencapturebyscreenrect

In my testing, it's just invoking createScreenVideoTrack in the WebSDK in the background anyway, and not using any of the position parameters you are passing. createScreenVideoTrack is going to launch the built-in Chrome/FF screenshare extensions anyway, so you don't need to define an area to capture.

If you just want to share a display or window in Chrome/FF, and keep both the current camera streaming plus the share, you need to:

  1. Create an engine instance for the camera, enable video/set device/encoder, and join to the channel with a define or random UID.
  2. The local video stream will be published automatically due to enableVideo.
  3. Create a second engine object, or the ScreenShareHelper in the FlutterSDK (which is just a child process of the main engine), set that to invoke the Chrome/FF screenshare extension with .startScreenCaptureByWindowId(windowId), where windowId is 0 for WebSDK, and have that child object or second engine join the channel with a different or random UID. Both will publish their respective videotracks, and if the remote side is set up to render additional views as UserJoined callbacks occur, you'll see both the camera and share.

Try this to test:

Run this, just your original test modified: https://github.com/alekben/Agora_Flutter_ShareTest/blob/main/main.working.dart

On the other side, join to the same channel with the same token or another generated token for the same channel name (hardcoded as 'TEST' in the same):

https://webdemo.agora.io/basicVideoCall/index.html

Share from the flutter test, you should be able to start/stop share correctly as well.

Note that in the sample code, I've set the screenshare helper engine to join with a hardcoded UID of 10. This way, when the UserJoined callback sees 10 as the UID, it doesn't do anything and doesn't try to locally subscriber to the track you are already pushing. If it's necessary for the user sharing to see their own share in the UI, that can be done by playing the localtrack in a view, without subscribing to the track/user looping back from Agora.

alekben avatar May 04 '22 16:05 alekben

Is it possible to switch video track if I wanted only one output ?

dbrezack avatar May 05 '22 17:05 dbrezack

@dbrezack The Flutter SDK doesn't give you fine control over what the WebSDK actually ends up doing, so you don't have direct control of WebRTC tracks, but it's easy enough to stick with the two engines, one for local video device capture, one for local screen/window capture, and just enableLocalVideo(false) on the main engine when starting the screenshare.

See this modified version:

https://github.com/alekben/Agora_Flutter_ShareTest/blob/main/main.shareonly.dart

This will end up with only the shared content sent to into the channel when sharing is started, and switches back to the local device when sharing is ended.

This is a quick and dirty way to do this, it could use some tuning and optimization.

If you haven't seen the Flutter examples, you can find them here, they are a good reference for making one codebase work across all of the platforms:

https://github.com/AgoraIO/Agora-Flutter-SDK/tree/master/example

alekben avatar May 06 '22 14:05 alekben

This solution does work pretty well. I just implemented it. There still seems to be some issues sharing the actual window (Screen recording is enabled). Tabs work fine. I'll find some time to test out 5.1.1 since it upgraded the WebRTC Sdk and report my findings

dbrezack avatar May 17 '22 20:05 dbrezack

The web support for agora_rtc_engine 6.x has landed in the main branch, If you still face issues, please try the latest code in main branch to see if it works or not.

littleGnAl avatar Nov 14 '23 08:11 littleGnAl

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

github-actions[bot] avatar Nov 28 '23 09:11 github-actions[bot]

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please raise a new issue.

github-actions[bot] avatar Dec 05 '23 10:12 github-actions[bot]