Skip to content

SwiftUI Optimisation #76

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

Merged
merged 4 commits into from
Jul 13, 2024
Merged

Conversation

Patrick-Kladek
Copy link
Contributor

@Patrick-Kladek Patrick-Kladek commented Jul 1, 2024

Description

We are wrapping MapLibre-navigation in a UIViewControllerRepresentable. The updateUIViewController function is run multiple times leading to setting the same variable over and over.

Open Tasks

  • prevent code from running again after setting the same property again
  • only call navigationViewControllerDidFinishRouting when confirmed via button

Infos for Reviewer

Comment on lines +661 to +663
self.mapViewController.hideEndOfRoute { _ in
self.delegate?.navigationViewControllerDidFinishRouting?(self)
}
Copy link
Contributor Author

@Patrick-Kladek Patrick-Kladek Jul 1, 2024

Choose a reason for hiding this comment

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

I've verified that this is called regardless if showsEndOfRouteFeedback is set to true or false.

@@ -467,6 +475,7 @@ open class NavigationViewController: UIViewController {

self.voiceController = nil
self.route = nil
self.locationManager = NavigationLocationManager()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resets LocationManager in case a SimulatedLocationManager was used

@michaelkirk
Copy link
Collaborator

Hi @Patrick-Kladek -
I just want to make sure that it stays focused on one issue, so that we can avoid having a far reaching PR that changes a lot of things at once. It makes it hard to test and evaluate. I see this is currently a draft. Why is that? What's the scope of this PR?

@Patrick-Kladek
Copy link
Contributor Author

@michaelkirk Sure, this PR is about fixing small things we've missed in #54. It has 3 small changes, I hope you don't want me to submit 3 PRs 😅, that's why I included it here. I've already got the approval from my team, so it's ready to review here too.

@Patrick-Kladek Patrick-Kladek marked this pull request as ready for review July 2, 2024 16:34
@hactar hactar self-requested a review July 10, 2024 18:34
hactar
hactar previously approved these changes Jul 10, 2024
@michaelkirk
Copy link
Collaborator

It has 3 small changes, I hope you don't want me to submit 3 PRs 😅

Well when you phrase it like that it makes me feel crazy 😆, but to be honest, it certainly would be my preference if they are separate! It makes it easier to talk about separate concerns.

For example, I have no concerns with:

b0c1397

But 4111671 seems like the wrong fix. Since location manger is per-route, not per-view-controller, it probably makes more sense to set it in startRoute rather than in init, right?

And as for 427721a, In my own application, I was calling hideEndOfRoute in my application logic, but I think you're right that we should probably include this in the library. However, I don't think it makes sense to call hideEndOfRoute unless showEndOfRoute was called, so probably here is the right place to include it?

self.showEndOfRoute(duration: presentationDuration, onDismiss: onDismiss, presentationCompletion: presentationCompletion)

What do you think?

@hactar hactar dismissed their stale review July 11, 2024 20:42

Some good questions by Michael, lets wait for Patrick K's response.

@Patrick-Kladek
Copy link
Contributor Author

Good point that the LocationManager is per Route, I fixed that.

hideEndOfRoute has no side effects, it will simply remove the built-in feedback view if it's in the view hierarchy. If you want to provide your own, you do it differently anyway by listening to the delegate method navigationViewControllerDidFinishRouting().

I checked that the navigationViewControllerDidFinishRouting() is called regardless of the showsEndOfRouteFeedback property.

Copy link
Collaborator

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

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

Good point that the LocationManager is per Route, I fixed that.

👍

hideEndOfRoute has no side effects, it will simply remove the built-in feedback view if it's in the view hierarchy. If you want to provide your own, you do it differently anyway by listening to the delegate method navigationViewControllerDidFinishRouting().

Ok, I don't feel that strongly about this one.

@hactar hactar merged commit be19416 into maplibre:main Jul 13, 2024
2 checks passed
@Patrick-Kladek Patrick-Kladek deleted the swiftui-optimization branch July 16, 2024 13:08
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.

3 participants