iOS Device Disconnect Sometimes Blocks Editor Forever

Here’s a fun little issue.

Sometimes when I load maps (that usually take ~2 mins) progress will be made for maybe a minute and then it just hangs.

Breaking in LLDB and checking what the main thread is doing I can see that it’s handling a DoDeviceDisconnect for my iPhone and forever blocking in MessageEndpoint::SafeRelease due to the fact that there’s a shared reference of that pointer somewhere. [Here’s the backtrace from LinkerLoad → Slate Tick → Message Pump → Disconnect Event and subsequent blocking][1].

The iOS device being disconnected is my iPhone, which isn’t even physically connected to my laptop, but they’re on the same WiFi so I guess that’s how they find each other, and I’m guessing there’s some choppiness in the WiFi causing the disconnect. It has only happened during map load, and it doesn’t happen every time. Activating Flight Mode on my phone prevents it from happening altogether.

I guess the main question is: who has the outstanding reference to the message endpoint, and why won’t they give it back.

Have fun,
.

https://gist.githubusercontent.com/mollstam/6cbd45c264a2057e534b/raw/2f4b5a869a1770f9bf743d53bf09a92f16925ef3/gistfile1.txt

Hey ,

Thank you for bringing this to our attention. In order to better assist you, I have a few questions. Are you working within 4.8.2 through the Epic Games Launcher? Also, when you say that your iOS device blocks the editor, are you trying to launch or package a project onto that device at that given time? If not, what exactly are you doing? Do you have your iOS device and the laptop synced up with bluetooth?

Looking forward to hearing back from you, thanks!

Hey ,

I have not heard from you in quite a few days and for that reason, I must mark this thread as resolved. However, if you have any further questions regarding this topic, do not hesitate in replying back. Thanks!

Hi , sorry for not replying earlier, went into vacation mode.

I’m running the editor in debug from the command-line through lldb, compiled from GH master with Build.sh. The project I’m working on isn’t setup with my phone, nor have I ever packaged it for it or anything. I’m not actively interacting with the phone. I guess that OS X and my phone is keeping an open link (due to “Sync over Wi-Fi” option on the device in iTunes), which sometimes will trigger a disconnect/connect on the OS level, dispatching an event to the device managing code in UE.

I could check when at home if I can trigger the bug more predictably.

I realize the description is a bit abstract, and the case probably pretty narrow.

I would suggest turning your bluetooth and any options to sync over wifi/bluetooth to be disabled when you’re working within UE4 as well. Make sure that you trust your computer on your device too, otherwise the project will not be able to push onto the device as intended.

Thanks!

Just to make sure we’re on the same page: I don’t want to push to my phone, I’m working on a desktop game. But having your Mac and your iDevice on the same choppy wifi will sometimes block the editor forever, due to the OS layer sending a disconnect event to UE4 which ends up in FMessageEndpoint::SafeRelease(…) which has a note:

MessageEndpoint.h:755
Note: When calling this function make sure that no other object is holding on to the endpoint, or otherwise the caller may get blocked forever.

If the recommended solution for this is to disable WiFi on your iDevice while working on any project in UE4 on your computer I’m fine with that, but it sounds kind of wonky.

Hey ,

I wanted to let you know that I have reached out to our iOS developers and I am waiting on some information. We will update you as soon as possible, thank you for your patience!

Cheers, no worries! It’s not a blocker for me. :slight_smile:

Right now there is bug with devices that have Sync over Wifi enabled. We only recently figured out it was that option causing the issue, so it won’t be fixed in 4.9 (plus we never see it internally because our PCs are on a different subnet from the devices). However, in the mean time if you disable Sync over Wifi, it should resolve the issue until we can get a fix in.

-Pete

Hi, just had the same issue with 4.11p1, attached a stacktrace

Hey MacAndor,

Could you please provide us with the [full ][1] as a .txt file? Please attach it to your next reply.

A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums

Hi,

Sorry for the late response, but here are some dumps, , etc:
[Sample in deadlock state][1]
[Unreal Engine project log][2]
[Unreal Engine log][3]

I checked the iOS device , nothing there, but then again I created a desktop project, which should have nothing to do with my mobile devices.

Reproducing this bug is quite easy for me:

  • I have an Apple Airport router

1, Have an iOS device on the same network as your computer and make sure it is connected via the MobileDevice framework
2, Create a new project in UE 4 (I created advanced vehicle)
3, After project inited, turn off wifi and BT on your device (this may take a few tries)

If you need any more info, I’ll try to provide as much as I can.

Best Regards,
MacAndor

72813-sample+of+unreal+editor.txt (182 KB)
[2]: 72814-myproject.log (12 KB)
[3]: 72816-ue4.log (31.2 KB)

MacAndor,

Thank you for providing us with this information. I have looked through and found UE-11999. Unfortunately, it is not resolved yet. It’s set as a ‘normal’ priority bug that has been backlogged. We currently do not have a fixed version in place.

FYI, this is still happening to me in 4.20.1, on MacOS 10.14 beta. I didn’t have any device connected while it happened.

So I’ve come up with a fix which ignores devices that are not physical attached to the Mac (it seems for some reason, as long as the Mac and iOS devices are in the same network, it’s considered “connected”):

void FIOSDeviceHelper::DoDeviceConnect(void* deviceHandle)
{
    // connect to the device
    IOSDevice* Device = new IOSDevice(deviceHandle);
    bool Connected = Device->Connect();
    if (Connected)
    {
        // get the needed data
        CFStringRef deviceName = AMDeviceCopyValue(deviceHandle, 0, CFSTR("DeviceName"));
        CFStringRef deviceId = AMDeviceCopyValue(deviceHandle, 0, CFSTR("UniqueDeviceID"));
		CFStringRef productType = AMDeviceCopyValue(deviceHandle, 0, CFSTR("ProductType"));
        
        auto hostAttached = (CFBooleanRef)AMDeviceCopyValue(deviceHandle, 0, CFSTR("HostAttached"));
        if (hostAttached)
        {
            auto attached = CFBooleanGetValue(hostAttached);
            CFRelease(hostAttached);
            if (!attached)
            {
                return;
            }
        }
        ...
    }
}