microsoft / OpenXR-Unity-MixedReality-Samples

Sample Unity projects to demo how to use OpenXR plugin in Unity for HoloLens 2 and Mixed Reality headsets
MIT License
250 stars 71 forks source link

AppRemoting: DisconnectReason not getting reported #153

Closed zenorbi closed 1 year ago

zenorbi commented 1 year ago

We are using the AppRemoting.StartConnectingToPlayer to connect Unity to Hololens but when there is an error the AppRemoting.Disconnecting always reports DisconnectReason.None.

I believe the issue is that AppRemotingSubsystem.OnSessionLossPending calls TryGetConnectionState and thus "consumes" the disconnect reason, so when later the AppRemotingSubsystem.ConnectRoutine calls TryGetConnectionState it doesn't get the reason.

I have verified this with a debugger. The AppRemotingSubsystem.OnSessionLossPending does get the correct disconnect reason.

yl-msft commented 1 year ago

Thanks for reporting. I'm pinging back to the feature team to investigate this issue.

satyapoojasama commented 1 year ago

Hi @zenorbi,

Unfortunately, I am unable to repro this issue on the latest BasicSample in this repo. Can you provide more details on what kind of error you are referring to before disconnecting?

Also, I am not sure how using "TryGetConnectionState" twice will hinder getting disconnecting reason. Could you please share some Unity Player Log for us to debug further?

zenorbi commented 1 year ago

Hi @satyapoojasama,

Thank you for looking into this. I cloned this repo and opened the RemotingSample project in Unity 2020.3.43f1 as indicated by the ProjectVersion.txt. All I did is that I added Debug.Log($"DISCONNECT REASON: {disconnectReason}"); to this method: https://github.com/microsoft/OpenXR-Unity-MixedReality-Samples/blob/666f809b418b8c84fd17e5d00589708c014d76a6/SampleShared/Samples/AppRemoting/Scripts/AppRemotingSample.cs#L234

I then entered play mode and tried to connect to an unused IP address. The log I received was:

DISCONNECT REASON: None

Editor.log

I would expect a HandshakeUnreachable, the same as what the AppRemotingSubsystem receives.

image

Interestingly if I build this project, I never even receive an OnDisconnecting callback in the player.

satyapoojasama commented 1 year ago

Thank you for providing the logs and details @zenorbi. I suspect you might have some misconceptions here. May I confirm your work flow? Are you using "Holographic Remoting for Play Mode" feature where you connect to the player app from Unity editor? In that case the OnDisconnecting() event will never be received. If you refer to the documentation of this feature here, it clearly states that this works only when "Holographic Remoting remote app" feature in OpenXR project settings is enabled. You may also refer to this documentation here to gain more clarity on Appremoting API behavior in different configurations.

zenorbi commented 1 year ago

@satyapoojasama Thank you for checking it. No I am not using "Holographic Remoting for Play Mode", I have left every setting as is defined in this project (using "Holographic Remoting remote app") and I am using the UGUI interface provided in the project to enter the IP address and all.

In our application this remoting used to work fine for many months and after a mixed reality upgrade where we had to switch over from checking the connection state every frame to the new event driven system, we have lost the DisconnectReason and the system always reports None as the reason.

zenorbi commented 1 year ago

Here is a video where I reproduce this issue on a fresh git clone:

https://github.com/microsoft/OpenXR-Unity-MixedReality-Samples/assets/313625/451c3d9a-07c6-443f-9175-9fa79d57bc1e

satyapoojasama commented 1 year ago

Wonderful, thank you for the video. Looks like something might have regressed. Your set up looks right.

satyapoojasama commented 1 year ago

Hi @zenorbi, we are actively working on fixing the bug and will update you once the fix makes to the release. Thank you for finding this.

satyapoojasama commented 1 year ago

Hi @zenorbi , we fixed this issue and it will be available in the next release of our plugin. Thank you.

satyapoojasama commented 1 year ago

1.9 release is now out. Please update to get the fix for this bug.