App freezes when ARSCNView is removed from view hierarchy

Hello 👋

We have a ARSCNView presented on screen. During presentation of that screen we capture some data that is provided by ARSessionDelegate.
After the capture we present a new screen which uses a new SCNView to present the result of the capture.

We observed hard to reproduce app freezes during transition from one screen to the other.

Looking at the stack trace, there seem no of our code to be directly involved in the deadlock.

I need some help if others faced the same issue or can point to something I did overlook here.

I have filed a feedback for this too: FB9079953




Code Block language
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x00000001c02c9204 in __psynch_mutexwait ()
#1 0x00000001dd804a78 in _pthread_mutex_fairshare_lock_wait ()
#2 0x00000001dd8049cc in _pthread_mutex_fairshare_lock_slow ()
#3 0x00000001c67b9d74 in -[SCNView _adjustBackingLayerPixelFormat] ()
#4 0x00000001c67bee24 in -[SCNView didMoveToWindow] ()
#5 0x00000001c3b98714 in -[ARSCNView didMoveToWindow] ()
#6 0x000000019598bf5c in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#7 0x000000019598ba1c in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#8 0x000000019598ba1c in -[UIView(Internal) _didMoveFromWindow:toWindow:] ()
#9 0x000000019597f324 in __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke ()
#10 0x000000019597f210 in -[UIView(Hierarchy) _postMovedFromSuperview:] ()
#11 0x000000019597cf24 in __UIViewWasRemovedFromSuperview ()
... see full trace in attachement

I have a similar issue with a very small number of customers (2/100) with iphone 8 and ipad on iOS 14.6, but for them it happens every time. We have tried to repro using the same phones without success. The first frame is displayed, then the view freezes. The app does not freeze though and is working normally. The app is still able to shutdown the ARSCNView and restart it. With the same result (ie: only the first frame is displayed).

App freezes when ARSCNView is removed from view hierarchy
 
 
Q