Unreal Editor hangs for Mac OS X

Hmm… I still encounter the issue without the specific reproduce step I mentioned, just continuous use of the engine hit case again on Mac OS X. I started to use source version and commented the SafeRelease() line in FTargetDeviceService::~~FTargetDeviceService(), as a fix. It never hits the problem again.

I made some observations:

  1. Mac OS X Only. I also tested binary version of UE4 Editor. The issue doesn’t occur.
  2. Editor Only. FTargetDeviceService is for developers. (I think?)
  3. MessageEndpoint is already ThreadSafe shared pointer what’s the point of this infinite loop in SafeRelease in FTargetDeviceService::~FTargetDeviceService()?
  4. The freeze (hanging) can be simulated whenever you create another FTargetDeviceService instead right before old FTargetDeviceService::~FTargetDeviceService() is invoked. Obviously, The code seems to be multi-threaded. I think this is the cause.

My fix works for me on Mac OS X. I cannot test all the platforms, and I don’t see the side effects from doing this specifically. So, I cannot do github pull request for this. But, I would put a comment here for reference.

I just encountered this same issue when doing an initial load of our project on a new machine. Commenting out the suggested line let it continue further but it eventually crashed on the first line of FTargetDeviceService::HandleClaimedMessage because FTargetDeviceService::DeviceName was invalid (I’m guessing the entire FTargetDeviceService was). I was able to proceed by unpairing all devices in Xcode.

Would love to know what the proper fix is here. My best guess for repro would be to do a first-time load of a large-ish project with an AMD GPU installed and an iPhone connected to Xcode via WiFi. For reference, I’m using a source code build of Unreal Engine 4.18.3, opening/running the project via Xcode, and have an iPhone X that was previously paired to Xcode via WiFi.

My system is a 2017 MacBook Pro: 3.1 GHz Core i7, 16 GB RAM, Radeon Pro 560 4GB, Intel HD 630.