aws-samples / aws-samples/amazon-chime-react-native-demo

Screen Share(Content Share) showing black screen on receiver's end and the app crashes

Open
#178 10 comments 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
Objective-C
Stars
106
Forks
24
PR merge metrics
No merged PRs in 30d

Description

i was implementing the amazon chime sdk in react native by following this https://github.com/aws-samples/amazon-chime-react-native-demo#2-add-sdk-binaries-to-the-project. We were able to implement the sdk in android and was able to integrate video calling by joining the meeting session and following the steps mentioned in the shared link.

Problem: **Not able to StartScreenShare from the android phone(ios not yet implemented) but able to see the Shared Screen( shared from Browser) from the attendee and was visible on the videoTile(in the android phone). The app crashes by showing a black screen on the receiver's end(in this case the browser).**
```
val audioVideo: AudioVideoFacade = meetingSession!!.audioVideo
audioVideo.startContentShare(source)
// after reaching this line of code the black screen is seen on the recievers end and the android app crashes
```
**Here is the code that generated the problem:**

for permission// in android
```
val mediaProjectionManager = currentActivity?.getSystemService(Context.MEDIA_PROJECTION_SERVICE) as MediaProjectionManager
currentActivity?.startActivityForResult(
mediaProjectionManager.createScreenCaptureIntent(),
SCREEN_CAPTURE_REQUEST_CODE//1 in this case )


private val mActivityEventListener: ActivityEventListener =
object : BaseActivityEventListener() {
override fun onActivityResult(activity: Activity?, requestCode: Int, resultCode: Int, data: Intent?) {

if (SCREEN_CAPTURE_REQUEST_CODE == requestCode) {
if (resultCode != Activity.RESULT_OK) {
Toast.makeText(currentActivity!!.applicationContext, "Screen share cannot work without
permissions",Toast.LENGTH_LONG).show()
} else {
Toast.makeText(currentActivity!!.applicationContext, "ALL OK", Toast.LENGTH_LONG).show()
**//able to see the toast on the phone and after accepting the permission**
currentActivity?.startService(Intent(currentActivity, ScreenCaptureService::class.java)
data?.let { startScreenShare(resultCode, it, currentActivity!!) }

}

}
}
}

init {
reContext?.addActivityEventListener(mActivityEventListener)
}
```
**ScreenCaptureService and ScreenShareManager be downloaded from amazon chime git**
```
val eglCoreFactory: EglCoreFactory = DefaultEglCoreFactory()
private fun startScreenShare(resultCode: Int, data: Intent, context: Context) {
currentActivity!!.startService(Intent(currentActivity, ScreenCaptureService::class.java))
screenshareServiceConnection = object : ServiceConnection {
override fun onServiceConnected(className: ComponentName, service: IBinder) {

val screenCaptureSource = DefaultScreenCaptureSource(
context,
logger,
DefaultSurfaceTextureCaptureSourceFactory(
logger,
eglCoreFactory
),
resultCode,
data
)

val screenCaptureSourceObserver = object : CaptureSourceObserver {
override fun onCaptureStarted() {
logger.info("#############", "Screen capture has started")
screenShareManager?.let { source ->
val audioVideo: AudioVideoFacade = meetingSession!!.audioVideo
audioVideo.startContentShare(source)
}
}

override fun onCaptureStopped() {
// notifyHandler("Screen capture stopped")
}

override fun onCaptureFailed(error: CaptureSourceError) {
// notifyHandler("Screen capture failed with error $error")
meetingSession?.audioVideo?.stopContentShare()
}
}

screenShareManager = ScreenShareManager(screenCaptureSource, context)
screenShareManager?.screenCaptureConnectionService = screenshareServiceConnection
screenShareManager?.addObserver(screenCaptureSourceObserver)
screenShareManager?.start()
logger.info("#############", "Screen screenShareManager has started")

// currentActivity?.setScreenShareManager(screenShareManager)
}

override fun onServiceDisconnected(arg0: ComponentName) {
isBound = false
}
}

context.startService(
Intent(
context,
ScreenCaptureService::class.java
).also { intent ->
screenshareServiceConnection?.let {
context?.bindService(
intent,
it,
Context.BIND_AUTO_CREATE
)
}
})

}
```

Expected behaviour :
After accepting Screen Share permission the screen should be visible to the receiver's end

**Logs**
If applicable, add logs from logcat to help explain your problem.

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

**Test environment Info (please complete the following information):**
- Device: MI
- OS: Android pie(9)

- Version amazon-chime-sdk:0.17.5
- Version amazon-chime-sdk-media: 0.17.6
- Can you reproduce this in the demo app . Demo app does not have screen share

**LOGS SCREENSHOT**
![Screen Shot 2023-02-15 at 6 27 06 PM](https://user-images.githubusercontent.com/14231815/219033631-35c873e1-8bc9-4d97-947e-f6d931e60a09.png)
![Screen Shot 2023-02-15 at 6 27 21 PM](https://user-images.githubusercontent.com/14231815/219033659-4f8b75a6-0d33-4cc1-b5e2-830b050c51d2.png)
![Screen Shot 2023-02-15 at 6 26 31 PM](https://user-images.githubusercontent.com/14231815/219033668-4b87b37f-d2d3-4646-9a1c-1a8005979640.png)

here is a video of the same in android app.
https://user-images.githubusercontent.com/14231815/219036255-13c15866-7ba7-4346-9f0a-12bf5e1e53a1.mp4

kindly guide me through if am missing anything. thanks is advance

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.