Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

proposal: shape layer grouping API #1708

Closed

Description

@incanus

If we proceed with this, it will also happen on Android.

Per voice with @kkaefer, our shape annotation implementation in #1655 could be improved by creating a layer grouping API identically-styled shapes.

Currently, each shape annotation gets its own style layer for reasons of:

  1. Eventual z-ordering by the client, much like MapKit's insertOverlay:aboveOverlay:.
  2. Styling, as shapes in the same layer get the same styling.

However, performance is a concern here. Adding 10,000 similarly-styled shapes means 10,000 more style layers, which means 10,000 more GL draw calls. 🚨 NOT TENABLE 🚨

If we introduced the concept of a shape group for identically-styled shapes, a consumer could add 10,000 blue polylines to the map and incur 1 style layer and 1 draw call.

Instead of:

mapView.addAnnotation(polyline1)
mapView.addAnnotation(polyline2)
// ...
mapView.addAnnotation(polyline10000)

It would look something like:

let polylineGroup = MGLMultiPointGroup
polylineGroup.addObject(polyline1)
polylineGroup.addObject(polyline2)
// ...
polylineGroup.addObject(polyline10000)
mapView.addAnnotationGroup(polylineGroup)

This would also allow functionality like:

  • Easy restyling of shape groups
  • Easy toggling of hide/show for shape groups

We would still support mapView.addAnnotation(polyline) like MapKit, with the understanding that it's more efficient to add many shapes with the groups API instead.

Thoughts @1ec5 @friedbunny?

Activity

  1. added
    iOS
    performance
    on Jun 10, 2015
  2. incanus commented on Jun 10, 2015

    @incanus
    ContributorAuthor

    If we are liking the looks of this, we should mock out what this Cocoa API looks like exactly, including styling configuration, how it interacts (if at all) with eventual layer reordering, and removal/other management.

  3. 1ec5 commented on Jun 10, 2015

    @1ec5
    Contributor

    Sure, why not?

  4. incanus commented on Jun 10, 2015

    @incanus
    ContributorAuthor

    Only because it's unlike Apple's API and may raise questions as to when or when not to use it. The answer to that is:

    • When adding many shapes with identical style properties.
  5. friedbunny commented on Jun 10, 2015

    @friedbunny
    Contributor

    Sounds like the performance gains would be worth the divergence/complexity. Having a built-in construct for managing groups of annotations is also a friendly addition in general.

    Would this also carry over into marker annotations? If so, we should be careful not to make this layer grouping too easily confused with our eventual support for clustering.

  6. mb12 commented on Jun 10, 2015

    @mb12

    This optimization is not needed for lines. LineBucket in gl-native is actually a MultiLine.

  7. ansis commented on Jun 11, 2015

    @ansis
    Contributor

    I think it might be worth waiting until data driven styling is implemented before worrying about this. Data driven styling will change the way this problem looks. I don't think the first implementation of shapes needs to be able to support thousands or even hundreds of shapes.

  8. jfirebaugh commented on Jun 11, 2015

    @jfirebaugh
    Contributor

    +1 to what @ansis said. With data driven styles we will have more optimization options for transparently combining multiple layers into one draw call.

  9. incanus commented on Jun 11, 2015

    @incanus
    ContributorAuthor

    I think it might be worth waiting

    This was my first inclination in talking with @kkaefer as well since adding this API can be classified as "works now, gets faster / more performant later", much like the R-tree stuff in #1694.

    Let's put this on the b3 milestone then.

  10. added this to the iOS Beta 3 milestone on Jun 11, 2015
  11. removed this from the iOS Beta 3 milestone on Jun 29, 2015
  12. jfirebaugh commented on Oct 29, 2015

    @jfirebaugh
    Contributor

    Working towards #837 instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    iOSperformance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions