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

A React Native demo application for Android and iOS using the Amazon Chime SDK.
MIT No Attribution
100 stars 24 forks source link

Some Video tiles randomly freeze #200

Closed AbhishekSri979 closed 3 months ago

AbhishekSri979 commented 8 months ago

useCase: If we join more meeting with more than 2 or 3 devices then video tiles get freeze automatically and sometime video tiles get blank.

can someone please help me, because i got stuck and i didn't find any solution for freezing video.

environment: react-native:"0.71.10" aws-chime-sdk:"0.18.2"

ashirkhan94 commented 8 months ago

Hi @AbhishekSri979 Pls see the comments https://github.com/aws-samples/amazon-chime-react-native-demo/issues/195#issuecomment-1711360513 It may help you. we have faced the same issue before Thanks

AbhishekSri979 commented 8 months ago

Hi @ashirkhan94

i checked this https://github.com/aws-samples/amazon-chime-react-native-demo/issues/195, and implemented as per comments but i am getting below error, also when i calling setPauseTile and setResumeTile function then nothing happening, so can you suggest me what i missing

IMG_8040A3759902-1

Below are the implemented code

For IOS: In MeetingObserver.m file

In NativeMobileSDKBridge.m RCT_EXPORT_METHOD(setPauseTile:(NSNumber * _Nonnull)tileId) { [meetingSession.audioVideo pauseRemoteVideoTileWithTileId:[tileId integerValue]]; }

RCT_EXPORT_METHOD(setResumeTile:(NSNumber * _Nonnull)tileId) { [meetingSession.audioVideo resumeRemoteVideoTileWithTileId:[tileId integerValue]]; }

