Unity-Technologies / UnityRenderStreaming

Streaming server for Unity
Other
1.31k stars 362 forks source link

[BUG]: Single connection with an input receiver stream doesn't receive data if it connects after a single connection with an input sender stream #700

Open akcastelino opened 2 years ago

akcastelino commented 2 years ago

Package version

3.1.0-exp.3

Environment

* OS: Windows 10 and 11
* Unity version: 2020.3.31
* Graphics API: DirectX11

Steps To Reproduce

On PC1 in a local network:

  1. Run webserver with command .\webserver -w in powershell
  2. In Unity, open the 'Broadcast sample' scene.
  3. In the RenderStreaming gameobject, add a SingleConnection component.
  4. Create a script called SingleConnectionSample with following code and add it as a component on the RenderStreaming gameobject. ( It's basically the 'BroadcastSample' script adapted for single connection with a connection created over a connection ID)

SingleConnectionSample

{

    [SerializeField] RenderStreaming renderStreaming;
    [SerializeField] InputReceiver inputReceiver;
    [SerializeField] VideoStreamSender videoStreamSender;
    private SingleConnection _singleConnection;
    private string _connectionID = "111";

    private void Awake()
    {
        _singleConnection = GetComponent<SingleConnection>();
        _singleConnection.CreateConnection(_connectionID);

        #if URS_USE_AR_FOUNDATION
            InputSystem.RegisterLayout<UnityEngine.XR.ARSubsystems.HandheldARInputDevice>(
                matches: new InputDeviceMatcher()
                    .WithInterface(XRUtilities.InterfaceMatchAnyVersion)
                );
        #endif
    }

    void Start()
    {
        if (renderStreaming.runOnAwake)
            return;
        renderStreaming.Run(
            hardwareEncoder: RenderStreamingSettings.EnableHWCodec,
            signaling: RenderStreamingSettings.Signaling);

        inputReceiver.OnStartedChannel += OnStartedChannel;
    }

    void OnStartedChannel(string connectionId)
    {
        inputReceiver.SetInputRange(videoStreamSender.streamingSize);
        inputReceiver.SetEnableInputPositionCorrection(true);
    }

    private void OnDestroy()
    {
        if (_singleConnection)
            _singleConnection.DeleteConnection("111");
    }
}
  1. In the RenderStreaming component make the following changes:

On PC2 in the same local network:

  1. Open Unity with the receiver sample.
  2. In the RenderStreaming component make the following changes:

3.Press Play, enter ID 111 and press Start.

Back again on PC 1

  1. Press Play

Current Behavior

When PC2( Single connection input sender) connects first and PC1(Single connection input receiver ) connects second, input data is not received by the Input Receiver

Only if PC1(Single connection input receiver ) connects first and PC2 ( Single connection input sender) connects second, then only does the input receiver receive input data.

Expected Behavior

Input Receiver ( single connection ) receives data from an input sender (single connection) irrespective of which one connects first.

Anything else?

No response

karasusan commented 2 years ago

memo: URS-458