metalangle
metalangle copied to clipboard
MGLKitSampleApp_ios9.0 crashes on launch on device running iOS 10.x
ERR: initialize(609): ANGLE Display::initialize error 12289: Could not create the EAGL context. ERR: initialize(609): ANGLE Display::initialize error 12289: Could not create the EAGL context. INFO: insertMessage(462): EGL CRITICAL: eglInitialize: Could not create the EAGL context. (lldb) bt
- thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1
- frame #0: 0x002a6d00 MetalANGLE
(anonymous namespace)::Throw(msg="Failed To call eglInitialize()") at MGLDisplay.mm:13:5 frame #1: 0x002a6c4e MetalANGLE-[EGLDisplayHolder init](self=0x1654dc20, _cmd="init") at MGLDisplay.mm:37:13 frame #2: 0x002a709e MetalANGLE-[MGLDisplay init](self=0x165510c0, _cmd="init") at MGLDisplay.mm:82:36 frame #3: 0x002a6f90 MetalANGLE+[MGLDisplay defaultDisplay](self=MGLDisplay, _cmd="defaultDisplay") at MGLDisplay.mm:71:27 frame #4: 0x0033f6a8 MetalANGLE-[MGLLayer constructor](self=0x16551ea0, _cmd="constructor") at MGLLayer.mm:351:16 frame #5: 0x0033f444 MetalANGLE-[MGLLayer init](self=0x16551ea0, _cmd="init") at MGLLayer.mm:330:9 frame #6: 0x200b3bb6 UIKit-[UIView _createLayerWithFrame:] + 138 frame #7: 0x200b3714 UIKitUIViewCommonInitWithFrame + 850 frame #8: 0x20382b36 UIKit-[UIView initWithCoder:] + 458 frame #9: 0x00337372 MetalANGLE-[MGLKView initWithCoder:](self=0x00000000, _cmd="initWithCoder:", coder=0x16881200) at MGLKView.mm:24:16 frame #10: 0x205823ba UIKit-[UIClassSwapper initWithCoder:] + 218 frame #11: 0x206bc6ee UIKitUINibDecoderDecodeObjectForValue + 834 frame #12: 0x206bc3a4 UIKit-[UINibDecoder decodeObjectForKey:] + 82 frame #13: 0x205820d2 UIKit-[UIRuntimeConnection initWithCoder:] + 160 frame #14: 0x206bc6ee UIKitUINibDecoderDecodeObjectForValue + 834 frame #15: 0x206bc646 UIKitUINibDecoderDecodeObjectForValue + 666 frame #16: 0x206bc3a4 UIKit-[UINibDecoder decodeObjectForKey:] + 82 frame #17: 0x20581632 UIKit-[UINib instantiateWithOwner:options:] + 1082 frame #18: 0x203ffade UIKit-[UIViewController _loadViewFromNibNamed:bundle:] + 314 frame #19: 0x201deaba UIKit-[UIViewController loadView] + 136 frame #20: 0x200b1b9a UIKit-[UIViewController loadViewIfRequired] + 170 frame #21: 0x200b1ad8 UIKit-[UIViewController view] + 22 frame #22: 0x200b805a UIKit-[UIWindow addRootViewControllerViewIfPossible] + 72 frame #23: 0x200b55ba UIKit-[UIWindow _setHidden:forced:] + 286 frame #24: 0x20125158 UIKit-[UIWindow makeKeyAndVisible] + 42 frame #25: 0x20322b12 UIKit-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3906 frame #26: 0x20327c1c UIKit-[UIApplication _runWithMainScene:transitionContext:completion:] + 1640 frame #27: 0x2033a7c4 UIKit__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke.3149 + 40 frame #28: 0x2032535a UIKit-[UIApplication workspaceDidEndTransaction:] + 142 frame #29: 0x1c760c12 FrontBoardServicesFBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 18 frame #30: 0x1c760acc FrontBoardServices-[FBSSerialQueue _performNext] + 220 frame #31: 0x1c760db6 FrontBoardServices-[FBSSerialQueue _performNextFromRunLoopSource] + 44 frame #32: 0x1ae3bfdc CoreFoundation__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12 frame #33: 0x1ae3bb04 CoreFoundation__CFRunLoopDoSources0 + 424 frame #34: 0x1ae39f50 CoreFoundation__CFRunLoopRun + 1160 frame #35: 0x1ad8d1ae CoreFoundationCFRunLoopRunSpecific + 470 frame #36: 0x1ad8cfd0 CoreFoundationCFRunLoopRunInMode + 104 frame #37: 0x2011ae2c UIKit-[UIApplication _run] + 660 frame #38: 0x20115a52 UIKitUIApplicationMain + 150 frame #39: 0x00031f12 MGLKitSampleApp_ios9.0main(argc=1, argv=0x0029fa1c) at main.m:25:12 frame #40: 0x1a57a4ea libdyld.dylib`start + 2 (lldb)
- frame #0: 0x002a6d00 MetalANGLE
I don't have iOS 10.x devices but I tried to run on simulator, and couldn't reproduce this issue (at least with current master branch).
It doesn't crash on the emulator for me either. Could it be a 32-bit (armv7) vs 64-bit (arm64 issue)? The device I am running it on is 32 bit.
Based on your posted log messages. It seems the process failed at this line: https://github.com/kakashidinho/metalangle/blob/4ccacad6cffac142f7b0162685a839a7c3d5c431/src/libANGLE/renderer/gl/eagl/DisplayEAGL.mm#L91
Which means mContext = [[EAGLContext alloc] initWithAPI:kGLESAPI]; failed. It's probably due to the phone's hardware doesn't support native OpenGL ES 3 (iPhone 5 and below).
This is the current limitation of MetalANGLE. On older devices, I fall back to use native OpenGL ES backend, but that back-end is not maintained by me. My main focus is Metal backend. OpenGL ES backend was maintained by upstream ANGLE and from what I know, they still support OpenGL ES 3.0+ hardwares only.
I don't think iPhone 5 and below have much market share currently. So they are low priorities in the support list.
Thank you very much. Your analysis is correct. Once I made these changes it works.
//constexpr EAGLRenderingAPI kGLESAPI = kEAGLRenderingAPIOpenGLES3; constexpr EAGLRenderingAPI kGLESAPI = kEAGLRenderingAPIOpenGLES2;
I have a bit similar issue. But in my case I can run the sample (and any other app) on real devices flawless but I can't run them in any simulator. I get the following output which is a bit different to the one of this issue, but has the same eglError code: https://gist.github.com/Berstanio/81708a6431d0bcda2145143591062eec
//constexpr EAGLRenderingAPI kGLESAPI = kEAGLRenderingAPIOpenGLES3; constexpr EAGLRenderingAPI kGLESAPI = kEAGLRenderingAPIOpenGLES2;
This change didn't fixed the issue.
I don't exactly know how the ios simulator works but a idea of mine was, that this could be related to the fact, that I run macos in a vm. Could this produce the issue? And if this is the case, is there any way to fix this?
@Berstanio macos in a vm doesn't support metal, so it failed to create a metal device:
MTLCreateSystemDefaultDevice() zero devices