Repository navigation
Flutter should use Metal instead of OpenGL on iOS #18208
Description
From #33079:
Based on guidance from the Skia team, the Metal backend is ready for integration into Flutter. This is a meta-bug listing the various tasks that need to be undertaken for the switch to be completed.
The Skia Metal backend is currently only available on iOS versions 11.0 and above. It is unlikely that the minimum supported version will be lowered all the way down to 8.0 (the current minimum supported by Flutter). The recommended approach is to compile both the OpenGL and Metal backends in the iOS engine and use runtime checks to only use the Metal backend on versions 11.0 and above. OpenGL will still be used on older iOS versions till support for the same persists.
Tasks
Tracked on this project board but the major ones are:
- Add the
enable-metalGN flag to existing builds of the iOS engine and re-baseline benchmarks that measure binary size. Binary sizes are expected to regress by around 220 Kbytes uncompressed. - Enable the Metal backend on iOS versions 11.0 and above.
- Add an
enable-metalshell flag that allows overriding the rendering backend to use without needing version checks. Duplicate all existing benchmarks to run the same with the Metal backend in addition to the OpenGL backend. - Ensure plugins that that provide pixel buffers to to the engine for inline composition have the appropriate compatibility flags set.
- Ensure platform views are wired up.
References:
- Notice of OpenGL deprecation on iOS: https://developer.apple.com/ios/whats-new/
- Notice of OpenGL deprecation on Mac: https://developer.apple.com/macos/whats-new/
- Related Flutter issues: ☂️ Switch to Metal for macOS shell #32569, Flutter should use Metal instead of OpenGL on iOS #18208
This is really a Skia bug, but tracking it here since we've gotten a flood of questions about this after Apple's announcement this week of deprecating OpenGL.
My understanding is Skia has an experimental Metal backend, but it would take some work to bring it to production ready.
Skia also already has a Vulkan backend which Flutter uses on Fuchsia, and has historically used on some Android phones (and could use again if there was demand -- it was recently disabled due to lack of demand).
Another advantage of moving to Metal sooner rather than later is that I'm told that Apple's GL drivers appear to be less maintained than they used to be, and Flutter/Skia have seen a resulting up-tick in Apple-specific GL bugs.
Activity
eseidelGoogle commentedon Jun 6, 2018
Filed a bug with Skia https://bugs.chromium.org/p/skia/issues/detail?id=8050 and have reached out to the team directly. There is some non-trivial amount of work to do here, but certainly possible.
amrsolimanmoustafa commentedon Jun 6, 2018
I am now developing my first mobile app with flutter when i publish it apple store through couple of week what will happen ?
pvmhoang commentedon Jun 6, 2018
I hope Flutter Dev Team will give us the answer about this one soon. I have just started to learning Flutter :(
eseidelGoogle commentedon Jun 6, 2018
Apple has not announced any removal of OpenGL support. Flutter works great on iOS, including iOS 12.
Chozzle commentedon Jul 27, 2018
I think improvements need to be made quickly on the graphics rendering pipeline. This is the biggest thing holding our company back from developing in flutter. Look at the Hamilton app on an iPhone 6 for an example of unacceptable performance.
Chozzle commentedon Aug 8, 2018
Any update on using MoltenVK? Does anyone know if this would allow much 2d performance improvement?
SAGARSURI commentedon Sep 9, 2018
Even I am eagerly looking for an update on this from the dev team.
eseidelGoogle commentedon Sep 10, 2018
The bug to track is in Skia: https://bugs.chromium.org/p/skia/issues/detail?id=8050. Once Skia has support for Metal, Flutter's Engine can also add support. There likely won't be any updates to this bug in Flutter until the Skia issue is resolved. We speak with Skia team members regularly and they're aware of the ask.
Flutter works great on iOS today. However, we expect Flutter may work even better on iOS with Metal in the long-term (as I'm told OpenGL drivers on iOS are less well maintained than Metal ones).
15 remaining items
Hixie commentedon Oct 22, 2019
We were discussing this in today's Triage meeting. Our current plan is to turn Metal on soon. This will increase the size of our engine by ~200KB. We can eventually reduce this by removing the OpenGL code but (a) that would drop support for <iOS10, which we don't want to do anytime soon (Skia only does Metal from iOS10), and (b) would require some work from the Skia team (OpenGL can't currently be removed from the codebase).
stuartmorgan-g commentedon Oct 22, 2019
Also the iPhone 5 and 5c, and the 4th generation iPad, all of which can run iOS 10, but don't support Metal.
fisforfaheem commentedon Mar 4, 2020
dannyvalentesonos commentedon Mar 27, 2020
Hi @Hixie . Is there an update on when Flutter will be using Metal?
Also, once it is turned on, will plugins like the video_player which use the Texture Registry work immediately?
Thanks!
chinmaygarde commentedon Mar 27, 2020
@dannyvalentesonos: The March 2020 milestone is accurate. Metal is currently feature complete on iOS and gated behind a flag. Will provide updated guidance in a couple of days.
Yes, plugins that use the texture registry like the video player and the camera are tested to work. More guidance surrounding applications that use the texture registry to provide texture created using OpenGL for inline composition in Flutter will be forthcoming.
Use Metal on iOS by default.
chinmaygarde commentedon Apr 1, 2020
I am landing flutter-team-archive/engine#17431 which turns Metal on-by-default on iOS. A Metal on iOS FAQ Wiki page attempts to answer all questions pertaining to this change.
Use Metal on iOS by default. (#17431)
lock commentedon Apr 15, 2020
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.Use Metal on iOS by default. (flutter-team-archive#17431)
Use Metal on iOS by default. (flutter-team-archive/engine#17431)