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

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

Open
Abdelsattar opened this issue Jan 29, 2024 · 3 comments · May be fixed by #533
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@Abdelsattar
Copy link

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!

@Abdelsattar Abdelsattar added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 29, 2024
@wangela
Copy link
Member

wangela commented Jan 29, 2024

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.

@Abdelsattar Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

@ln-12
Copy link

ln-12 commented Mar 15, 2024

I have the same issue. This is the full stack trace from sentry in my case:

android.graphics.Bitmap in createBitmap in Zeile 1170
android.graphics.Bitmap in createBitmap in Zeile 1118
android.graphics.Bitmap in createBitmap in Zeile 1077
com.example.common.compose.maps.RememberComposeBitmapDescriptorKt in renderComposableToBitmapDescriptor in Zeile 58
com.example.common.compose.maps.RememberComposeBitmapDescriptorKt in access$renderComposableToBitmapDescriptor in Zeile 1
com.example.common.compose.maps.RememberComposeBitmapDescriptorKt in rememberComposeBitmapDescriptor in Zeile 29
com.example.common.compose.maps.MarkerKt in MarkerComposable-pMp3byo in Zeile 248
com.example.DetailScreenKt$MapCard$1$1$3 in invoke in Zeile 638
com.example.DetailScreenKt$MapCard$1$1$3 in invoke in Zeile 637
androidx.compose.runtime.internal.ComposableLambdaImpl in invoke in Zeile 109
androidx.compose.runtime.internal.ComposableLambdaImpl in invoke in Zeile 35
com.example.common.compose.maps.GoogleMapKt$GoogleMap$4$1$1$1 in invoke in Zeile 142
com.example.common.compose.maps.GoogleMapKt$GoogleMap$4$1$1$1 in invoke in Zeile 141
androidx.compose.runtime.internal.ComposableLambdaImpl in invoke in Zeile 109
androidx.compose.runtime.internal.ComposableLambdaImpl in invoke in Zeile 35
androidx.compose.runtime.CompositionLocalKt in CompositionLocalProvider in Zeile 248
com.example.common.compose.maps.GoogleMapKt$GoogleMap$4$1$1 in invoke in Zeile 139
com.example.common.compose.maps.GoogleMapKt$GoogleMap$4$1$1 in invoke in Zeile 128
androidx.compose.runtime.internal.ComposableLambdaImpl in invoke in Zeile 109
androidx.compose.runtime.internal.ComposableLambdaImpl in invoke in Zeile 35
androidx.compose.runtime.ActualJvm_jvmKt in invokeComposable in Zeile 90
androidx.compose.runtime.ComposerImpl in doCompose in Zeile 3302
androidx.compose.runtime.ComposerImpl in composeContent$runtime_release in Zeile 3235
androidx.compose.runtime.CompositionImpl in composeContent in Zeile 723
androidx.compose.runtime.Recomposer in composeInitial$runtime_release in Zeile 1071
androidx.compose.runtime.ComposerImpl$CompositionContextImpl in composeInitial$runtime_release in Zeile 3599
androidx.compose.runtime.CompositionImpl in composeInitial in Zeile 631
androidx.compose.runtime.CompositionImpl in setContent in Zeile 617
com.example.common.compose.maps.GoogleMapKt$GoogleMap$4 in invokeSuspend in Zeile 284
kotlin.coroutines.jvm.internal.BaseContinuationImpl in resumeWith in Zeile 33
kotlinx.coroutines.DispatchedTask in run in Zeile 108
androidx.compose.ui.platform.AndroidUiDispatcher in performTrampolineDispatch in Zeile 81
androidx.compose.ui.platform.AndroidUiDispatcher in access$performTrampolineDispatch in Zeile 41
androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1 in run in Zeile 57
android.os.Handler in handleCallback in Zeile 959
android.os.Handler in dispatchMessage in Zeile 100
android.os.Looper in loopOnce in Zeile 232
android.os.Looper in loop in Zeile 317
android.app.ActivityThread in main in Zeile 8501
java.lang.reflect.Method in invoke
com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run in Zeile 552
com.android.internal.os.ZygoteInit in main in Zeile 878

My code looks similar to the example above. I could also reproduce it locally, but only once. All I did was navigate back and forth (fragment based navigation) between my main screen and the screen which contains the map very fast for many times. So it is probably some kind of race condition.

@ln-12
Copy link

ln-12 commented Mar 18, 2024

This crash can be forced using this project: https://github.com/ln-12/GoogleMapsCrashReproducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
3 participants