Search Unity

Question IL2CPP Failing in Windows Machine

Discussion in 'Windows' started by SketchWork, May 16, 2020.

  1. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    254
    Hi there,

    I have recently downgraded Visual Studio from 2019 back to 2017 which I was using for a long time with no issues. Now when I'm compiling for Windows x86-64 with IL2CPP .Net x4 I'm getting the following error:

    One thing I noticed is that unity is still trying to use Windows Kit 10.0.19041.0 which was a part of the VS2019 install and is no longer there. Where is it getting this old version of WinSDK from even if that is the problem at all.

    Help please :(

    Justin
     
    l_racher likes this.
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Likely when you uninstalled Visual Studio, it didn't cleanup the registry and it's still saying that SDK is installed. You can either install that SDK back (you can use it with VS2017) from https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk/, or you can manually change the registry values to point to older SDK at "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SDKs\Windows\v10.0".
     
  3. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    254
    Hey @Tautvydas-Zilys,

    You my friend are awesome. This fixed my issue and I'm able to continue building again. One thing to make a note of is that the new Win 10 SDK 10.0.19041.0 released on the 15th May 2020 has some issues with sockets in Unity. All my networking broke, reverting back to Win 10 SDK 10.0.17763.0 and all networking works again.

    This new version is now installed automatically with VS2019 in case others get issues.

    Justin
     
    koeni296 and mowax74 like this.
  4. l_racher

    l_racher

    Joined:
    Sep 1, 2018
    Posts:
    12
    I had a similar problem caused by the latest Windows 10 SDK 10.0.19041.0 which is not fully compatible with unity il2cpp yet.
    (async TcpClient socket connect causes an "ArgumentException: Value does not fall within the expected range." while using it at least with NoDelay and specific timeout values.)
    This is a general problem I have encountered before. I had the exact same problem some time ago with 10.0.18362.0 when it was first available.
    Unity probably should have a way to select the Windows 10 SDK to use for il2cpp builds if multiple versions are available instead of always using the latest one.
    The other issue that, even after uninstalling the newest Windows 10 SDK the above-mentioned registry key isn't properly updated, technically is the fault of Microsoft but finger-pointing doesn't really help anyone.
    Being able to ourselves select the Windows SDK to use is all we would need to get around these kinds of obscure issues which can be incredibly frustrating to debug.
     
    Last edited: May 20, 2020
    SketchWork likes this.
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you report a bug on this?
     
  6. l_racher

    l_racher

    Joined:
    Sep 1, 2018
    Posts:
    12
    tracker id: 1249143
    Please tell me if you didn't mean that.
     
    SketchWork likes this.
  7. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    254
    This was exactly the same error I was having which is what led to us rolling back to a previous Win 10 SDK version.

    Justin
     
    l_racher likes this.
  8. Yacuzo

    Yacuzo

    Joined:
    Sep 22, 2016
    Posts:
    27
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    We have a fix for this coming, all the way back to Unity 2018.4. If you want to work around sooner, here's the source code patch (you can find it at Editor\Data\il2cpp):

    Code (csharp):
    1. diff --git a/libil2cpp/os/Win32/SocketImpl.cpp b/libil2cpp/os/Win32/SocketImpl.cpp
    2. index f63abecd5..5821d2577 100644
    3. --- a/libil2cpp/os/Win32/SocketImpl.cpp
    4. +++ b/libil2cpp/os/Win32/SocketImpl.cpp
    5. @@ -1700,11 +1700,7 @@ namespace os
    6.                  break;
    7.  
    8.              case kSocketOptionLevelIP:
    9. -#ifdef SOL_IP
    10. -                *system_level = SOL_IP;
    11. -#else
    12.                  *system_level = IPPROTO_IP;
    13. -#endif
    14.  
    15.                  switch (name)
    16.                  {
    17. @@ -1777,11 +1773,7 @@ namespace os
    18.                  break;
    19.  #if IL2CPP_SUPPORT_IPV6
    20.              case kSocketOptionLevelIPv6:
    21. -        #ifdef SOL_IPV6
    22. -                *system_level = SOL_IPV6;
    23. -        #else
    24.                  *system_level = IPPROTO_IPV6;
    25. -        #endif
    26.  
    27.                  switch (name)
    28.                  {
     
    Lev095 and SketchWork like this.
  10. adeanHCG

    adeanHCG

    Joined:
    Jan 17, 2020
    Posts:
    5
    Is there an ETA on when this patch will come out? Will it be pushed to Unity 2019.x?
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yeah it going to both 2019.4 and 2018.4. The backport is on the way but I don't have any concrete dates to share.
     
    adeanHCG likes this.
  12. adeanHCG

    adeanHCG

    Joined:
    Jan 17, 2020
    Posts:
    5
    Thank you for the response, does this mean it's live in 2019.4 currently?
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    No, it's not. It will be in a future 2019.4.x release.
     
    adeanHCG likes this.
  14. e-sollinger

    e-sollinger

    Joined:
    Dec 30, 2016
    Posts:
    12
    Is it in 2019.4.3f1?
     
  15. BenjaminBachman

    BenjaminBachman

    Joined:
    Feb 1, 2017
    Posts:
    29
    I have just upgraded to 2019.4.3f1 because I ran into the above problem when building for HoloLens 2. Unfortunately the fix seems not to be included in this version yet.

    However, I was able to manually patch the file "Win32/SocketImpl.cpp" by removing the SOL_IP references and got it working!
     
  16. lackrin_unity

    lackrin_unity

    Joined:
    Jul 14, 2020
    Posts:
    2
    @BenjaminBachman
    I'm running into the same issue, what did you change here to make this happen? can you post your code?
     
  17. BenjaminBachman

    BenjaminBachman

    Joined:
    Feb 1, 2017
    Posts:
    29
    Go to "Installs", click on the 3 dots:
    upload_2020-7-14_23-24-5.png

    Select "Show in Explorer":

    upload_2020-7-14_23-24-32.png

    You should arrive in something like "C:\Program Files\Unity\Hub\Editor\2019.4.3f1\Editor"
    Go to the sub-folder "...\Data\il2cpp\libil2cpp\os\Win32" and open the file "SocketImpl.cpp" in an editor of your choice.

    then go to around line 1700 and delete the lines reading
    • #ifdef SOL_IP
    • *system_level = SOL_IP;
    • #else
    • #endif
    The line reading "*system_level = IPPROTO_IP;" should remain.
    Go to line 1777 and do the same there.

    Restart Unity, rebuild your project. Maybe you have to delete the build folder first.
     
  18. lackrin_unity

    lackrin_unity

    Joined:
    Jul 14, 2020
    Posts:
    2
    when I try this i get the following error
    upload_2020-7-16_11-29-6.png

    Guess i'll have to wait for the official fix.
     
  19. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    That is not a crash. Uncheck "Break when this exception type is thrown" and it will go away.
     
  20. Scanlia

    Scanlia

    Joined:
    Apr 13, 2017
    Posts:
    5
    Just tested this in 2020.1.0f1 and it seems it has still not been fixed yet.
     
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The fix landed to 2020.1.1f1 and 2019.4.5f1. 2018.4 fix is also on the way.
     
    r618, IgorKo, BenjaminBachman and 2 others like this.
  22. Scanlia

    Scanlia

    Joined:
    Apr 13, 2017
    Posts:
    5
    Thank you, I've tested it and it works great!
     
  23. superDiv

    superDiv

    Joined:
    Oct 5, 2020
    Posts:
    1
    This fixed a problem our team ran into where manually installing a new Windows SDK from Microsoft caused issues with IL2CPP builds -- broken sockets as others in this thread have mentioned. Unity just kept trying to build with the newer SDK that was by then uninstalled from the machine. Modifying the keys to the previous SDK version in that registry path fixed this. Thank you very much for that solution!
     
  24. LT23Live

    LT23Live

    Joined:
    Jul 8, 2014
    Posts:
    98
    This was also the fix for me. In my case it was Unity UWP with Socket IO. I had downgrade the version to 10.0.17134.0
     
    DianaAlvarez likes this.
  25. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254

    I encountered this issue out of the blue on an release build that didn't have it before and implemented your quick fix as updating my unity version is out of the question at the moment so thank you for saving the build.

    That said, I'd love for someone to explain the actual cause of the issue to me so I can better understand what went wrong and why. The same build version has been working just fine for almost 6 months, then suddenly failed and wouldn't work anymore.