Skip to content

fix(maps-compose): do not apply mapColorScheme to Lite mode maps - #1029

Open
Dai1678 wants to merge 3 commits into
googlemaps:mainfrom
Dai1678:fix/lite-mode-color-scheme
Open

Dai1678 wants to merge 3 commits into
googlemaps:mainfrom
Dai1678:fix/lite-mode-color-scheme

Conversation

@Dai1678

@Dai1678 Dai1678 commented Oct 7, 2026 •

Copy link
Copy Markdown

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:

  • Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1028 🦕

Description

Keeps FOLLOW_SYSTEM as the default mapColorScheme from #986, but never applies a color scheme to Lite mode maps:

  • GoogleMap.kt: the AndroidView factory writes mapColorScheme into GoogleMapOptions only when liteMode is not true.
  • MapUpdater.kt: map.mapColorScheme is not set when the map is in Lite mode. The flag is computed once from the options in the factory, stored with the MapView in MapTagData, and passed to the MapApplier created for each subcomposition. When the MapView is reused (for example in LazyColumn), the factory does not run again but remembered state, including MapUpdaterState and the subcomposition, is recreated; the new MapApplier still gets the flag from the MapView. cameraPositionState.isLiteMode is not used for the same reason, and because the CameraPositionState passed to GoogleMap can be replaced.
  • A color scheme set explicitly in googleMapOptionsFactory is still passed through unchanged, as for non-Lite maps.
  • KDoc of mapColorScheme and docs/lite-mode-dark-theme.md now say that Lite mode maps do not get the color scheme.

Behavior change

The three Lite mode tests added in #989 asserted that mapColorScheme ends up in the Lite mode GoogleMapOptions. They now assert the opposite:

Test Before After
testLiteModeDoesNotApplyColorSchemeToOptions (was testLiteModePreservesColorSchemeAndLiteModeInOptions) DARK LIGHT (not applied)
testLiteModeWithTerrainMapTypePreservesOptions DARK LIGHT (map type still preserved)
testLiteModeDoesNotApplyDefaultColorSchemeToOptions (was testLiteModeDefaultColorSchemeIsFollowSystem) FOLLOW_SYSTEM LIGHT (not applied)

testLiteModePreservesColorSchemeSetInOptions is new and covers the explicit googleMapOptionsFactory case.

Verification

  • GoogleMapViewTests on 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.
  • Without the source changes, the three Lite mode options tests fail on an emulator with Play services 24.23.
  • ./gradlew :maps-compose:testDebugUnitTest lint passes. Lint reports no findings in the changed files.
  • The MapUpdater guard 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, setMapColorScheme does not throw, so such a test would pass with or without the fix. MapUpdaterState is internal, so the flag cannot be checked from maps-app tests either.
  • MapView reuse was checked by hand with temporary logging: wrapping a Lite mode GoogleMap in ReusableContent and changing the key keeps the same MapView and recreates MapUpdaterState. Without storing the flag with the MapView, it was false after reuse and setMapColorScheme was called; with this change it stays true.

Not addressed

  • cameraPositionState.isLiteMode is 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.

@google-cla

google-cla Bot commented Oct 7, 2026

Copy link
Copy Markdown

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
Dai1678 force-pushed the fix/lite-mode-color-scheme branch from 3e3495e to 130434a Compare October 7, 2026 06:15
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
Dai1678 marked this pull request as ready for review October 7, 2026 08:34

This branch has not been deployed

No deployments
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.

Lite mode crash "setMapColorScheme not supported in Lite mode" regressed in 8.6.0 (#601)

2 participants