Metal texture validation failure

I have a Unity app inside an iOS app. Basically I took control of main from Unity and integrate UnityAppController to work with AppDelegate lifecycle in harmony. While taking iOS export, I chose background behaviour of Unity to be Exit with IL2CPP scripting, auto graphics enabled, leaving sprite format as default (RGBA Compressed PVRTC 4 bits).

There is one UIViewController which contains UnityGLView as a subView. It waits Unity to be ready before calling UnityGetGLView. After that, it simply sets constraints of UnityGLView, with leading and trailing anchors to be equal to superview, topAnchor to match bottom of topLayout and finally bottomAnchor to be equal to bottom of superview minus 44 (height of a custom view much like a banner ad).

I pause Unity with UnityWillPause and UnityPause functions each time before the UIViewController disappears and resume when the view appears again. Loading UnityGLView as described above, waits a Unity callback to give it time loading the scene preventing an old scene submission to the user.

Everything was working fine until I started to get a crash report. When the app enters the background and than come back to foreground again, UnityAppController seems to fail validating textures. This does not occur frequently, and seems independent from device model and iOS version.

The crash info states:

validateTextureDimensions:681: failed
assertion `MTLTextureDescriptor has
width of zero.’

The stack-trace is as [87178-crash.txt|87178].

Any help would be much appreciated.

@burakvl We too faced the same issue. The issue is unitygetglview() frame becomes zero after the viewcontroller, which holds the unityview, is dismissed. it seems the zero frame issue occurs when we use autolayout constraints. the fix is to set the frame of unityglview directly instead of autolayout constraints


I’m facing the same problem and it is not happening all the time. So reproducing the problem is very hard. Do you have a sample code for the solution?


I’m facing the same problem. How to fix it do you have a sample code or something that would be great!