Skip to content

MarkerComposable throw Fatal Exception: java.lang.IllegalArgumentException: width and height must be > 0Β #518

@Abdelsattar

Description

@Abdelsattar

Hello,
I'm working with Google Maps Compose and now I get some Firebase crashes related to markerComposable withe the following exception:

Fatal Exception: java.lang.IllegalArgumentException: width and height must be > 0
       at android.graphics.Bitmap.createBitmap(Bitmap.java:1148)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:1115)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:1065)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:1026)
       at com.google.maps.android.compose.RememberComposeBitmapDescriptorKt.renderComposableToBitmapDescriptor(RememberComposeBitmapDescriptor.kt:58)
       at com.google.maps.android.compose.RememberComposeBitmapDescriptorKt.access$renderComposableToBitmapDescriptor(RememberComposeBitmapDescriptor.kt:1)
       at com.google.maps.android.compose.RememberComposeBitmapDescriptorKt.rememberComposeBitmapDescriptor(RememberComposeBitmapDescriptor.kt:29)
       at com.google.maps.android.compose.MarkerKt.MarkerComposable-pMp3byo(Marker.kt:239)
       ```


this is my following code : 

@Composable
fun MapScreen(
 ...
) {

 GoogleMap(
       modifier = Modifier
          .fillMaxWidth()
          .padding(bottom = sheetPeekHeight - 8.dp),
      cameraPositionState = cameraPositionState,
      properties = if (locationPermissionState.status.isGranted) MapProperties(isMyLocationEnabled = true) else MapProperties(
          isMyLocationEnabled = false
     ),
      uiSettings = MapUiSettings(zoomControlsEnabled = false)
   ) {
      LocationMarkers(locations, getMarkerSequence)
 } 
}

@Composable
fun LocationMarkers(
   locations: List<LatLng>,
   getMarkerSequence: (Int) -> String
 ) {

  locations.onEachIndexed { index, latLng ->

    MarkerComposable(
        state = MarkerState(latLng),
    ) {
        val markerSequence = getMarkerSequence(index)
        Box(contentAlignment = Alignment.Center) {
            Image(
                painter = painterResource(id = R.drawable.ic_my_icon),
                contentDescription = ""
            )

            Text(
                text = markerSequence,
                color = Color.White,
                modifier = Modifier
                    .padding(top = 4.dp)
                    .align(Alignment.TopCenter)
            )
        }

    }
  }
 }

Environment details

  1. API Google Maps compose
  2. it's happening at multiple Version From Android 9 ->14
  3. Google Maps compose version v2.14.0

Steps to reproduce

  1. I can't reproduce my local but the crashes caught by Firebase affect around 1% of the users

Thanks!

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.releasedtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions