浏览代码

Looks like the "A Native Collection hasn't been disposed" error at this point is only present due to use not disposing of the NetworkDriver when we're done with Relay.

/main/staging/more_minor_fixes
nathaniel.buck@unity3d.com 3 年前
当前提交
6346d43d
共有 4 个文件被更改,包括 13 次插入10 次删除
  1. 1
      Assets/Scripts/Relay/RelayUtpClient.cs
  2. 13
      Assets/Scripts/Relay/RelayUtpSetup.cs
  3. 7
      Assets/Scripts/Tests/PlayMode/LobbyRoundtripTests.cs
  4. 2
      Assets/Scripts/Tests/PlayMode/RelayRoundTripTests.cs

1
Assets/Scripts/Relay/RelayUtpClient.cs


m_localUser.onChanged -= OnLocalChange;
Leave();
Locator.Get.UpdateSlow.Unsubscribe(UpdateSlow);
m_networkDriver.Dispose();
}
public void OnDestroy()
{

13
Assets/Scripts/Relay/RelayUtpSetup.cs


}
}
#endregion
private void OnDestroy()
{
if (!m_isRelayConnected && m_networkDriver.IsCreated)
m_networkDriver.Dispose();
}
}
/// <summary>

}
else
{
RelayUtpClient watcher = gameObject.AddComponent<RelayUtpClient>();
watcher.Initialize(m_networkDriver, m_connections, m_localUser, m_localLobby);
m_onJoinComplete(true, watcher);
m_isRelayConnected = true;
RelayUtpClient client = gameObject.AddComponent<RelayUtpClient>();
client.Initialize(m_networkDriver, m_connections, m_localUser, m_localLobby);
m_onJoinComplete(true, client);
LobbyAsyncRequests.Instance.UpdatePlayerRelayInfoAsync(m_allocation.AllocationId.ToString(), m_localLobby.RelayCode, null);
}
}

7
Assets/Scripts/Tests/PlayMode/LobbyRoundtripTests.cs


using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Unity.Services.Lobbies;
using Unity.Services.Lobbies.Models;
using UnityEngine;

public void Teardown()
{
m_auth?.Dispose();
LogAssert.ignoreFailingMessages = false;
}
/// <summary>

public IEnumerator DoRoundtrip()
{
#region Setup
LogAssert.ignoreFailingMessages = true; // Not sure why, but when auth logs in, it sometimes generates an error: "A Native Collection has not been disposed[...]." We don't want this to cause test failures, since in practice it *seems* to not negatively impact behavior.
// Wait a reasonable amount of time for sign-in to complete.
if (!m_didSigninComplete)
yield return new WaitForSeconds(3);

// Some error messages might be asynchronous, so to reduce spillover into other tests, just wait here for a bit before proceeding.
yield return new WaitForSeconds(3);
LogAssert.ignoreFailingMessages = false;
}
/// <summary>

public IEnumerator OnCompletesOnFailure()
{
LogAssert.ignoreFailingMessages = true;
LogAssert.Expect(LogType.Exception, new Regex(".*400 Bad Request.*"));
if (!m_didSigninComplete)
yield return new WaitForSeconds(3);
if (!m_didSigninComplete)

2
Assets/Scripts/Tests/PlayMode/RelayRoundTripTests.cs


public void Teardown()
{
m_auth?.Dispose();
LogAssert.ignoreFailingMessages = false;
}
/// <summary>

[UnityTest]
public IEnumerator DoBaseRoundTrip()
{
LogAssert.ignoreFailingMessages = true;
if (!m_didSigninComplete)
yield return new WaitForSeconds(3);
if (!m_didSigninComplete)

正在加载...
取消
保存