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

Solved: Very large Marker size is causing crash #116

Open
cwsiteplan opened this issue May 22, 2024 · 5 comments
Open

Solved: Very large Marker size is causing crash #116

cwsiteplan opened this issue May 22, 2024 · 5 comments

Comments

@cwsiteplan
Copy link
Contributor

Hi,

I ran into an issue where a marker with large dimensions is causing a crash.

 java.lang.IllegalArgumentException: Can't represent a width of 36818 and height of 36818 in Constraints
                                                                                                    	at androidx.compose.ui.unit.Constraints$Companion.createConstraints-Zbe2FdA$ui_unit_release(Constraints.kt:369)
                                                                                                    	at androidx.compose.ui.unit.ConstraintsKt.Constraints(Constraints.kt:433)
                                                                                                    	at androidx.compose.foundation.layout.SizeNode.getTargetConstraints-OenEA2s(Size.kt:794)
                                                                                                    	at androidx.compose.foundation.layout.SizeNode.measure-3p2s80s(Size.kt:806)
                                                                                                    	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:116)
                                                                                                    	at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier.measure-3p2s80s(GraphicsLayerModifier.kt:646)
                                                                                                    	at androidx.compose.ui.node.LayoutModifierNodeCoordinator.measure-BRTryo0(LayoutModifierNodeCoordinator.kt:116)
                                                                                                    	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:252)
                                                                                                    	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$performMeasureBlock$1.invoke(LayoutNodeLayoutDelegate.kt:251)
                                                                                                    	at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2303)
                                                                                                    	at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500)
                                                                                                    	at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
                                                                                                    	at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
                                                                                                    	at androidx.compose.ui.node.OwnerSnapshotObserver.observeMeasureSnapshotReads$ui_release(OwnerSnapshotObserver.kt:113)
                                                                                                    	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:1617)
                                                                                                    	at androidx.compose.ui.node.LayoutNodeLayoutDelegate.access$performMeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:36)
                                                                                                    	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:620)
                                                                                                    	at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release(LayoutNode.kt:1145)
                                                                                                    	at androidx.compose.ui.node.LayoutNode.remeasure-_Sx5XlM$ui_release$default(LayoutNode.kt:1136)
                                                                                                    	at androidx.compose.ui.node.MeasureAndLayoutDelegate.doRemeasure-sdFAvZA(MeasureAndLayoutDelegate.kt:356)
                                                                                                    	at androidx.compose.ui.node.MeasureAndLayoutDelegate.remeasureAndRelayoutIfNeeded(MeasureAndLayoutDelegate.kt:514)
                                                                                                    	at androidx.compose.ui.node.MeasureAndLayoutDelegate.onlyRemeasureIfScheduled(MeasureAndLayoutDelegate.kt:598)
                                                                                                    	at androidx.compose.ui.node.MeasureAndLayoutDelegate.forceMeasureTheSubtreeInternal(MeasureAndLayoutDelegate.kt:624)
                                                                                                    	at androidx.compose.ui.node.MeasureAndLayoutDelegate.forceMeasureTheSubtree(MeasureAndLayoutDelegate.kt:587)
                                                                                                    	at androidx.compose.ui.platform.AndroidComposeView.forceMeasureTheSubtree(AndroidComposeView.android.kt:993)
                                                                                                    	at androidx.compose.ui.node.Owner.forceMeasureTheSubtree$default(Owner.kt:239)
                                                                                                    	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.remeasure-BRTryo0(LayoutNodeLayoutDelegate.kt:632)
                                                                                                    	at androidx.compose.ui.node.LayoutNodeLayoutDelegate$MeasurePassDelegate.measure-BRTryo0(LayoutNodeLayoutDelegate.kt:596)
                                                                                                    	at ovh.plrapps.mapcompose.ui.markers.MarkerLayoutKt$MarkerLayout$2$1.invoke(MarkerLayout.kt:38)

I was using it in combination with clustering and the cluster having items quite close, so it would zoom in quite a lot.
After quite some time of debugging I identified the issue.
The map was configured with a high maxScale of > 5000 (in order to distinguish very close markers).
The problem was that I had a GPS accuracy circle marker that computed it's size depending on accuracy and zoom level.
That made the accuracy circle marker's size (which was anyways off-screen) exceeding 10000.dp and producing the above crash.

I reproduced that in the demo app here
A simple coerce (size.coerceAtMost(500f)) on the marker size fixed the issue (but potentially leaves the problem to other marker usages).

I just logged the issue here for reference, in case someone is dealing with that in future. Not sure if a modification to the MarkerComposable could prevent that issue.

@p-lr
Copy link
Owner

p-lr commented May 23, 2024

Interestingly enough, I don't get the crash when I zoom-in manually. The crash only happens when I click on green clusters (at least for me).
EDIT: I also get the crash by zooming manually (I just didn't zoom-in enough).

@p-lr
Copy link
Owner

p-lr commented May 25, 2024

It seems that we're hitting an internal limit due to how compose computes constraints. Width and height values need to hold on 32 bit at some point, which clearly cannot be the case when the scale is allowed to rocket at such high value.

@cwsiteplan
Copy link
Contributor Author

yep, think so too. question is if we can limit (coerce) the width/height to that size so we don't run into crashes.

@p-lr
Copy link
Owner

p-lr commented May 30, 2024

Coercing values would mean incorrect rendering by the layout. The Compose framework raises an exception, to notify that it no longer handles the input.
I'm not comfortable having incorrect rendering.

@cwsiteplan
Copy link
Contributor Author

i see, then hopefully this issue might be an explanation to future users running into this.

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

No branches or pull requests

2 participants