Hi All,
We are using PlayFab integration for our Unity3D game. We have recently run into some unpleasant issues when attempting to have a user login to PlayFab (LoginWithAndroidDeviceIDRequest and/or LoginWithEmailAddressRequest) while having a poor internet connection.
Using step-by-step debugging we traced the issue to the PlayFabWWW class - Post coroutine.
The issue here is that the coroutine yields and waits for the WWW to complete. This leads to a timeout of 30 seconds or more which is unacceptable for users. Since Unity does not allow the WWW timeout to be changed, we did a bit of a hack inside the PlayFab coroutine:
private IEnumerator Post(WWW www, Action<string> wwwSuccessCallback, Action<string> wwwErrorCallback) { DateTime coroutineStart = DateTime.Now; bool timeoutReached = false; while(!timeoutReached && !www.isDone) { yield return null; if((DateTime.Now - coroutineStart).Seconds >= 5) { timeoutReached = true; } } if(timeoutReached) { www.Dispose(); wwwErrorCallback("Request timed out."); yield break; } //... Rest of the code here ... }
Using this method we reduced the timeout to a reasonable value.
We would like to know:
1. Do you think the above hack might cause issues? Our testing did not reveal any, but we don't really know all the use-cases for the Post coroutine.
2. Would it be possible, in the future, for PlayFab SDK to use for the WWW Post the timeout value from PlayFabSettings.RequestTimeout (or another setting)?
Thank you and Best Regards,
Alex
EZ ENTERTAINMENT