Unity 5.1 and Ping on iOS [Fix coming in Unity 5.1.0p2+]

Options
For some reason, Unity 5.1 broke the Use Best Cloud functionality on iOS, can you look that up. I am using the latest PUN+ version from the Asset Store. It works fine on Android.

Thank you!

Comments

  • Tobias
    Options
    We will look into this but if Unity broke it, there might be no workaround (without breaking other stuff).
    Please report a bug to Unity, too.
  • Tobias
    Options
    I can reproduce the issue in 5.1.0p1. I assume it's a new bug and working with other versions of Unity.
    Did you report this as bug to Unity already?

    In Unity 5, you can use PUN Free as alternative. It comes with C# sockets, which now export without Unity 4's licensing restrictions.
  • Tobias
    Options
    I can run a build by Unity 5.0.2p1, so this is definitely new.
    The error is reported to Unity. Case 704938
  • Tobias
    Options
    I got an update by Unity:
    "This issue is already fixed and will be available with next version of Unity 5.1."
    Look out for 5.1.0p2.
  • kamend
    Options
    Well, Unity 5.1.1f, still not fixed, probably next version. Unity has really messed up their versions, but at least they push fixes faster.
  • kamend
    Options
    Tried Unity 5.1.1p1 and still have the error, are you sure this is only on the Unity's side? Also I tried using Photon Free and still have the same error.

    This is what I get from XCode:
    MissingMethodException: Method not found: 'Default constructor not found...ctor() of ExitGames.Client.Photon.PingMono'.


    (Filename: currently not available on il2cpp Line: -1)

    MissingMethodException: Method not found: 'Default constructor not found...ctor() of ExitGames.Client.Photon.PingMono'.


    (Filename: currently not available on il2cpp Line: -1)

    MissingMethodException: Method not found: 'Default constructor not found...ctor() of ExitGames.Client.Photon.PingMono'.


    (Filename: currently not available on il2cpp Line: -1)

    MissingMethodException: Method not found: 'Default constructor not found...ctor() of ExitGames.Client.Photon.PingMono'.


    (Filename: currently not available on il2cpp Line: -1)

    MissingMethodException: Method not found: 'Default constructor not found...ctor() of ExitGames.Client.Photon.PingMono'.

    (Filename: currently not available on il2cpp Line: -1)
  • Tobias
    Options
    Do you have a linker.xml file in your code? Do you set a code stripping level?
    If the problem is still there, please report it to Unity via their bug tracker. I can not fix this in the exporter and I can't work around it. Bug them with their bugs to fix them.
  • kamend
    Options
    Hey Tobias,
    I would report to Unity, if I know exactly where the bug is? It is your code, not mine and being a future client of Photon, it's in your best interest to bug Unity to fix it.
  • Tobias
    Options
    I bugged Unity to fix it and got the reply that the fix is upcoming.
    I can re-test the latest Unity patch version each week but then I can't work on other features and improvements. We try to strike a balance.
  • kamend
    Options
    I also noticed that it is not working on Android too, is this the same bug?
  • Tobias
    Options
    I re-reported the issue but it might help if you also do.
    Support Case 704938.
  • kamend
    Options
    Can we find the number here: http://issuetracker.unity3d.com/, so we can vote? I mean where exactly can we find that Support Case?
  • kamend
    Options
    I tried using PUN Free and on Android, BestCloudConnect is working, but on iOS it is just hanging without any error.

    Kamen
  • kamend
    Options
    I found where the problem comes from for iOS on PUN Free, but I have the feeling that it is the same problem on PUN+ too.

    The error comes from PingCloudRegions.cs and especially this line:

    ping = (PhotonPing)Activator.CreateInstance( PhotonHandler.PingImplementation );

    I think that using Activator.CreatInstance and IL2CPP does not play well. The way I fixed it is that I made my own copy of PingMono (using reflection), added a constructor and initialized it with "new".
    if( Application.platform == RuntimePlatform.IPhonePlayer ) {
    				ping = new PingMono2();
    			} else {
    				ping = (PhotonPing)Activator.CreateInstance( PhotonHandler.PingImplementation );
    			}
    
  • Tobias
    Options
    Kamen: Thanks for the update and great workaround.

    We are using the CreateInstance method in other places (in the assembly), too, so I still hope Unity will fix the issue.
    The case number is the one I published above but it seems this didn't make it into the public bug tracking.
    I even mailed plugged this case into another, totally unrelated mail conversation to get some attention to it. Despite that, no update yet.

    Maybe we can refactor our workflow to your variant. I will take a look.
  • kamend wrote:
    I found where the problem comes from for iOS on PUN Free, but I have the feeling that it is the same problem on PUN+ too.

    The error comes from PingCloudRegions.cs and especially this line:

    ping = (PhotonPing)Activator.CreateInstance( PhotonHandler.PingImplementation );

    I think that using Activator.CreatInstance and IL2CPP does not play well. The way I fixed it is that I made my own copy of PingMono (using reflection), added a constructor and initialized it with "new".
    if( Application.platform == RuntimePlatform.IPhonePlayer ) {
    				ping = new PingMono2();
    			} else {
    				ping = (PhotonPing)Activator.CreateInstance( PhotonHandler.PingImplementation );
    			}
    

    Thank you so much for this!
  • Tobias
    Options
    Just an update:
    We got an update by Unity and the core of the problem is that IL2CPP is always stripping unused code. In this case, that includes the classes we want to Instantiate via Activator.CreateInstance!

    We will either provide a linker.xml file to prevent this stripping or refactor our code entirely to avoid the issue.
  • blattepop
    Options
    I ran into this problem today and was wondering if there was any update that fixed the problem. For now, I'll try using the Cloud option with US selected.
  • Tobias
    Options
    We couldn't update the PUN package yet, so right now, this is still a problem.
    The fix kamend posted above is a valid solution, however. We will check that the next PUN version has something comparable.
  • Tobias
    Tobias admin
    edited July 2015
    Options
    You can take care of the specific problem in this case by using a link.xml file as described in here:
    http://docs.unity3d.com/Manual/iphone-playerSizeOptimization.html

    You should be able to resolve the lack of a constructor for the PingMono class using this link.xml:
    
    
           
                   
           
    
    Not that it is also possible to disable stripping entirely for a specific assembly by using a link.xml file like this: