Skip to content

Flutter should use Metal instead of OpenGL on iOS #18208

Closed
flutter-team-archive/engine
#17431

Description

@eseidelGoogle

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-metal GN 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-metal shell 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:


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

  1. eseidelGoogle commented on Jun 6, 2018

    @eseidelGoogle
    ContributorAuthor

    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.

  2. amrsolimanmoustafa commented on Jun 6, 2018

    @amrsolimanmoustafa

    I am now developing my first mobile app with flutter when i publish it apple store through couple of week what will happen ?

  3. pvmhoang commented on Jun 6, 2018

    @pvmhoang

    I hope Flutter Dev Team will give us the answer about this one soon. I have just started to learning Flutter :(

  4. eseidelGoogle commented on Jun 6, 2018

    @eseidelGoogle
    ContributorAuthor

    Apple has not announced any removal of OpenGL support. Flutter works great on iOS, including iOS 12.

  5. Chozzle commented on Jul 27, 2018

    @Chozzle

    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.

  6. Chozzle commented on Aug 8, 2018

    @Chozzle

    Any update on using MoltenVK? Does anyone know if this would allow much 2d performance improvement?

  7. SAGARSURI commented on Sep 9, 2018

    @SAGARSURI

    Even I am eagerly looking for an update on this from the dev team.

  8. eseidelGoogle commented on Sep 10, 2018

    @eseidelGoogle
    ContributorAuthor

    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).

  9. added this to the milestone on Oct 16, 2018
  10. 15 remaining items

  11. Hixie commented on Oct 22, 2019

    @Hixie
    Contributor

    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).

  12. stuartmorgan-g commented on Oct 22, 2019

    @stuartmorgan-g
    Contributor

    that would drop support for <iOS10

    Also the iPhone 5 and 5c, and the 4th generation iPad, all of which can run iOS 10, but don't support Metal.

  13. fisforfaheem commented on Mar 4, 2020

    @fisforfaheem
  14. dannyvalentesonos commented on Mar 27, 2020

    @dannyvalentesonos
    Contributor

    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).

    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!

  15. chinmaygarde commented on Mar 27, 2020

    @chinmaygarde
    Contributor

    @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.

    will plugins like the video_player which use the Texture Registry work immediately?

    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.

  16. added a commit that references this issue on Mar 31, 2020
  17. chinmaygarde commented on Apr 1, 2020

    @chinmaygarde
    Contributor

    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.

  18. added a commit that references this issue on Apr 1, 2020
  19. lock commented on Apr 15, 2020

    @lock

    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 -v and a minimal reproduction of the issue.

  20. locked and limited conversation to collaborators on Apr 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

dependency: skiaSkia team may need to help usengineflutter/engine related. See also e: labels.platform-iosiOS applications specifically

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions