Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Cannot connect IL2CPP managed debugger to iPhone

Discussion in 'Experimental Scripting Previews' started by thisisthedave, Aug 17, 2018.

  1. thisisthedave

    thisisthedave

    Joined:
    Dec 2, 2013
    Posts:
    7
    I'm attempting to try out the IL2CPP managed debugger feature advertised in Unity 2018.2.3, but I'm unable to make it work. What can I try next to figure out why it's failing?

    I created a lightly modified version of the SimpleMobilePlaceholder sample project, and configured an iOS build with "Script Debugging" enabled:

    upload_2018-8-16_19-44-52.png

    The build completes successfully and I'm able to build and install the app to my iPhone 7 using xcode. In Visual Studio 2017, I click Run, Attach to Process, and select the Unity iPhonePlayer:
    upload_2018-8-16_19-47-45.png

    But visual studio cannot connect to the player.
    upload_2018-8-16_19-49-5.png

    Some diagnostic info:
    * I'm using Unity 2018.2.3f1, Visual Studio 2017 Version 7.5.2 (build 40), and Xcode 9.4.1.
    * I am able to connect the Unity profiler.
    * I've experienced the same inability to connect on a different Mac, and on a different Unity project.
    * IL2CPP managed debugging does work when the target platform is MacOS Standalone.
    * I'm happy to send the sample project, but I can't attach the file (42MB zip exceeds the upload limit).

    I'm excited for the potential of debugging on an iPhone! I appreciate any help you can provide.

    Thanks!
    -Dave
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    Thanks for the information. This should work, based on the versions you are using. Can you submit a bug report via the Unity editor? I think you can upload a 42 MB project there. If not, we can get the project from you via another route. Please let me know the bug number if you are able to submit one.

    In the meantime, you can try another IDE, just to gather more data. Jetbrains Rider and VSCode should work on macOS as well. If you have a Windows computer on the same network as the iOS device, you can use Visual Studio on Windows to connect to it as well.
     
  3. thisisthedave

    thisisthedave

    Joined:
    Dec 2, 2013
    Posts:
    7
    Hi Josh,

    Thanks for your response. I'm unable to connect the managed debugger with either VS Code or Rider. I submitted a bug report (Case 1072724). Are there any network settings that might interfere with connection, but not with discovery (which might explain why I'm able to see the IOS player listed as a debug target, but cannot connect)?
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    Yes, the discovery and debugger connection use to different TCP ports. On iOS, the TCP port for the debugger can change each time the app runs. It might be worth peeking at the open ports on the machine running the IDE and the iOS device (if you can). Also, check for any firewall settings.

    We'll investigate your bug report and see if we can reproduce it here.
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    @thisisthedave

    I have another possibility for your to try. This might be a problem because the iPhone has two network interfaces, the cellular data connection, and a Wifi connection. We need to use the Wifi connection for debugging. Please try to use airplane mode, with Wifi enabled. That should disable the cellular data connection, and might allow debugging to work properly.
     
    zwcloud likes this.
  6. thisisthedave

    thisisthedave

    Joined:
    Dec 2, 2013
    Posts:
    7
    @JoshPeterson Thank you, that worked perfectly! I had even attempted disabling the ethernet connection on my iMac on the suspicion that it was attempting to connect on the wrong network interface, but it never occurred to me that I should disable the phone's cellular network. For the sake of anybody who has this problem in the future, swipe up on your iPhone to disable the cellular connection:

    upload_2018-8-28_15-47-2.png

    Thanks Josh, I really appreciate your help!

    -Dave
     
    JoshPeterson likes this.
  7. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    44
    Hi, we're still experiencing the issue with all the above

    Our setup

    iOS
    Xcode 9.4
    Rider 2018.2.2
    Unity 2018.2.6/2018.2.7

    We get the error in Rider with regards to unable to reach a specific IP, Rider detects the device but fails to Attach to Unity Process. We can ping the IP

    Android
    We tried a couple of devices, OS 6.0/7.0/8.0 - identical result, same Unity + Rider

    We disabled Cellular, enabled wifi+airport mode etc
    We tried on 2 different macs, ensured same wifi connection on device/mac

    Unity Profiler works fine
    OSX Version 10.13.4

    Any other thoughts or things we could possibly try?
     
  8. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    44
    Couple of things we have also tweaked in the player settings

    Note: We use AllowDebugging in the BuildPlayer options in code

    iOS
    ARM64 only
    Api Compat 2.0
    IL2CPP
    Runtime 3.5
    Engine stripping on

    Android
    Min Api 19
    Target Auto
    Runtime .net 3.5
    IL2CPP
    Api Compat 2.0
    C++ Compiler Config Release
    ARMv7 only
    Engine stripping on
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    The iOS debugger should always use port 56000. Is there a firewall blocking that port, or maybe something else using that port?

    Also, you may want to try Visual Studio for Mac or Visual Studio on Windows as additional data points for trouble shooting.
     
    stgs73 likes this.
  10. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    44
    Ya we'll give VS OSX a go and see, if it's good then it's a Rider issue and we'll ping them on it
     
  11. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    44
    Just to let you know, we tried VS for Mac and still the same issue
     
  12. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    44
    It seems the UDP port is open but the TCP port is blocked ( i assume this is the issue ). We've double-checked for firewall stuff but no dice there.
     
  13. stgs73

    stgs73

    Joined:
    Mar 23, 2015
    Posts:
    44
    Ok we found the issue, our player settings are on 3.5 .NET - this is why it didn't work

    We only noticed because there was some small text in the build player settings that said you had to be on 4.0 .NET and api compat 2.0 :)

    We usually build via our own menu so we completely missed this, i don't recall seeing it in the docs ...maybe we missed?

    Also the Unity docs on the original 4.0 net said something along the lines of not to use for mobile due to bloat or was that just referring to api compatibility?

    We now have 1 conflict with a plugin provider that is stopping us from changing this, we'll chase this down.

    The problem error we have is if we use Api Compat 2.0..
    The type or namespace name `Remoting' does not exist in the namespace` System.Runtime'.

    Update: We hacked the plugin to fix the issue, should be good now.

    thnx
     
    Last edited: Sep 12, 2018
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    No, you did not miss this in the debugger docs - they don't exist yet! We have new debugger documentation in process now, hopefully it will be posted soon.

    This was referring to the Api Compatibility Level option. You should avoid using the .NET 4.x Api Compatibility Level option in Unity 2018.1 and Unity 2018.2, as it is a much larger amount of code than the .NET Standard 2.0 Api Compatibility Level. In Unity 2018.3, they are much more comparable in size.

    However, we still recommend .NET Standard 2.0, and the .NET 4.x profile include a number of APIs which we don't support on most platforms.
     
    stgs73 likes this.
  15. MikePage_Artrix

    MikePage_Artrix

    Joined:
    Mar 18, 2016
    Posts:
    11
    Hi,

    I'm having a similar issue on Android using Unity 2018.3.0f2. The instance shows up on the device (after disabling all windows firewalls) but when I hit OK, I just a get a spinner for a second or two and then nothing happens.

    Any ideas?

    upload_2019-1-24_10-49-3.png
     
    seandanger likes this.
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    Make sure the device only has one network interface active. It looks like it might be a phone, so you can put it in airplane mode an enable Wifi. Also, you can use the USB connection to debug for Android devices. If you have physical access to the device, try to connect it via USB. That might be more reliable.
     
  17. zwcloud

    zwcloud

    Joined:
    Mar 15, 2016
    Posts:
    311
    Here is another case when the debbuger can see the iPhone player but cannot connect and attach to it: The mac has two network connections. One is WiFi, another one is a network via a USB ethernet adapter. After I removed the USB ethernet adapter, VS for mac can attach to the iOS player without any problem.

     
  18. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    33
    I have the same issue MikePage_Artrix posted about, the USB connected option for the device never shows up in the Attach Unity Debugger window when the project was built using IL2CPP backend. It does show the wifi connected option for the device though -- but doesn't successfully connect. As he wrote, I get a spinner for about a second and then nothing. Profiling in the Unity Editor attaches and records properly, FWIW.

    If I build the project using the Mono backend, both the USB and wifi option for the device appear in the Attach Unity Debugger device list, and successfully attach. My Windows Defender firewall is disabled and the device is in airplane mode.

    Edit: Issue persists with a freshly reformatted machine, fresh install of Unity 2019.1 and included Visual Studio Community 2017 (15.9.11), using a new project with just a single Canvas Button in scene.
     
    Last edited: May 7, 2019
  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    Can you submit a bug report for this issue? It looks like something is wrong on our end. The specific Android device you are using might have an impact as well, so please provide that information in the bug report if possible.
     
  20. seandanger

    seandanger

    Joined:
    Jun 13, 2012
    Posts:
    33
    Hey Josh, thanks a lot for the response. I did end up submitting a bug report, case 1152416. I had the same results with 3 different devices: a Nexbit Robin running Android 7.1.1, a Sony Xperia Compact X running 7.1.1, and a Samsung Galaxy S9 running Android 9. I included the Android versions in my report but not the device models -- I'm not sure how to edit the report I submitted, is that possible?

    For now I'll debug with the Mono version -- which is an acceptable workaround for me for now.

    I hope that helps!
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    Please reply to the original email you received with the bug number. Your email content will be added the case notes. Thanks!
     
  22. eylulatilgan

    eylulatilgan

    Joined:
    Jun 7, 2013
    Posts:
    12
    Hello, I have the similar issue like MikePage_Artrix's. I get a build with IL2CPP for Android and cannot see my device in Visual Studio when I try to debug. My device is Alcatel Idol 4.
     
  23. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    @eylulatilgan

    Is the device attached to the machine where the debugger is running via USB, or are they on the same Wifi network?

    Also, note that if the device has both Wifi and cellular data antennas, make sure only the Wifi antenna is enabled. If the device has more than one network interface, the debugger code in the Unity player might bind to the wrong network interface, and end up on a network which is different from the IDE.
     
  24. sotrosh

    sotrosh

    Joined:
    Dec 25, 2014
    Posts:
    11
    Trying to attach to debug to my iPad. The problem is that I don't see my device in "Attach to Process" list. But Profiler works perfect (using USB)

    P.S. I'm using Unity 2019.1.9 and Visual Studio for Mac 7.7.2, macOS 10.14.5
     
  25. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    Does the iPad happen to have both cellular data and Wifi connections? If so, please enable only the Wifi connection by putting the device in airplane mode, then enabling Wifi.

    The debugger code in the player which connects to the IDE cannot determine which network interface to choose. It will sometimes choose the wrong one if more than one interface is present.
     
  26. sotrosh

    sotrosh

    Joined:
    Dec 25, 2014
    Posts:
    11
    Thank you for answer. Yes, airplane mode is turned on and iPad doesn't have any GPS module.
     
  27. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    Can you submit a bug report for this issue? Maybe there is something specific to this project which prevents it from showing up properly.
     
  28. Wecica

    Wecica

    Joined:
    Jul 20, 2016
    Posts:
    24
    I've run into the same problem as you do with Unity 2018.3.11 and Visual Studio 2017.15.9.11 trying to attach debugger on Redmi Note 5A running with Android 7.1.2...(So much version...) Is there any progress or a solution for this problem now? It is quite annoying.
     
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
    I don't believe that we had a bug report for this issue, so we've not made any progress on it that I can recall. Can you submit a bug report for it?
     
  30. Wecica

    Wecica

    Joined:
    Jul 20, 2016
    Posts:
    24
    I don't know how to submit a bug report for this? Any documents for bug reporting?
     
  31. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,115
  32. smartinetz

    smartinetz

    Joined:
    Dec 8, 2017
    Posts:
    27
    JoshPeterson likes this.