Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Tangram-ES to 0.7 #342

Merged
merged 12 commits into from
Jun 28, 2017
Merged

Upgrade Tangram-ES to 0.7 #342

merged 12 commits into from
Jun 28, 2017

Conversation

msmollin
Copy link
Member

@msmollin msmollin commented Jun 22, 2017

Overview

This PR upgrades Tangram-es to the latest production stable version. It includes some major refactoring, some method deprecations, and some bug fixes and performance improvements.

Note that this includes a minor breaking change where we have to make the tgMarker property across the marker protocols optional now. This shouldn't affect most people but it should be called out in release notes.

Proposed Changes

  • Updates the podspec to pull in latest changes
  • Update build settings to satisfy xcode
  • Alter unit tests and main code to satisfy API and functionality changes
  • SDK markers are now decoupled from ES markers. This has some good functionality benefits but means we need to do additional checks before adding them to the map to avoid overwriting changes that may have happens to the TGMarker
  • Request that GLKit render the map at 60 FPS which makes for a much smoother and nicer mapping experience.
  • Minor bug fix to actually remove all the markers from our internal storage.

Fixes #327

Matt Smollinger added 3 commits June 15, 2017 22:47
- Refactor API and re-enable previous error checks where applicable
- Deprecate functions not needed
- Remove unnecessary files
Matt Smollinger added 5 commits June 23, 2017 00:30
Future commits will fix them.
This fixes unit test runtime exceptions by adding a test mapVC into the
tests which allows the markers to sync up correctly with ES 0.7 changes.

Also an oversight was found where we weren't clearing our own internal
marker storage upon marker removal, and so that's now fixed.
@msmollin msmollin changed the title [WIP] Upgrade Tangram-ES to 0.7 Upgrade Tangram-ES to 0.7 Jun 23, 2017
if marker.tgMarker == nil {
marker.tgMarker = tgViewController.markerAdd()
}
currentMarkers[marker.tgMarker!] = marker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking more, it seems that a nice alternative would be to store the SDK marker as a user data of the Tangram marker, that the association can be easily retrieved without additional container.

https://github.com/tangrams/tangram-es/blob/master/platforms/ios/src/TangramMap/TGMarker.h#L103

I think it reminds me of some conversation we had on a previous PR relating to that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a slightly different use case. With this change we're effectively decoupling SDK markers from Tangram-es markers, meaning we no longer require a Tangram-es marker be created at initialization time of the SDK marker class. We're also allowing users to set their own underlying TGMarkers for their SDK markers if they want (it honestly makes it easier on us to implement as well).

The side effect of all that is we need to check we don't override previous markers when adding the SDK markers to the map.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh slow github is slow - yeah the user data object is a good idea. Lemme think on how that might change the interaction model at the Mapzen layer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so @sarahlensing and I discussed it further and I think we wanna go down the route of using the user data object on TGMarker. However, a void* there imported into Swift is difficult to use. Do you think it would be much effort to convert it to a nullable NSObject ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NSObject seems to narrow down the flexibility quite a lot, we should probably useid there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id could work. That at least converts to AnyObject in Swift which I can cast through easier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other places I see in Foundation that have this type of construct (NSNotification for example) flat out use NSDictionary which is even more constraining.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually like the NSDictionary idea, it would let you store different kind of data without having to create your own data structure holding it. Feel free to open an issue in ES with the different options we have.

guard let marker = tgMarker else { return false }
marker.pointEased(coordinates, seconds: seconds, easeType: ease)
do {
try marker.getError()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error is only checked on setPointEased, I assume that the inconvenience of Swift regarding properties that throw is a potential blocker, but the implementation might leave error incoming from previous usage of the marker, which would be misleading when using setPointEased. What seems correct is to check on every modification of the marker or check nowhere at all (while potentially wrapping getError to allow its usage externally).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm yeah you're right. Probably should just pull this then and go back through a re-add it when we tackle #248

@@ -234,12 +245,20 @@ public class PointMarker : GeometricMarker, GenericPointIconMarker {
- parameter ease: Easing to use for animation.
*/
public func setPointEased(_ coordinates: TGGeoPoint, seconds: Float, easeType ease: TGEaseType) -> Bool {
return tgMarker.setPointEased(coordinates, seconds: seconds, easeType: ease)
tgMarker?.pointEased(coordinates, seconds: seconds, easeType: ease)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to call getError before pointEased to avoid returning an error for a previous action taken on tgMarker? I'm wondering if we have an existing error on the tgMarker and then call pointEased which completes without an error, will we erroneously return false here? I just saw @karimnaaji's comment, looks like you already plan to handle this

let _ = self.showCurrentLocation(true)
self.showFindMeButon(true)
try? loadStyleAsync(appDelegate.selectedMapStyle) { [weak self] (style) in
guard let unwrappedSelf = self else { print("Self is nil"); return }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Might be useful to have a more descriptive message here, and maybe a description of how this can happen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah that is debug code - had a separate issue I was trying to figure out and forgot to remove that. Will do now.

@msmollin msmollin merged commit 7f17090 into master Jun 28, 2017
@msmollin msmollin deleted the issue-327 branch June 28, 2017 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Tangram-es 0.7
3 participants