Unity and IPv6 Support
Apple recently announced that beginning June 1, 2016, “all apps submitted to the App Store must support IPv6-only networking.” Since many of our users publish Unity games to the App Store, we wanted to take a moment to discuss Unity’s support for IPv6-only networks. Note that this requirement applies to both new app submissions and updates to existing apps.
What is IPv6?
From the Wikipedia article: “Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet.” Devices can operate on an IPv4-only network (the previous standard), and IPv6-only network, or a network with both protocols in use. Apple’s new requirement means that apps must be able to operate in an IPv6-only network.
It is important to understand that IPv4 and IPv6 networks do not interoperate, although it is possible to pass traffic from one type of network over the other with tunnelling.
Does Unity support IPv6?
Yes! WWW and UnityWebRequest are IPv6 compatible on iOS out of the box because they are based on high level Apple networking APIs. And over the past few months we have been working to bring support for IPv6-only networks to Unity’s .NET/IL2CPP libraries. Our last known IPv6 bugs related to .NET/IL2CPP were corrected in the 5.3.4p4 patch release. There is one fix pending for UNET which is going to be shipped in coming weeks. Thanks to help from great members of our community (like Exit Games) we have been able root out a number of bugs in the Unity Engine code and provide support for IPv6-only networks on the following platforms:
- Editor: All platforms
- Standalone player: All platforms
We’ll continue to add support for IPv6-only networks on other platforms in the future.
What about older versions of Unity?
If you are using only WWW or UnityWebRequest APIs to access network resources you should be fine, though please test your games carefully.
We are also planning to backport our .NET/IL2CPP fixes to selected older lines of Unity and release them as 4.7.2, 5.1.5 and 5.2.5 updates.
What should you do?
First, test your game in IPv6-only setup to assess if all the game features work as intended. This guide from Apple goes through the setup of an IPv6-only testing network using a Mac with OS X 10.11 or later. This is the same testing that App Store reviewers will use, so it is a good place to start with IPv6 testing. Since IPv4 and IPv6 networks cannot interoperate, you must test on an IPv6-only network to ensure everything is working well. If your device has both IPv6 and IPv4 addresses, then socket operations could succeed using IPv4.
Second, audit your code for a few indicators of possible problems:
- Look for the use of IPv4 addresses (e.g. 127.0.0.1, 220.127.116.11). Any use of such hardcoded addresses should be removed. Prefer host names, which can be used to look up the proper IPv4 or IPv6 address of a given device for the proper type of network.
- Look for the use of the IPAddress.AddressFamily property. If the code branches based on the value of the property, is there a branch that handles IPv6 properly?
- Look for the use of the IPAddress.Any and IPAddress.Loopback fields. These fields work with IPv4 addresses, not IPv6 addresses. Use the IPAddress.IPv6Any and IPAddress.IPv6Loopback fields as well to ensure IPv6 support.
If you encounter troubles beyond the ones mentioned above, please make sure you are using a build with the necessary fix in it. If a fix has not yet landed in your line (4.7.x, 5.1.x, 5.2.x), wait until we have released a patch with it. Then proceed to upgrade to this version.
Some of 3rd party native and managed networking plugins might also be not compatible with IPv6 networks, please consider reaching out plugin vendor for their compatibility status.
Finally, let us know if you encounter bugs in Unity related to IPv6. We will work hard to correct them as soon as possible. For issues specifically related to the App Store requirements, visit the iOS and tvOS development section of our forums. I’ll be hanging out there to help.
Update: 4.7.2 is live now: http://unity3d.com/get-unity/download/archive
Update #2: 5.2.5 is live too: http://unity3d.com/get-unity/download/archive (scroll down below 5.3.x updates).
Update #3: 5.1.5 is live too: http://unity3d.com/get-unity/download/archive (scroll down below 5.2.x updates).