-
Notifications
You must be signed in to change notification settings - Fork 149
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
Using Marker or MarkerComposable in Clustering #641
Comments
We are also experiencing case 1. This issue seems to be a follow up to this issue/PR/comment. I our case it also happens without clustering (also on v6.1.2): GoogleMap(
cameraPositionState = cameraPositionState,
uiSettings = MapUiSettings(
compassEnabled = false,
indoorLevelPickerEnabled = false,
mapToolbarEnabled = false,
myLocationButtonEnabled = false,
rotationGesturesEnabled = false,
scrollGesturesEnabled = false,
scrollGesturesEnabledDuringRotateOrZoom = false,
tiltGesturesEnabled = false,
zoomControlsEnabled = false,
zoomGesturesEnabled = false,
),
liteMode = true,
modifier = Modifier
.height(115.dp)
.fillMaxWidth(),
) {
val markerState = remember(coordinates) { MarkerState(position = coordinates) }
MarkerComposable(
state = markerState,
title = stringResource(R.string.some_description),
) {
Icon(
imageVector = MyDrawables.MapMarker,
contentDescription = null,
tint = Color.Blue,
modifier = Modifier.size(16.dp),
)
}
} I am already defining a |
I have additional information. The requireSize modifier did not help with that crash. However, I copied the if (composeView.measuredWidth == 0 || composeView.measuredHeight == 0) {
val ex = IllegalStateException(
"The ComposeView was measured to have a width or height of " +
"zero. Make sure that the content has a non-zero size.",
)
Logger.ex(
ex = ex,
message = "Parent: size=${parent.size}, width=${parent.width}, height=${parent.height}\n" +
"Compose view: size=${composeView.size}, width=${composeView.width}, height=${composeView.height}\n" +
"Measured: width=${composeView.measuredWidth}, height=${composeView.measuredHeight}",
)
return null
} The result is the following:
So apparently the actual issue not the parent having a zero width/height but rather the compose view not being measured correctly. Also, I can see that according to the Sentry log, the fragment in which the ComposeView with the GoogleMap composable is used was already |
In my case, it's not related to clustering. I have fragments in a ViewPager, and a Compose map in one of the fragments. When the fragment becomes invisible and the marker data source changes, a crash occurs. To work around this issue, I added a boolean flag: if (uiState.isContainerVisible) {
uiState.markers.forEach { marker ->
MarkerComposable(...) {
CustomMarker(marker)
}
}
}
|
@mariohide are you able to provide a complete and somewhat minimal repro? I am not a maintainer, but I think a good repro may help with seeing this fixed, as it seems to happen in specific circumstances. Right now this issue does not seem to have a stacktrace for the non-clustering case. The non-clustering codebase is somewhat different from (simpler than) the clustering kind. |
Sure, I will do that after my busy days.
Uli Bubenheimer ***@***.***> 于 2024年12月30日周一 22:16写道:
… @mariohide <https://github.com/mariohide> are you able to provide a
complete and somewhat minimal repro? I am not a maintainer, but I think a
good repro may help with seeing this fixed, as it seems to happen in
specific circumstances.
Right now this issue does not seem to have a stacktrace for the
non-clustering case. The non-clustering codebase is somewhat different from
(simpler than) the clustering kind.
—
Reply to this email directly, view it on GitHub
<#641 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE337XOIBFHDR447L6C6BE32IFIVHAVCNFSM6AAAAABQZ6OTZ6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRVGU2DAMBWG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@bubenheimer Hi, I've created a repo that reproduce this:
You got a crash. |
Thanks for the repro, that should be very helpful. I took a quick look: you should set Modifier.requiredSize() on the Image, otherwise it may be zero size. However, that is not enough: the crash persists. You can use Here is the stacktrace:
The ComposeView is zero measured size here, presumably due to the Fragment View not currently being displayed on the screen. A maintainer may need to address this, I'm not sure how to best fix it; I'm no expert on the Android View system. My thinking is, if the ComposeView cannot be forced to the size we want when the parent View is zero size, then we should not use the parent. We could draw into some sort of offline View, but we'd lose all inherited "attributes" from the parent View, including View attributes and Compose attributes. It may be sufficient to install the CompositionContext from the parent View on the offline View composition to preserve Compose attributes, but not sure how to preserve View attributes, or if that is necessary. Also, additional work may be needed for the clustering case, it uses a more sophisticated approach for certain things. |
@bubenheimer Thanks for looking into this topic again! You mention the use of the |
Thanks @mariohide for sharing this workaround, I have used it and it worked until we can get a propre soultion from Maps. |
Is your feature request related to a problem? Please describe.
Now we cannot use Marker or MarkerComposable in blocks clusterContent and clusterItemContent of Clustering (com.google.maps.android.compose.clustering.Clustering)
Therefore, it is not possible to drag and drop custom markers.
Describe the solution you'd like
I want to use features together: custom markers, dragging and clustering.
MarkerComposableinside Clustering leads to a crash: case 1
java.lang.IllegalStateException: The ComposeView was measured to have a width or height of zero. Make sure that the content has a non-zero size.
Marker inside Clustering leads to a crash: case 2
java.lang.IllegalStateException: Invalid applier
maps-compose version is 6.1.2
Case 1
Case 2
The text was updated successfully, but these errors were encountered: