when we call
Code: Select all
StartCoroutine(smartFox.InitCrypto());
Code: Select all
Message: ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
Stacktrace: System.Buffer.BlockCopy (System.Array src, System.Int32 srcOffset, System.Array dst, System.Int32 dstOffset, System.Int32 count) (at <2e531ccb5a634d41a5f338e40371c5fd>:0)
Sfs2X.Util.ByteArray.WriteBytes (System.Byte[] data, System.Int32 ofs, System.Int32 count) (at <facfabb65458430294cb5e9a75ea8519>:0)
Sfs2X.Util.CryptoInitializer.OnHttpResponse (System.String rawData) (at <facfabb65458430294cb5e9a75ea8519>:0)
Sfs2X.Util.CryptoInitializer+<Run>d__5.MoveNext () (at <facfabb65458430294cb5e9a75ea8519>:0)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <e0b801613d424beca89c0145453da4be>:0)
The issue is intermittent, we don't have the STR.
but in crashlytics we saw that many users are getting this nonfatal exception intermittently in production, the method was part of smartfox internal class we were not about to figure out what the issue was.
we are using smartfox for a long time and our connection flow is fine also we haven't noticed this issue while testing.
so to deal with the issue we have implemented a retry logic in case encryption fails so sometimes the following thing is happening for the user.
step 1: User-initiated connection
step 2: Connected successfully
Step 3: Called StartCoroutine(smartFox.InitCrypto());
Step 4: Encryption initialization successful
Step 5: Initiated login.
Step 6: Login successful , so started gameplay
Step 7: After around 10min of gameplay, the user minimized the app so the client manually disconnected from smartfox
Step 8: On app maximization, the client started reconnection flow where it again completed steps 1,2 but got the above nonfatal exception while trying to complete step 3.
Step 9: As step 3 got failed while reconnection our retry logic again tried to finish step 3 after a 2-sec delay and at that attempt encryption initialization was successful.
So we didn't understand why exactly it threw an exception in step 8 though.
How can we avoid this? are we doing anything wrong?
Misc info:
SFS2X version: 1.7.8
Unity API version: 2019.2.14f1
Platform: Both in Android and iOS