kivy-ios
kivy-ios copied to clipboard
[WIP] MetalANGLE support?
Apple deprecated OpenGLES.framework
since iOS 12.
This is a first-stage testing and migration to MetalANGLE
, a OpenGL ES to Metal API translation layer.
It's something I'm going to work on weekends, I hope is going to be ready for when Apple will remove support for opengles.
TODO:
- [ ] Test, test, test, test, and test again
- [x] Wait for
glGenerateMipmap
fix or disable mipmap - [x] Cleanup
KNOWN ISSUES:
Tested over touchtracer
and showcase
and works fine with mipmapping disabled.
- :heavy_check_mark: mipmap issue got fixed thanks to @kakashidinho (The author of
MetalANGLE
). - :mailbox: I proposed to the SDL2 team a migration to
MetalANGLE.framework
in order to not rely on my patched repo in the future. - :factory: Updated toolchain to automagically include embedded frameworks inside the project
Testing it's still appreciated
Update:
-
I had to add a fix in order to remove the un-needed archs from
MetalANGLE.framework/MetalANGLE
because Apple Store Validation was refusing Universal frameworks. -
~~Now it seems failing with this error: https://github.com/kakashidinho/metalangle/issues/13~~ (fixed via https://github.com/kakashidinho/metalangle/commit/1964ec02f475dc210300313d543f2cd8f96de9bb)
If this is merged, I noticed that XCode fails to build the app because the target is iOS 8.1+ and Metal is only supported on iOS 12+
@mbrockman1 It's not merged yet. You're using it for some specific reason or just for testing?
@misl6 Only for testing. You are a legend for setting this up by the way. If it is helpful, I could identify all the problems I had from start to finish in making the app using your branch.
@mbrockman1 Sounds good to have some testing and reporting!
FYI: I'm not expecting to remove the WIP tag and requesting for a merge until at least one of these two conditions are met:
-
Apple removes support for OpenGL
-
An intuitive and recipe oriented method for selecting OpenGL vs MetalANGLE during compilation is available.
I was working on the 2nd option, but then I had to stop due to lack of free time.
Apart of that, feel free to send bug reports or suggestions!
I posted this in discord. I was using a blend of your pull request plus the latest Kivy-iOS master to attempt to release an app. Here is a list of the problems and how I revolved them:
- Had to hard code Python.h and initconfig.h in Xcode
*fix: https://www.reddit.com/r/kivy/comments/gr1zep/xcode_validate_fails_cant_find_pythonh/*
- Line 1473 & 1477 of kivy-ios/toolchain.py was causing an import error
Import xcassets => from .tools.external import xcassets
- Had issues with icon generation to the point where I had to make my own and put them into the assets folder. I dont know if it is related to xcassets import or not.
- The MetalAngle branch worked well, only thing that needed adjustment was increase the target deployment to iOS 12+ from iOS 8.1+ because that is when Metal started support.
- Missing purpose string for NSCamera fixed by following this: https://stackoverflow.com/questions/44690075/xcode-missing-info-plist-key-for-nscamerausagedescription/49439492#49439492
- Had to specify “-exportOptionsPlist” but regardless buildozer iOS release didnt work so I had to release it via Xcode. Link: https://github.com/kivy/kivy-ios/issues/326#issuecomment-451656753
- Had to cut iPad support due to this issue: https://forum.defold.com/t/error-itms-90474-invalid-bundle-ipad-multitasking-support-requires-these-orientations/56128
FYI, MetalANGLE requires iOS min version 9.0 not 12.0. You can set deployment target 9.0 and it should still work (although it will fallback to native OpenGL on pre iOS 11.0 devices but from application point of view everything will work the same)
Some updates:
- I did a complete rework of the SDL2 code, so it could hopefully get merged into the SDL2 upstream, I will submit a PR ASAP.
- Now We share the same SDL codebase for both MetalANGLE and OpenGLES versions of SDL2 provided views.
- Our user is able to select the needed (by default it's still OpenGLES) SDL2 by using an environment variable (
export KIVYIOS_USE_METALANGLE=1
) - Now We're downloading the provided binaries for
MetalANGLE
without building them. (Definitely faster, but that behavior could be changed if someone have some concerns about it)
What is unsupported right now:
- Due to how Apple
Framework
are managed, at this time (due to lack of time) We're unable to build for both iOS and iOS Simulator without the intervention of the user, by default, the toolchain selects iOS. This could be easily managed by creating anxcframework
Will add a specific section for "Building with MetalANGLE.framework
in README.md after the SDL PR.