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

perf: Make CameraPositionState and MarkerState stable #254

Merged
merged 2 commits into from
Jan 19, 2023

Conversation

DSteve595
Copy link
Contributor

CameraPositionState has a few unstable properties. Rather than verify all usages of these are safe for stability, I'm opting to back them with mutable states, so the compiler can mark the class stable for us.
MarkerState's internal var: Marker? property was causing the class to be marked unstable.
While I think it can safely be marked @Stable as-is, I'd rather have the compiler infer that. I feel better backing it with an actual state value, that way if we later do an actual non-imperative state read it won't break stuff.

Verified stability via compiler report.

Fixes #232 🦕

@DSteve595 DSteve595 changed the title Marker cameraposition stable perf: Marker cameraposition stable Jan 18, 2023
@DSteve595 DSteve595 changed the title perf: Marker cameraposition stable perf: Make CameraPositionState and MarkerState stable Jan 18, 2023
@wangela wangela merged commit 52bd69e into googlemaps:main Jan 19, 2023
googlemaps-bot pushed a commit that referenced this pull request Jan 19, 2023
## [2.8.1](v2.8.0...v2.8.1) (2023-01-19)

### Performance Improvements

* Make CameraPositionState and MarkerState stable ([#254](#254)) ([52bd69e](52bd69e))
@googlemaps-bot
Copy link
Contributor

🎉 This PR is included in version 2.8.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@bubenheimer
Copy link
Contributor

Nervous about seeing additional state added to MarkerState: an app may have quite a lot of Marker/MarkerState objects. Were time/space performance impacts considered?

@DSteve595 DSteve595 deleted the marker-cameraposition-stable branch January 21, 2023 12:44
@DSteve595
Copy link
Contributor Author

@bubenheimer No, those weren't considered. A benchmark would be useful. I made the judgment call that stability of a State class is generally expected, and so ours should fit the pattern.
Have you encountered any performance issues from this?

@bubenheimer
Copy link
Contributor

The Marker-related change looks like a red flag to me. Marker is a mutable type inside what's now a MutableState. And on top of that there is MarkerState.position, which replicates parts of the MutableState-wrapped mutable object inside another MutableState.

As you may be aware, I believe that MarkerState can and should be eliminated entirely, at least from the public API surface: #149

@DSteve595
Copy link
Contributor Author

I'm gonna take some time to digest your thoughts in #149. Thanks very much for the detailed explanations.

The MarkerState changes were made with defensive correctness in mind (I'm not positive about enumerating all cases that can modify those properties, now and in the future). I'm inclined to try benchmarking some scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MarkerState behaves in a non-@Stable manner at runtime
4 participants