maplibre-native icon indicating copy to clipboard operation
maplibre-native copied to clipboard

Metal support in iOS

Open rbrundritt opened this issue 3 years ago • 10 comments

OpenGL ES is deprecated in iOS 12, in favor of Metal which is pretty significant. Copying over issue from Mapbox GL native: https://github.com/mapbox/mapbox-gl-native/issues/12061

rbrundritt avatar Feb 16 '21 16:02 rbrundritt

MetalANGLE is a translation layer that could potentially be used to map OpenGL ES calls to Metal: https://github.com/kakashidinho/metalangle

systemed avatar Feb 24 '21 13:02 systemed

I tried out MetalANGLE and after a couple of tweaks it works well. I will prepare a PR once I cleanup the code. Here are the benchmark results of the Debug build (both MapLibre and MetalANGLE) running on Simulator. We should be able to hit 60 fps with a Release build:

2021-03-01 12:28:56.056928-0800 Bench GL[42138:8510478] Benchmark completed. 2021-03-01 12:28:56.056990-0800 Bench GL[42138:8510478] Result: 2021-03-01 12:28:56.057061-0800 Bench GL[42138:8510478] | paris | 51.8 fps | 2021-03-01 12:28:56.057130-0800 Bench GL[42138:8510478] | paris2 | 42.4 fps | 2021-03-01 12:28:56.057197-0800 Bench GL[42138:8510478] | alps | 59.0 fps | 2021-03-01 12:28:56.057264-0800 Bench GL[42138:8510478] | us east | 57.1 fps | 2021-03-01 12:28:56.057340-0800 Bench GL[42138:8510478] | greater la | 54.0 fps | 2021-03-01 12:28:56.057402-0800 Bench GL[42138:8510478] | sf | 41.4 fps | 2021-03-01 12:28:56.057497-0800 Bench GL[42138:8510478] | oakland | 52.3 fps | 2021-03-01 12:28:56.057569-0800 Bench GL[42138:8510478] | germany | 59.8 fps | 2021-03-01 12:28:56.057677-0800 Bench GL[42138:8510478] Total FPS: 417.8 2021-03-01 12:28:56.057816-0800 Bench GL[42138:8510478] Average FPS: 52.2

sulewicz avatar Mar 02 '21 17:03 sulewicz

FWIW for others interested in the matter, an experimental metal-support branch has landed through PR #40.

rotoglup avatar Mar 12 '21 14:03 rotoglup

Test Results of Archive & upload to App Store Connect (TestFlight) of the MapLibre test app iosapp with MapLibre + MetalANGLE SDKs

Results Summary — the MetalANGLE SDK adds approximately 6.7 MB to the install size for iOS & iPadOS variants.

Key

  • 🗺 - Size of iosapp with MapLibre SDK only
  • 🗺+🎸 - Size with MapLibre SDK + MetalANGLE SDK
  • The Universal Device Type has data for a basic MapKit app based on Swift UI. This is intended to demonstrate the smallest possible app that can render a MapKit based map.

Methodology

  • Upload a build to App Store Connect with app thinning.

  • App Store Connect reports App Store File Sizes in KB.

  • app thinning "creates variants of your app for different devices and operating system versions. You can view the size of the variants directly in App Store Connect."1

  • Approved apps for the App Store are "encrypted with DRM and recompressed. The added encryption and DRM affects the ability to compress your binary, and as a result you may see a larger App Store file size for your binary than the binary you uploaded in App Store Connect."1

  • 1 - Definitions such as Download and Install size - https://help.apple.com/app-store-connect/#/dev3b56ce97c?sub=dev7379ba2ed

DEVICE TYPE DOWNLOAD SIZE INSTALL SIZE
This is the compressed size of the app downloaded over the air. This is the amount of disk space the app will take up on the customer's device. The install size also appears on your app’s product page in the Information section.
Universal 1706 KB MapKit
11742 KB 🗺
23240 KB 🗺+ 🎸
---
🎸 adds an additional 11498 KB
1924 KB MapKit
20146 KB 🗺
32855 KB 🗺+ 🎸
---
🎸 adds an additional 12709 KB
iPad (6th generation)  6221 KB  🗺
12380 KB 🗺+ 🎸
---
🎸 adds an additional 6159 KB
 14105 KB  🗺