For Android: in MeetingObserver.kt override fun onVideoTilePaused(tileState: VideoTileState) { // Not implemented for demo purposes logger.info(TAG, "Received event for VideoTilePaused: $tileState") eventEmitter.sendVideoTileEvent(RN_EVENT_VIDEO_TILE_PAUSED, tileState) } override fun onVideoTileResumed(tileState: VideoTileState) { // Not implemented for demo purposes logger.info(TAG, "Received event for VideoTileResumed: $tileState") eventEmitter.sendVideoTileEvent(RN_EVENT_VIDEO_TILE_RESUME, tileState) }

in NativeMobileSDKBridge.kt @ReactMethod fun setPauseTile(tileId: Int) { logger.info(TAG, "setPauseTile: $tileId") meetingSession?.run { audioVideo.pauseRemoteVideoTile(tileId) } } @ReactMethod fun setResumeTile(tileId: Int) { logger.info(TAG, "setResumeTile: $tileId") meetingSession?.run { audioVideo.resumeRemoteVideoTile(tileId) } }

in recat native side

const onPauseVideotileSubscription = () => getSDKEventEmitter().addListener( "OnPauseVideoTile", async (data) => { console.log('onPauseVideotileSubscription', data); // if (tileState.pauseState == 2) { // console.log("Video was paused due to a poor network connection") // } } );

const onResumeVideotileSubscription = () =>
    getSDKEventEmitter().addListener(
       "OnResumeVideoTile",
        async (data) => {
            console.log('onResumeVideotileSubscription', data);
        }
    );
AbhishekSri979 commented 8 months ago

@ashirkhan94

Also my internet connectivity is fine, so why video tiles is freezing or blank out, if there any other approach to fix this then please suggest me.

ashirkhan94 commented 8 months ago

Hi @AbhishekSri979 I think you may check the cause of video freeze by checking the value of tileState.pauseState

ashirkhan94 commented 8 months ago

setPauseTile

You need to Change Bridge.js like

export const MobileSDKEvent = {
  OnMeetingStart: 'OnMeetingStart',
  OnMeetingEnd: 'OnMeetingEnd',
  -----------
  -----------
  OnPauseVideoTile: 'OnPauseVideoTile',
  OnResumeVideoTile: 'OnResumeVideoTile',

for Ios meetingObserver.h

//need to define OnPauseVideoTile and OnResumeVideoTile here like

#define kEventOnMeetingStart @"OnMeetingStart"
#define kEventOnMeetingEnd @"OnMeetingEnd"
.
.
#define KEventonOnPauseVideoTile @"OnPauseVideoTile"
#define KEventOnResumeVideoTile @"OnResumeVideoTile"

in NativeMobileSDKBridge.m need to add KEventonOnPauseVideoTile and KEventOnResumeVideoTile here

- (NSArray<NSString *> *)supportedEvents
{
  return
  @[
    kEventOnMeetingStart,
    kEventOnMeetingEnd,
    .
    .
    KEventonOnPauseVideoTile,
    KEventOnResumeVideoTile,
    .
    .
    kEventOnError  
  ];
}

For Android need to change RNEventEmitter.kt file like

class RNEventEmitter(private val reactContext: ReactApplicationContext) {
    companion object {
        // Event types
        const val RN_EVENT_ERROR = "OnError"
        const val RN_EVENT_MEETING_START = "OnMeetingStart"

        const val RN_EVENT_VIDEO_TILE_PAUSED = "OnPauseVideoTile"
        const val RN_EVENT_VIDEO_TILE_RESUME = "OnResumeVideoTile"
AbhishekSri979 commented 8 months ago

@ashirkhan94 yes i am already doing this

ashirkhan94 commented 8 months ago

@AbhishekSri979 For me its working

AbhishekSri979 commented 8 months ago

ok thanks @ashirkhan94, i will check again

ashirkhan94 commented 8 months ago

@AbhishekSri979 In android MeetingObservers.kt file

import com.amazonaws.services.chime.RNDemo.RNEventEmitter.Companion.RN_EVENT_VIDEO_TILE_PAUSED
import com.amazonaws.services.chime.RNDemo.RNEventEmitter.Companion.RN_EVENT_VIDEO_TILE_RESUME

need to import above lines for pause and resume events

AbhishekSri979 commented 8 months ago

yes @ashirkhan94 i implemented all above code.

ashirkhan94 commented 8 months ago

Hi @ashirkhan94

i checked this #195, and implemented as per comments but i am getting below error, also when i calling setPauseTile and setResumeTile function then nothing happening, so can you suggest me what i missing

IMG_8040A3759902-1

Below are the implemented code

For IOS: In MeetingObserver.m file

  • (void)videoTileDidPauseWithTileState:(VideoTileState * _Nonnull)tileState { // Not implemented for demo purposes [_bridge sendEventWithName:KEventonOnPauseVideoTile body:@{@"tileId":[NSNumber numberWithInt: (int)tileState.tileId],@"attendeeId":[tileState attendeeId], @"isLocal":@(tileState.isLocalTile), @"isScreenShare":@(tileState.isContent),@"pauseState":@(tileState.pauseState)}]; }
  • (void)videoTileDidResumeWithTileState:(VideoTileState * _Nonnull)tileState { // Not implemented for demo purposes [_bridge sendEventWithName: KEventOnResumeVideoTile body:@{@"tileId":[NSNumber numberWithInt: (int)tileState.tileId], @"attendeeId":[tileState attendeeId], @"isLocal":@(tileState.isLocalTile), @"isScreenShare":@(tileState.isContent), @"pauseState":@(tileState.pauseState)}]; }

In NativeMobileSDKBridge.m RCT_EXPORT_METHOD(setPauseTile:(NSNumber * _Nonnull)tileId) { [meetingSession.audioVideo pauseRemoteVideoTileWithTileId:[tileId integerValue]]; }

RCT_EXPORT_METHOD(setResumeTile:(NSNumber * _Nonnull)tileId) { [meetingSession.audioVideo resumeRemoteVideoTileWithTileId:[tileId integerValue]]; }

For Android: in MeetingObserver.kt override fun onVideoTilePaused(tileState: VideoTileState) { // Not implemented for demo purposes logger.info(TAG, "Received event for VideoTilePaused: $tileState") eventEmitter.sendVideoTileEvent(RN_EVENT_VIDEO_TILE_PAUSED, tileState) } override fun onVideoTileResumed(tileState: VideoTileState) { // Not implemented for demo purposes logger.info(TAG, "Received event for VideoTileResumed: $tileState") eventEmitter.sendVideoTileEvent(RN_EVENT_VIDEO_TILE_RESUME, tileState) }

in NativeMobileSDKBridge.kt @ReactMethod fun setPauseTile(tileId: Int) { logger.info(TAG, "setPauseTile: $tileId") meetingSession?.run { audioVideo.pauseRemoteVideoTile(tileId) } } @ReactMethod fun setResumeTile(tileId: Int) { logger.info(TAG, "setResumeTile: $tileId") meetingSession?.run { audioVideo.resumeRemoteVideoTile(tileId) } }

in recat native side

const onPauseVideotileSubscription = () => getSDKEventEmitter().addListener( "OnPauseVideoTile", async (data) => { console.log('onPauseVideotileSubscription', data); // if (tileState.pauseState == 2) { // console.log("Video was paused due to a poor network connection") // } } );

const onResumeVideotileSubscription = () =>
    getSDKEventEmitter().addListener(
       "OnResumeVideoTile",
        async (data) => {
            console.log('onResumeVideotileSubscription', data);
        }
    );

@AbhishekSri979 Does the error still exist?

AbhishekSri979 commented 8 months ago

Hi @ashirkhan94 i checked this #195, and implemented as per comments but i am getting below error, also when i calling setPauseTile and setResumeTile function then nothing happening, so can you suggest me what i missing IMG_8040A3759902-1 Below are the implemented code For IOS: In MeetingObserver.m file

  • (void)videoTileDidPauseWithTileState:(VideoTileState * _Nonnull)tileState { // Not implemented for demo purposes [_bridge sendEventWithName:KEventonOnPauseVideoTile body:@{@"tileId":[NSNumber numberWithInt: (int)tileState.tileId],@"attendeeId":[tileState attendeeId], @"isLocal":@(tileState.isLocalTile), @"isScreenShare":@(tileState.isContent),@"pauseState":@(tileState.pauseState)}]; }
  • (void)videoTileDidResumeWithTileState:(VideoTileState * _Nonnull)tileState { // Not implemented for demo purposes [_bridge sendEventWithName: KEventOnResumeVideoTile body:@{@"tileId":[NSNumber numberWithInt: (int)tileState.tileId], @"attendeeId":[tileState attendeeId], @"isLocal":@(tileState.isLocalTile), @"isScreenShare":@(tileState.isContent), @"pauseState":@(tileState.pauseState)}]; }

In NativeMobileSDKBridge.m RCT_EXPORT_METHOD(setPauseTile:(NSNumber _Nonnull)tileId) { [meetingSession.audioVideo pauseRemoteVideoTileWithTileId:[tileId integerValue]]; } RCT_EXPORT_METHOD(setResumeTile:(NSNumber _Nonnull)tileId) { [meetingSession.audioVideo resumeRemoteVideoTileWithTileId:[tileId integerValue]]; } For Android: in MeetingObserver.kt override fun onVideoTilePaused(tileState: VideoTileState) { // Not implemented for demo purposes logger.info(TAG, "Received event for VideoTilePaused: $tileState") eventEmitter.sendVideoTileEvent(RN_EVENT_VIDEO_TILE_PAUSED, tileState) } override fun onVideoTileResumed(tileState: VideoTileState) { // Not implemented for demo purposes logger.info(TAG, "Received event for VideoTileResumed: $tileState") eventEmitter.sendVideoTileEvent(RN_EVENT_VIDEO_TILE_RESUME, tileState) } in NativeMobileSDKBridge.kt @ReactMethod fun setPauseTile(tileId: Int) { logger.info(TAG, "setPauseTile: $tileId") meetingSession?.run { audioVideo.pauseRemoteVideoTile(tileId) } } @ReactMethod fun setResumeTile(tileId: Int) { logger.info(TAG, "setResumeTile: $tileId") meetingSession?.run { audioVideo.resumeRemoteVideoTile(tileId) } } in recat native side const onPauseVideotileSubscription = () => getSDKEventEmitter().addListener( "OnPauseVideoTile", async (data) => { console.log('onPauseVideotileSubscription', data); // if (tileState.pauseState == 2) { // console.log("Video was paused due to a poor network connection") // } } );

const onResumeVideotileSubscription = () =>
    getSDKEventEmitter().addListener(
       "OnResumeVideoTile",
        async (data) => {
            console.log('onResumeVideotileSubscription', data);
        }
    );

@AbhishekSri979 Does the error still exist?

AbhishekSri979 commented 8 months ago

hi @ashirkhan94

i checked my code again , and all required code are exist but still not working , listener is not calling and in ios crash is appearing

AbhishekSri979 commented 8 months ago

Hii @ashirkhan94

onPause and onResume listener are calling now.

i am explaining what issue i am facing

can you please suggest me ? whenever i got pauseState value 2, then my video tile getting freeze or blank so at that time what should i do ?

below is the ui for video meeting

Screenshot 2023-10-26 at 9 24 00 PM

i thought after calling setResume method video tile will resume but not working.

whenever i will get pauseState value 2 in any of the video tile then what should i do in that case ?

or is there any way to reduce the video quality ?

Thanks

stale[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.