Closed GabeBigBoxVR closed 7 years ago
Hi Gabe,
Do you get this same error when running the HLAPI demo scene? That also uses triggers on the player prefab, so it sounds like it ought to suffer from the same problem.
The first error is coming from inside this try
block in BaseClient:
try
{
//Update components
_serverNegotiator.Update();
_sendQueue.Update();
_voiceReceiver.Update();
//Poll network layer for more packets
ReadMessages();
return ClientStatus.Ok;
}
Would you mind drilling into this and finding what the null reference is? If you're not sure how to do that just comment out the following lines and it'll give me a good hint:
//try
//return ClientStatus.Ok;
//catch (Exception e)
//Log.Error(e.Message);
//return ClientStatus.Error;
//finally
// at the end of the method, add in
return ClientStatus.Ok;
Make sure to add the lines back in afterwards!
The second error looks like something that has already been fixed in the dev branch. Once we've tracked down the first error I can send you a new package with that fix included :)
I'm not at the office yet, but I'll check the demo scene to see if it repro's in there.
I tracked down the null reference last night and it's coming from the HLAPIClient in ReadMessages(). In the first frame of a newly loaded scene, the connection property on NetworkHost.singleton.client.connection is null. (or something like that, I'm recalling from memory until I get into the office) After the the first frame, the property has a value.
HlapiClient.cs line 95. Connection is null for the first frame only.
if (!NetworkManager.singleton.client.connection.SendBytes(_sendWriter.AsArray(), length, channel))
We also just tested the HLAPI demo scene and it does work. I suspect there's something going on with our setup.
HlapiClient.cs line 95. Connection is null for the first frame only.
That's odd - that code doesn't run until NetworkClient.active
is true which I would expect to indicate a non null connection! You could explicitly check for this case, in HlapiCommsNetwork:Update there's a check which starts the Dissonance client/server when the HLAPI client/server are ready.
if (IsInitialized)
{
var networkActive = NetworkManager.singleton.isNetworkActive && (NetworkServer.active || NetworkClient.active);
if (networkActive)
{
//setup stuff
}
}
You could add another check in there to ensure that the connection is not null:
var networkActive = NetworkManager.singleton.isNetworkActive && (NetworkServer.active || NetworkClient.active) && (!NetworkClient.active || (NetworkManager.singleton.client != null && NetworkManager.singleton.client.connection != null));
This will delay Dissonance startup until the connection is not null (but only if the client is active). If that works for you I'll include it in the next Dissonance version.
I suspect there's something going on with our setup.
It's intended to be very forgiving of slightly wrong setups - for example the check I referenced above means it doesn't care if it's active before a network session even exists - it just waits until HLAPI is ready. Even if you have set up something very wrong I'd still like for Dissonance to detect that and print a more useful message than a null reference exception!
Hey Martin,
I sorted it out, it looks like my setup had multiple room triggers in the scene. After removing those it appears to be working properly, but we still get those exceptions but at least audio is now playing.
I'm going to add a null check on the connection and to have it return true if the connection is null as per a setup. Then after that it should be good.
it looks like my setup had multiple room triggers in the scene
Multiple room triggers is totally fine! You can have as many room triggers as you like - that's totally expected (e.g. one global, one per team, one proximity per player).
I'm going to add a null check on the connection
Do you mean the var networkActive = ...
check I suggested above? If not, did you try that and did it work?
I didn't try the networkActive check since we got it working shortly after we got it setup. Once you have a dev build, let me know as I'd love to try it.
On Wed, Aug 30, 2017 at 12:51 PM, Martin Evans notifications@github.com wrote:
it looks like my setup had multiple room triggers in the scene
Multiple room triggers is totally fine! You can have as many room triggers as you like - that's totally expected (e.g. one global, one per team, one proximity per player).
I'm going to add a null check on the connection
Do you mean the var networkActive = ... check I suggested above? If not, did you try that and did it work?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/48#issuecomment-326099957, or mute the thread https://github.com/notifications/unsubscribe-auth/AVWK_n-M9wNYMXhzlm7Z8abDbq_IP4Cdks5sdb1CgaJpZM4PFR1V .
I've already got a change merged into the dev branch so I can send you a build right now if you'd like - just send me your order number.
Out of interest what change did you make to fix this yourself?
Just did a null check and returned true until it was non-null.
On Tue, Sep 5, 2017 at 4:19 PM, Martin Evans notifications@github.com wrote:
I've already got a change merged into the dev branch so I can send you a build right now if you'd like - just send me //martin@placeholder-software.co.uk your order number.
Out of interest what change did you make to fix this yourself?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Placeholder-Software/Dissonance/issues/48#issuecomment-327329974, or mute the thread https://github.com/notifications/unsubscribe-auth/AVWK_q7sK14u6J870rrRGaqDbxg8dPIOks5sfdcCgaJpZM4PFR1V .
Dissonance 3.0.1 has just released on the Unity asset store, this includes the changes made to resolve this issue so I'll close it now. If the problem persists please feel free to continue posting in this thread. If you're happy with how this issue was handled please consider rating and reviewing us on the asset store!
Context
I'm using the HLAPI setup in Unity 2017.1.0p4 and i'm getting exceptions when a client tries to join the game that is being self-hosted on another computer.
Screenshot of Log: http://imgur.com/a/MSoYU
[Dissonance:Network] HlapiClient: Object reference not set to an instance of an object
Exception in OnStartClient:An element with the same key already exists in the dictionary.
Expected Behavior
Shouldn't see an exception when connecting
Actual Behavior
Exception
Steps to Reproduce
We're using the stock settings that were in the tutorial, channels 0 and 1 for comms.
Verify: Error occurs
Your Environment
Dissonance version used: v3.0.0
Unity version: Unity 2017.1.0p4
Editor Operating System and version: Microsoft Windows 10
Build Settings: Windows, x86_64, In Editor