Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Lite mode does not support map color schemes. Recent Play services ignore them, but older ones throw UnsupportedOperationException from MapView.onCreate or GoogleMap.setMapColorScheme. Since the default became FOLLOW_SYSTEM, Lite mode maps crash on those devices without any opt-in from the app. Fixes googlemaps#1028
Dai1678
force-pushed
the
fix/lite-mode-color-scheme
branch
from
October 7, 2026 06:15
3e3495e to
130434a
Compare
AndroidView reuses the MapView (for example in LazyColumn) without running the factory again, while remembered MapUpdaterState is recreated. The Lite mode flag then reset to false, and MapUpdater set the color scheme on a reused Lite mode map again.
MapApplier is created per subcomposition from the MapView, so it has the right lifetime for the flag and needs no copy on every update. This also keeps a plain var out of the @stable MapUpdaterState, and reads liteMode from the options once.
Dai1678
marked this pull request as ready for review
October 7, 2026 08:34
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #1028 🦕
Description
Keeps
FOLLOW_SYSTEMas the defaultmapColorSchemefrom #986, but never applies a color scheme to Lite mode maps:GoogleMap.kt: theAndroidViewfactory writesmapColorSchemeintoGoogleMapOptionsonly whenliteModeis nottrue.MapUpdater.kt:map.mapColorSchemeis not set when the map is in Lite mode. The flag is computed once from the options in the factory, stored with theMapViewinMapTagData, and passed to theMapAppliercreated for each subcomposition. When theMapViewis reused (for example inLazyColumn), the factory does not run again but remembered state, includingMapUpdaterStateand the subcomposition, is recreated; the newMapApplierstill gets the flag from theMapView.cameraPositionState.isLiteModeis not used for the same reason, and because theCameraPositionStatepassed toGoogleMapcan be replaced.googleMapOptionsFactoryis still passed through unchanged, as for non-Lite maps.mapColorSchemeanddocs/lite-mode-dark-theme.mdnow say that Lite mode maps do not get the color scheme.Behavior change
The three Lite mode tests added in #989 asserted that
mapColorSchemeends up in the Lite modeGoogleMapOptions. They now assert the opposite:testLiteModeDoesNotApplyColorSchemeToOptions(wastestLiteModePreservesColorSchemeAndLiteModeInOptions)DARKLIGHT(not applied)testLiteModeWithTerrainMapTypePreservesOptionsDARKLIGHT(map type still preserved)testLiteModeDoesNotApplyDefaultColorSchemeToOptions(wastestLiteModeDefaultColorSchemeIsFollowSystem)FOLLOW_SYSTEMLIGHT(not applied)testLiteModePreservesColorSchemeSetInOptionsis new and covers the explicitgoogleMapOptionsFactorycase.Verification
GoogleMapViewTestson emulators with Play services 26.11 and 26.36: all color scheme tests pass. The 17 tests that need a Maps API key were skipped, as no key was configured../gradlew :maps-compose:testDebugUnitTest lintpasses. Lint reports no findings in the changed files.MapUpdaterguard has no test. Observing it needs both a valid Maps API key and older Play services. With an invalid key, or on recent Play services,setMapColorSchemedoes not throw, so such a test would pass with or without the fix.MapUpdaterStateis internal, so the flag cannot be checked frommaps-apptests either.GoogleMapinReusableContentand changing the key keeps the sameMapViewand recreatesMapUpdaterState. Without storing the flag with theMapView, it wasfalseafter reuse andsetMapColorSchemewas called; with this change it staystrue.Not addressed
cameraPositionState.isLiteModeis also only set in the factory, so it has the same reuse problem for camera animations. That is unrelated to the crash and predates this change, so it is left out of this PR.