Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Assets/Tests/PlayMode/Services/FriendsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public IEnumerator QueryFriendsList()
QueryFriendsCallbackInfo? result = null;
_friendsInterface.QueryFriends(ref options, null, (ref QueryFriendsCallbackInfo data) => { result = data; });

yield return new WaitUntil(() => result != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => result != null);
if (result != null)
{
Assert.AreEqual(Result.Success, result.Value.ResultCode, "Could not query the friends list.");
Expand Down Expand Up @@ -103,7 +103,7 @@ public IEnumerator SearchFriendsListByDisplayName()
QueryUserInfoByDisplayNameCallbackInfo? queryResult = null;
_userInfoInterface.QueryUserInfoByDisplayName(ref options, null, (ref QueryUserInfoByDisplayNameCallbackInfo data) => { queryResult = data; });

yield return new WaitUntil(() => queryResult != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => queryResult != null);
Assert.AreEqual(Result.NotFound, queryResult.Value.ResultCode);

// TODO: Will need set test accounts to verify that the results are correct. For now,
Expand Down Expand Up @@ -146,7 +146,8 @@ public IEnumerator QuerySelfInfo()
QueryUserInfoCallbackInfo? queryResult = null;
_userInfoInterface.QueryUserInfo(ref queryOptions, null, (ref QueryUserInfoCallbackInfo data) => { queryResult = data; });

yield return new WaitUntil(() => queryResult != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => queryResult != null);

if (queryResult != null)
{
Assert.AreEqual(Result.Success, queryResult.Value.ResultCode, "Could not query for self.");
Expand Down Expand Up @@ -188,7 +189,7 @@ public IEnumerator SendReportToSelf()
SendPlayerBehaviorReportCompleteCallbackInfo? reportResult = null;
reportsHandle.SendPlayerBehaviorReport(ref reportOptions, null, (ref SendPlayerBehaviorReportCompleteCallbackInfo data) => { reportResult = data; });

yield return new WaitUntil(() => reportResult != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => reportResult != null);

if (reportResult != null)
{
Expand All @@ -212,7 +213,7 @@ public IEnumerator SendReportToFirstFriend()
QueryFriendsCallbackInfo? result = null;
_friendsInterface.QueryFriends(ref options, null, (ref QueryFriendsCallbackInfo data) => { result = data; });

yield return new WaitUntil(() => result != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => result != null);
if (result != null)
{
Assert.AreEqual(Result.Success, result.Value.ResultCode, "Could not query the friends list.");
Expand Down Expand Up @@ -243,7 +244,7 @@ public IEnumerator SendReportToFirstFriend()
QueryExternalAccountMappingsCallbackInfo? externalData = null;
connectHandle.QueryExternalAccountMappings(ref queryOptions, null, (ref QueryExternalAccountMappingsCallbackInfo data) => { externalData = data; });

yield return new WaitUntil(() => externalData != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => externalData != null);
if (externalData != null)
{
Assert.AreEqual(Result.Success, externalData.Value.ResultCode,
Expand Down Expand Up @@ -273,7 +274,7 @@ public IEnumerator SendReportToFirstFriend()
SendPlayerBehaviorReportCompleteCallbackInfo? reportResult = null;
reportsHandle.SendPlayerBehaviorReport(ref reportOptions, null, (ref SendPlayerBehaviorReportCompleteCallbackInfo data) => { reportResult = data; });

yield return new WaitUntil(() => reportResult != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => reportResult != null);

if (reportResult != null)
{
Expand All @@ -299,7 +300,7 @@ public IEnumerator ShowHideFriendsOverlay()
null,
(ref ShowFriendsCallbackInfo data) => { overlayResult = data; });

yield return new WaitUntil(() => overlayResult != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => overlayResult != null);
if (overlayResult != null)
{
Assert.AreEqual(Result.Success, overlayResult.Value.ResultCode, "Could not notify overlay to show friends");
Expand All @@ -315,7 +316,7 @@ public IEnumerator ShowHideFriendsOverlay()
null,
(ref HideFriendsCallbackInfo data) => { hideResult = data; });

yield return new WaitUntil(() => hideResult != null);
yield return new WaitUntilDone(GlobalTestTimeout, () => hideResult != null);
if (hideResult != null)
{
Assert.AreEqual(Result.Success, hideResult.Value.ResultCode, "Could not notify overlay to hide friends");
Expand Down
30 changes: 23 additions & 7 deletions com.playeveryware.eos/Runtime/Core/EOSManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
#define EOS_CAN_SHUTDOWN
#endif

// This define controls if the EOS SDK should be unloaded in the editor at shutdown to work around DLL unload errors.
//#define EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN

// On macOS and Linux, there isn't a known reliable way to unload shared libraries, therefore this is the default behavior.
#if (UNITY_EDITOR_OSX || UNITY_EDITOR_LINUX)
#define EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN
// As per Epic's documentation they recommend not calling PlatformInterface.Release / PlatformInterface.Shutdown in editor
// because Unity doesn't unload managed libraries until the Editor exits. Doing so will cause unintended side effects:
// https://dev.epicgames.com/docs/epic-online-services/eos-get-started/get-started-guide/next-steps#shut-down-the-eos-sdk
// This is also required on macOS/Linux always, because there isn't a known reliable way to unload shared libraries
#if UNITY_EDITOR && (!UNITY_EDITOR_WIN || !EOS_UNLOAD_SDK_ON_SHUTDOWN_IN_WIN_EDITOR)
// This define controls if the EOS SDK should be unloaded in the editor at shutdown to work around DLL unload errors.
#define EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN_IN_EDITOR
#endif
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This docs file covers a couple of points which are a bit of a concern:

  • "It is not the default because if it were, then any edits to the EOSConfig file would require a reboot of the Unity Editor"
    • Can you check if this is accurate?
    • If it is then we would need to think of a solution to this, perhaps when you save the EOSConfig it prompts you to restart the Editor (after checking the new define mentioned in the comment below)
    • I suspect we also need a Unity hook to check if the file was modified outside of Unity (user could've edited it by hand, or pulled latest changes from their repo)
  • "In the past, not unloading the EOS SDK could also cause issues with state from the previous Unity run not being properly cleaned up."
    • This is the opposite of what we're seeing right? I'm wary that there's some edge case issues that we haven't seen with this initial testing. It could definitely be a misunderstanding though
    • The commit message where it was added also says the same, so it doesn't appear to just be a mistake in the docs (It also carries with it the potential for "leaked" EOS State to carry over between play in editor runs.)


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change to always define EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN in Editor this means that this docs file is out of date.

The change above also removes the ability for developers to control whether it's enabled in Editor or not for Windows.

One option would be to change the above code to this, and update the docs to refer to this define instead:

#if UNITY_EDITOR && (!UNITY_EDITOR_WIN || !EOS_UNLOAD_SDK_ON_SHUTDOWN)
#define EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly it would be nice to update these defines whilst we're here:

  • EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN_IN_EDITOR
  • EOS_UNLOAD_SDK_ON_SHUTDOWN_IN_WIN_EDITOR

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this comment active because this docs file needs updating with the new define

#if !UNITY_EDITOR
Expand Down Expand Up @@ -220,7 +222,7 @@ public partial class EOSSingleton
static private bool s_hasInitializedPlatform;

private static readonly bool s_eosUnloadSDKOnShutdown =
#if EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN
#if EOS_DO_NOT_UNLOAD_SDK_ON_SHUTDOWN_IN_EDITOR && UNITY_EDITOR
false
#else
true
Expand Down Expand Up @@ -1640,15 +1642,29 @@ public void OnApplicationShutdown()
Log("Waiting for pending finalizers.");
System.GC.WaitForPendingFinalizers();
#endif
Log("Disposing notification handles before platform release.");
s_notifyLoginStatusChangedCallbackHandle?.Dispose();
s_notifyLoginStatusChangedCallbackHandle = null;

s_notifyConnectLoginStatusChangedCallbackHandle?.Dispose();
s_notifyConnectLoginStatusChangedCallbackHandle = null;

s_notifyConnectAuthExpirationCallbackHandle?.Dispose();
s_notifyConnectAuthExpirationCallbackHandle = null;

Log("Releasing the EOS Platform Interface.");
GetEOSPlatformInterface()?.Release();

#if UNITY_EDITOR
if (s_eosUnloadSDKOnShutdown)
{
Log("Shutting down the platform interface.");
ShutdownPlatformInterface();
}
Comment thread
matt-clarke marked this conversation as resolved.

#else
Log("Shutting down the platform interface.");
ShutdownPlatformInterface();
#endif
Comment thread
matt-clarke marked this conversation as resolved.
Outdated
SetEOSPlatformInterface(null);


Expand Down