Crash on iOS using LoadBalancingAPI and SetCustomProperties

Options
Hi,
I am using setCustomProperties to a room and it consistently crashes on iOS only (not in the editor) with the following message :

System.String doesn't implement interface System.Collections.ICollection
* Assertion: should not be reached at mini-trampolines.c:183

I have tracked it down the the StripKeysWithNullValues method in the Extensions.cs class specifically to
original.Keys.CopyTo(keys, 0);

I found related posts on the matter here :
http://forum.unity3d.com/threads/140115 ... g-an-Array
and here
http://web.archiveorange.com/archive/v/ ... c3PKDyPbUe

I guess its easily fixed using a different method for copying the array but I don't want my fix to be overwritten when I update the plugin.

or maybe I am doing something wrong.
Thanks,

Comments

  • Tobias
    Options
    I could use the full call-stack and the values you use. It might be an issue in StripKeysWithNullValues of course but maybe it's due to a use I didn't expect.
    You can feel free to fix it for yourself in that method. If you post the fix here and it won't break other code, I can copy it into the next update and keep it.

    Sorry you ran into such an issue.
  • Hi Tobias,
    I just commented out the CopyTo method and iterated over the collection using foreach to copy the keys, and now everything works fine.
     public static void StripKeysWithNullValues(this IDictionary original) {
    
              object[] keys = new object[original.Count];
    			//original.Keys.CopyTo(keys, 0);
    			int i =0;
    			foreach(object key in original.Keys){
    				keys[i++]=key;
    			}
    
                for (int index = 0; index < keys.Length; index++)
                {
                    var key = keys[index];
                    if (original[key] == null)
                    {
                        original.Remove(key);
                    }
                }
    
            }
    
  • Tobias
    Options
    The foreach is minimally less performing but not in a critical method, so I'll change PUN accordingly.

    You should submit the issue with CoptyTo as bug report to Unity, nevertheless. I'd say CopyTo should work also on iOS but maybe it's not correctly implemented for IDictionary and gets broken on export.