Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

MGLShapeSource features(matching: NSPredicate) returns old data #301

Closed
akovalov opened this issue May 8, 2020 · 2 comments
Closed

MGLShapeSource features(matching: NSPredicate) returns old data #301

akovalov opened this issue May 8, 2020 · 2 comments

Comments

@akovalov
Copy link

akovalov commented May 8, 2020

Steps to reproduce

  1. Update existing MGLShapeSource every minute with a new shape like the following
...
var shapeSource: MGLShapeSource?
...
shapeSource?.shape = shapeFromGeoJson
mapView?.style.addSource(shapeSource!)
  1. Get feature from the source
let feature = shapeSource?.features(matching: NSPredicate(format: "uuid == %@", uuid))

Expected behavior

feature will contain the latest data from just added source

Actual behavior

feature contains the previously added source data
But if add delay it works correctly

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
    let feature = self.shapeSource?.features(matching: NSPredicate(format: "uuid == %@", uuid))
}

I assume there is some delay in rendering new shape data on layer (like ~0.5s) and it could differ based on features count and layer drawing complexity.

It would be good to understand what caused this delay and how to deal with it - get a callback/delegate or a property like loaded etc. Please advice.

Configuration

Mapbox SDK versions: Mapbox-iOS-SDK (5.8.0)
iOS/macOS versions: iOS 13.4.1
Device/simulator models: iPad Pro (9.7 inch) Simulator
Xcode version: 11.4.1

@1ec5
Copy link
Contributor

1ec5 commented May 8, 2020

get a callback/delegate or a property like loaded etc.

Yes, a callback on tile load would be awesome (even more awesome if it came with a way to manipulate what has been loaded). mapbox/mapbox-gl-native#2775 tracks the various ways in which MGLMapViewDelegate doesn’t align with MKMapViewDelegate.

Fortunately, you may be able to wait for the map’s next render cycle by implementing either -mapViewDidFinishRenderingFrame: or the undocumented -mapViewDidFinishRenderingMap:fullyRendered:. (The fullyRendered: flag isn’t fully implemented; that’s mapbox/mapbox-gl-native#1804.)

@stale stale bot added the archived label Nov 7, 2020
@stale
Copy link

stale bot commented Nov 9, 2020

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Nov 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants