question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Screen sharing showing black screen for local video on iOS

See original GitHub issue

Expected behavior

The screen share i.e getDisplayMedia() should work as working on android i.e show the local screen

Observerd behavior

The screen sharing is not working on ios no matter real device or simulator, but works fine for the same code on android

Steps to reproduce the problem

create a dummy react native project, install the latest react native webrtc library and replace the app.js code with the code below

import React, {useState} from 'react';
import {
  SafeAreaView,
  StatusBar,
  Text,
  NativeModules,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import {
  RTCView,
  mediaDevices,
} from 'react-native-webrtc';

 const { ScreenShareFile } = NativeModules;

const App = () => {
  const [stream, setstream] = useState(undefined);
  
  const startShare = async () => {
    mediaDevices
      .getDisplayMedia({video: true})
      .then(handleSuccess, handleError);
  };

  const stopShare = async () => {
    mediaDevices.stopShare();
  };

  const handleError = (error) => {
    console.log("Error",error)
  };

  const handleSuccess = async stream => {
    setstream(stream);
  };

  const backgroundStyle = {
    backgroundColor: Colors.lighter,
    flex:1
  };

  return (
    <SafeAreaView style={backgroundStyle}>
      <StatusBar barStyle={'dark-content'} />

      <Text
        onPress={() => {
          startShare();
        }}
        style={{textAlign: 'center', width: '100%', marginVertical: 20}}>
        Press me to start sharing
      </Text>
      {stream && (
        <RTCView
          style={{
            borderColor: '#000',
            borderWidth: 1,
            width: '80%',
            height: '80%',
          }}
          streamURL={stream?.toURL()}
        />
      )}
      <Text
        onPress={() => {
          stopShare();
        }}
        style={{textAlign: 'center', width: '100%', marginVertical: 20}}>
        Press me to stop sharing
      </Text>
    </SafeAreaView>
  );
};

export default App;

Now run the app on iOS and click start recording, no pop up to start broad cast is shown and also, the screen or RTCView is black in color.

Please let me know if I have to do some extra setting to have this working in iOS. As of now, I just want to show the iOS local video only !

Platform information

iOS Real device

  • React Native version: 0.65.1
  • Plugin version: 1.92.1
  • OS: iOS
  • OS version: 14.3

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:49 (20 by maintainers)

github_iconTop GitHub Comments

1reaction
saghulcommented, Mar 14, 2022

You can do this: https://github.com/jitsi/jitsi-meet/blob/d651ecb166fdd5b3914614b2be2a183876496e64/react/features/toolbox/components/native/ScreenSharingIosButton.js#L86

Create your own button, and when the user taps it do the same thing we do to show the system picker.

1reaction
saghulcommented, Feb 17, 2022

Yes and yes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Share screen is blank - iPhone - Apple Support Communities
Share screen is blank. I'm currently using iPhone 11 Pro with iOS 13.5.1 and when I'm trying to share a picture or a...
Read more >
Black screen appears on the display when screen sharing ...
A black screen appears on the display when using SMART Screen Share app for iOS to share an iOS device's screen. Symptoms. Cause....
Read more >
Black Screen when receive screen sharing - iOS
Host tap on start video and then stop video; Host tap on start share screen. See black screen on my app. Smartphone (please...
Read more >
iOS 15 / Safari - MediaStream not playing/black screen
Tried and this does not work, I am using the <video> which works fine for my local media stream. To clarify I am...
Read more >
How to fix Discord black screen when sharing your ... - YouTube
Video showing how to fix Discord black screen when sharing your screen on Mac.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found