googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.16k stars 142 forks source link

Strange rendering lag when using GoogleMap composable inside a ModalBottomSheetLayout #100

Closed shrikanth7698 closed 2 years ago

shrikanth7698 commented 2 years ago

Environment details

Device: OnePlus 7T, Android 11 Library Version: https://github.com/googlemaps/android-maps-compose/releases/tag/v1.1.0

Steps to reproduce

  1. Use GoogleMap composable inside the sheetContent of ModalBottomSheetLayout

  2. Add MapUiSettings like this

    GoogleMap(
        modifier = Modifier.height(125.dp),
        cameraPositionState = cameraPositionState,
        uiSettings = MapUiSettings(
            indoorLevelPickerEnabled = false,
            myLocationButtonEnabled = true,
            compassEnabled = false,
            mapToolbarEnabled = true,
            rotationGesturesEnabled = false,
            scrollGesturesEnabled = false,
            scrollGesturesEnabledDuringRotateOrZoom = false,
            tiltGesturesEnabled = false,
            zoomGesturesEnabled = false,
            zoomControlsEnabled = false
        )
    ) {
        // showing the marker only when the camera is not moving
        Marker(
            position = jobLocation,
            visible = !cameraPositionState.isMoving
        )
    }
  3. Run the app and open the bottomsheet dialog

  4. Click on the marker that is visible on the map and then click on the google maps icon that is visible in the bottom right corner. This will take you to the google maps app.

  5. Now come back, close the bottom sheet dialog and open it again. Bottomsheet will be very laggy while opening and maps canvas will be blank for at least 2 seconds.

Note:

All the animations that you do using cameraPositionState after coming back from google maps app will be very laggy. This lag persist even when you come back from that activity and revisit that activity. App needs to be force stopped and relaunched again to remove this lag.

Let me know if you guys need any additional resources like video or code samples. Thanks.

jpoehnelt commented 2 years ago

@shrikanth7698 Thank you for opening this issue. 🙏 Please check out these other resources that might be applicable:

This is an automated message, feel free to ignore.

barbeau commented 2 years ago

@shrikanth7698 Have you tried running this in a release build instead of a dev build? Dev builds can have performance issues with Compose in general.

shrikanth7698 commented 2 years ago

@barbeau I'm not able to repro this issue in release build. Thank you!