malloc error occurring when connecting to server on device with IL2CPP

Options
We've been building multiplayer support for our game for a while, but we've been initially focused on PC/Mac where Photon has been working great. However, on iOS we're running into a showstopper problem. It happens with our own code as well as the demo projects that come with the SDK.

On device, building with IL2CPP Universal (which is now required for the App Store), whenever Photon connects to the server, it gets a malloc error as follows:

photonsandbox(2290,0x16e19f000) malloc: *** error for object 0x14f723ff0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

If you use Mono 2.x you do not get this error, but this has to work with IL2CPP due to App Store requirements.

I'm not sure when this problem started happening, but it happens in Unity 5.0.2p2 as well as Unity 5.2.1f1. We're using Photon-Unity3D-Sdk_v4-0-0-10. I can reproduce the problem every time on an iPad Air 2 and an iPhone 5s (and probably other devices).

Steps to reproduce every time:
Open the demo-turnbased-sandbox project.
Set an API key in the DemoScene.
Change to iOS platform and set the following player settings:
Scripting Backend: IL2CPP
Architecture: Universal
Bundle Identifier: something that will work for your certs
Build the game and open the Xcode project. Turn off "Enable Bitcode" in the build settings there.
Build & Run on device.
Enter a player name and press Connect.

Comments

  • Hmm, actually this problem may be solved in Unity 5.2.1. I thought I tested with that but now it seems to work!