Description
Hi,
We think there is a mistake in DefaultVideoTileController
which causes video bindings to fail under certain circumstances. This occurs when two participants in a video meeting swap their videos.
Description
Initial situation:
VideoRenderView
A showstileId
1VideoRenderView
B showstileId
2
Final situation (expected):
VideoRenderView
A showstileId
2VideoRenderView
B showstileId
1
Final situation (actual):
VideoRenderView
A shows frozentileId
1VideoRenderView
B showstileId
1
To Reproduce
Here are the steps to reproduce:
- Have two participants in a meeting
- Disable the video of the first participant then re-enable it
- Now proceed to swapping the tiles: bind the
VideoRenderView
of the second participant to the firsttileId
- Bind the
VideoRenderView
of the first participant to the secondtileId
The video of the second participant shows the old video and is frozen (binding didn't occur).
We did not try to reproduce it on the demo app because it means a bit of work for triggering the swap of videos. However I can upload a video recording of the bug occurring in our application if needed.
Explanation and probable solution
The problem is caused by step 2. When the video is disabled, DefaultVideoTileController::onRemoveVideoTile()
is invoked but does not remove the VideoRenderView
(let's call it X) from renderViewToBoundVideoTileMap
. Most likely a call to removeRenderViewFromBoundVideoTileMap(tileId)
is missing line 201.
Then when later re-enabling the video, a new VideoRenderView
is created (let's call it Y). Then, when swapping the videos, the following occurs:
DefaultVideoTileController::bindVideoView()
is invoked- The block checking whether a
VideoRenderView
is associated with a video tile is entered ("Override the binding from (…)") - A call is made to
removeRenderViewFromBoundVideoTileMap()
to remove theVideoRenderView
which is going to be replaced renderViewToBoundVideoTileMap.entries.firstOrNull
finds theVideoRenderView
X (which no more exists and should have been removed inonRemoveVideoTile()
) and removes it from the map instead of finding and removing Y (both have the savetileId
)- First video replaced the other, now
DefaultVideoTileController::bindVideoView()
is invoked a second time to swap the second video - The same block as in 2 is entered althought it should not because Y should have been removed from the map there but was not
- Again, call to
removeRenderViewFromBoundVideoTileMap()
which in turn callsvideoTile.unbind()
, unbinding the first video we swapped previously - Hence the video being frozen
We confirmed that by adding the missing call line 201 described above the bug goes away. This seems to be the right way of solving the issue, however we are not that familiar with the internals of Chime so maybe there is a better way.
Test environment Info
- Version amazon-chime-sdk: 0.17.4
- Version amazon-chime-sdk-media: 0.17.5
Additional info
This was not tested on iOS.