UnityRenderStreaming
UnityRenderStreaming copied to clipboard
[BUG]: Screen is flipped vertically and Datachannel dead when close up one of multi-tabs
Package version
3.1.0-exp.6
Environment
* OS: Debian 11
* Unity version:2022.2.2f1c1
* Graphics API: OpenGL
* Browser: FireFox
Steps To Reproduce
- Running broadcast sample on debian 11
- Open multiple tabs(>1) on browser
- Close one of tabs
Current Behavior
- Observing screen is flipped vertically
- Do not receive any mouse and keyboard event
Expected Behavior
screen and user interface all going well
Anything else?
Actually I have find the reason by debugging. BroadCast.Disconnect() will be called when close a tab, then following functions RemoveSender and RemoveChannel are called subsequently.
private void Disconnect(string connectionId)
{
if (!connectionIds.Contains(connectionId))
return;
connectionIds.Remove(connectionId);
foreach (var sender in streams.OfType<IStreamSender>())
{
RemoveSender(connectionId, sender); // Cause problem 1
}
foreach (var receiver in streams.OfType<IStreamReceiver>())
{
RemoveReceiver(connectionId, receiver);
}
foreach (var channel in streams.OfType<IDataChannel>())
{
RemoveChannel(connectionId, channel); // Cause problem 2
}
}
-
RemoveSender lead to call Dispose() in VideoStreamSourceScreen, then m_screenCopyTexture will be destroyed
which is the reference to sourceTexture_ in VideoTrackSource
so the sourceTexture_ is null and Graphics.Blit will copy a correct screen texture to upside down.
-
As for RemoveChannel, I think there is already a commit to fix it: https://github.com/Unity-Technologies/UnityRenderStreaming/pull/925
@lyclyc171 yeah i had this problem long time ago, and i think it was because of this RemoveSender method in SignalingHandlerBase which was probably removing the track for that one user, then recreating a new track which wrongfully flips the texture again for the other users. So I commented it out:
and i also updated the SetTransceiver method in StreamSenderBase too
Now, this might get things working for you, but I'm not fully sure if I'm fully cleaning up everything memory-wise, so insights here would be appreciated.
@lyclyc171 How about the google chrome?
@JohnnyNgo Is this issue already fixed by #925 ?
@karasusan I'm using Render Streaming 3.1.0-exp.6 for reference, so I don't think I have tried that solution. I never had the issue of inputs or resolution changes as mentioned in #925, probably because I don't use Broadcast.cs (I made my own custom script to handle removing/adding senders/channels to each users)
So I'd say my solution here is more specific to the Vertical Flipping part and is not already fixed.
@lyclyc171 How about the google chrome?
No, it doesn't work
@lyclyc171 yeah i had this problem long time ago, and i think it was because of this RemoveSender method in SignalingHandlerBase which was probably removing the track for that one user, then recreating a new track which wrongfully flips the texture again for the other users. So I commented it out:
and i also updated the SetTransceiver method in StreamSenderBase too
Now, this might get things working for you, but I'm not fully sure if I'm fully cleaning up everything memory-wise, so insights here would be appreciated.
@JohnnyNgo Does the screen image turn to normal after you comment out "RemoveTrack"? Actually my debugging result tell me "OnStroppedStream" ( in your second pic ) is the reason who calls Dispose().
Anyway, thanks for your clue, I will try to comment RemoveTrack out to check result.
memo: URS-624
Hey I have a similar issue in 3.1.0-exp.7. When I have multiple tabs open and close one the image for the others is distorted.
Just changing the SetTransceiver method to how @JohnnyNgo commented
seems to fix it for me. (Or just never calling RemoveSender to begin with)
Are there already plans to implement this or sth similar @karasusan and if yes do you know when this might happen?