20915 KB 🗺+ 🎸
---
🎸 adds an additional 6810 KB
iPad Pro (11‑inch)  6220 KB  🗺
12379 KB 🗺+ 🎸
---
🎸 adds an additional 6159 KB
 14100 KB  🗺
20911 KB 🗺+ 🎸
---
🎸 adds an additional 6811 KB
iPad Pro (12.9‑inch) (4th generation)  2834 KB  🗺
5042 KB 🗺+ 🎸
---
🎸 adds an additional 2208 KB
 14007 KB  🗺
20708 KB 🗺+ 🎸
---
🎸 adds an additional 6701 KB
iPhone 5S  6216 KB  🗺
12375 KB 🗺+ 🎸
---
🎸 adds an additional 6159 KB
 14096 KB  🗺
20907 KB 🗺+ 🎸
---
🎸 adds an additional 6811 KB
iPhone 7 Plus  6225 KB  🗺
12385 KB 🗺+ 🎸
---
🎸 adds an additional 6160 KB
 14105 KB  🗺
20915 KB 🗺+ 🎸
---
🎸 adds an additional 6810 KB
iPhone 11 Pro Max  2839 KB  🗺
5047 KB 🗺+ 🎸
---
🎸 adds an additional 2208 KB
 14011 KB  🗺
20712 KB 🗺+ 🎸
---
🎸 adds an additional 6701 KB
iPhone SE (2nd generation)  2830 KB  🗺
5038 KB 🗺+ 🎸
---
🎸 adds an additional 2208 KB
 14003 KB  🗺
20704 KB 🗺+ 🎸
---
🎸 adds an additional 6701 KB
iPhone 12 mini  2839 KB  🗺
5047 KB 🗺+ 🎸
---
🎸 adds an additional 2208 KB
 14011 KB  🗺
20712 KB 🗺+ 🎸
---
🎸 adds an additional 6701 KB
iPhone 12 Pro Max  2839 KB  🗺
5047 KB 🗺+ 🎸
---
🎸 adds an additional 2208 KB
 14011 KB  🗺
20712 KB 🗺+ 🎸
---
🎸 adds an additional 6701 KB
iPod touch (6th generation)  6216 KB  🗺
12375 KB 🗺+ 🎸
---
🎸 adds an additional 6159 KB
 14096 KB  🗺
20907 KB 🗺+ 🎸
---
🎸 adds an additional 6811 KB

roblabs avatar Mar 31 '21 18:03 roblabs

Thanks for working on this! Any progress since the experimental release? While I don't think we can help codewise, Bikemap is now a maplibre sponsor - symbolically for now until we can switch (waiting for metal)...

hactar avatar Aug 25 '21 08:08 hactar

Hello! We still need to setup Metal-supported CI and solve an issue with laggy annotation views. Have you had a chance to try out the experimental build? Are there any other problems you've experienced with it?

sulewicz avatar Aug 25 '21 16:08 sulewicz

So I've finally had a chance to try out the the experimental builds. They work well: we can finally work on M1 machines without enabling rosetta.

We did have the random crash here and there, especially when working with the snapshotter. Because the whole development team has now been upgraded to M1 machines (the non metal builds do not work, we have little to no choice: we need to use the prerelease version and hope this will become the general pipe line soon. There is a new version of metalangle available, and you've patched a few things in the non metal builds. Would be great if that could all be brought together.

I did take a stab at trying to help with this, but quickly lost my way. Most documentation, especially "develop" documentation, still talks about Mapbox and appears to not the the way to build things in metal mode.

hactar avatar Jan 16 '22 15:01 hactar

Is this topic still being actively pursued?

hakkurishian avatar Jun 03 '22 10:06 hakkurishian

I think there is a large interest in Metal support, especially because Apple might drop OpenGL at some point. This will be an interesting challenge and we will need code contributors and also reviewers. @hakkurishian would you be interested in joining this effort?

wipfli avatar Jun 03 '22 13:06 wipfli

#202

wipfli avatar Jun 09 '22 14:06 wipfli

A rendering backend that uses Metal-cpp directly is under development.

Progress can be tracked here: https://github.com/orgs/maplibre/projects/8

louwers avatar Aug 07 '23 10:08 louwers

We now have a pre-release out with Metal support.

Testers needed. Please see: https://github.com/maplibre/maplibre-native/issues/1609

louwers avatar Sep 21 '23 20:09 louwers