UnityRenderStreaming icon indicating copy to clipboard operation
UnityRenderStreaming copied to clipboard

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

Open akcastelino opened this issue 3 years ago • 1 comments

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:
  • Signalling Type: WebSocketSignalling
  • Signalling URL: ws://{PC1's ipv4 address}
  • Remove the Broadcast handler and add the SingleConnection handler in the List of Handlers
  • Set 'Run On Awake' to True

On PC2 in the same local network:

  1. Open Unity with the receiver sample.
  2. In the RenderStreaming component make the following changes:
  • Signalling Type: WebSocketSignalling
  • Signalling URL: ws://{PC1's ipv4 address}
  • Set 'Run On Awake' to True

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

akcastelino avatar Jun 12 '22 19:06 akcastelino

memo: URS-458

karasusan avatar Jun 14 '22 03:06 karasusan