Hello everybody,
we managed to upgrade our Unity to the “latest” 2022 version (2022.1.17f1) and upgraded every unity-pack. Since we now have to Authenticate the users (for RemoteConfig/Ads/IAP) we implemented it, like the documentations mentioning.
Since the implementation, we have a tremendous rise of our exceptions because of the authentication-system (the second high one is the “System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert”-
TelemetryHandler one, that’s another story).
I post this screenshot attached, as I start thinking, this might have something to do with traffic? If you look at the hour-graph you may understand why i came to this conclusion.
I am not able to reproduce this exception and I don’t know if this is a critical exception for IAP’s or other game-relevant stuff.
I want to implement more of the UGS-features (without fearing it doesn’t work like intended) and I just hope maybe someone can help me or deliver some suggestions, leading to a new perspective/solution-attempt.
Here’s the stacktrace:
Unity.Services.Authentication.AuthenticationServiceInternal/<HandleSignInRequestAsync>d__108.MoveNext() (at D:/XXX/Library/PackageCache/com.unity.services.authentication@2.3.1/Runtime/AuthenticationServiceInternal.cs:528)
Unity.Services.Authentication.WebRequest/<SendAsync>d__15`1<System.Object>.MoveNext() (at D:/XXX/Library/PackageCache/com.unity.services.authentication@2.3.1/Runtime/Network/WebRequest.cs:63)
TMPro.TMP_TextProcessingStack`1<Unity.IL2CPP.Metadata.__Il2CppFullySharedGenericType>.PreviousItem() (at D:/XXX/Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_TextProcessingStack.cs:397)
TMPro.TMP_TextProcessingStack`1<Unity.IL2CPP.Metadata.__Il2CppFullySharedGenericType>.PreviousItem() (at D:/XXX/Library/PackageCache/com.unity.textmeshpro@3.0.6/Scripts/Runtime/TMP_TextProcessingStack.cs:397)
Unity.Services.Authentication.WebRequest.RequestCompleted(System.Threading.Tasks.TaskCompletionSource`1<System.String>,System.Int64,System.Boolean,System.Boolean,System.String,System.String,System.Collections.Generic.IDictionary`2<System.String,System.String>) (at D:/EXXX/Library/PackageCache/com.unity.services.authentication@2.3.1/Runtime/Network/WebRequest.cs:193)
Unity.Services.Authentication.WebRequest/<>c__DisplayClass16_0.<SendAttemptAsync>b__0(UnityEngine.AsyncOperation) (at D:/XXX/Library/PackageCache/com.unity.services.authentication@2.3.1/Runtime/Network/WebRequest.cs:82)
And here’s my implementation-Code:
private bool isTryingToInit = false;
private bool isInitialized = false;
private UnityAction<bool> onConnectionOutcomeEvent;
private const string environment = "production";
private bool HasConnection {
get {
return (Application.internetReachability != NetworkReachability.NotReachable);
//retrun Unity.Services.RemoteConfig.Utilities.CheckForInternetConnection(); //thats a "http"-call??? - no, thanks
}
}
public void TryConnectWithUnityService(UnityAction<bool> _onConnecitonOutcome) {
if (isInitialized) {
if (_onConnecitonOutcome != null) {
_onConnecitonOutcome.Invoke(true);
}
return;
}
if (isTryingToInit) {
if (_onConnecitonOutcome != null) {
onConnectionOutcomeEvent -= _onConnecitonOutcome;
onConnectionOutcomeEvent += _onConnecitonOutcome;
}
return;
}
isTryingToInit = true;
if (!HasConnection) {
isTryingToInit = false;
if (_onConnecitonOutcome != null) {
_onConnecitonOutcome.Invoke(false);
}
return;
}
if (_onConnecitonOutcome != null) {
onConnectionOutcomeEvent -= _onConnecitonOutcome;
onConnectionOutcomeEvent += _onConnecitonOutcome;
}
StartConnectingUnityService();
}
private async void StartConnectingUnityService() {
await InitializeAndSignInAsync();
isInitialized = (UnityServices.State == ServicesInitializationState.Initialized);
isTryingToInit = false;
if(onConnectionOutcomeEvent != null) {
UnityAction<bool> _tempHolder = onConnectionOutcomeEvent;
onConnectionOutcomeEvent = null;
_tempHolder.Invoke(isInitialized);
}
}
private async Task InitializeAndSignInAsync() {
// initialize handlers for unity game services
if (!isInitialized) {
if ((UnityServices.State == ServicesInitializationState.Uninitialized)) {
try {
// options can be passed in the initializer, e.g if you want to set analytics-user-id or an environment-name use the lines from below:
// var options = new InitializationOptions()
// .SetOption("com.unity.services.core.analytics-user-id", "my-user-id-1234")
// .SetOption("com.unity.services.core.environment-name", "production");
var _options = new InitializationOptions()
.SetEnvironmentName(environment);
await UnityServices.InitializeAsync(_options);
} catch (System.Exception _ex) {
return;
}
}
}
// remote config requires authentication for managing environment information
if (!AuthenticationService.Instance.IsSignedIn) {
try {
await AuthenticationService.Instance.SignInAnonymouslyAsync();
} catch (AuthenticationException ex) {
// Compare error code to AuthenticationErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
} catch (RequestFailedException ex) {
// Compare error code to CommonErrorCodes
// Notify the player with the proper error message
Debug.LogException(ex);
} catch (System.Exception _ex) {
return;
}
}
}
Relevant Packages we use:
- Advertisement 4.3.0
- Analytics 4.2.0
- Analytics Library 3.8.1
- Authentication 2.3.1
- In App Purchasing 4.5.1
- Remote Config 3.1.3
Other relevant Informations:
- We use IL2CPP
- We use proguard