Closed diego-francisco-jt closed 1 month ago
Hi @diego-francisco-jt, thank you for your nice words, we appreciate it! We haven't observed this crash in the sample app, and the code you shared contains unknown references and thus we can't run it. Please provide an MRE that we can run to reproduce the crash. #659 is a good example of a complete bug report.
We'll answer your migration-related questions as soon as possible.
I have also encountered this problem. After testing, I found that this situation occurs on devices with low performance (possibly due to insufficient computing power and fast scrolling, causing the marker to be outside the screen and x to get 0?), The specific operation is that normal sliding to view data will cause it to crash, but it will not appear on devices with good performance. My temporary solution is to display only 5 pieces of data, so that users cannot perform sliding operations and therefore cannot cause crashes. But this is not the solution to the fundamental problem.
@Gowsky Sorry for not providing the minimal reproducible example š I've updated the original message with the MRE, I hope it helps.
I ran into the same issue today when I simply just swapped the HorizontalLayout
to horizontalLayout = HorizontalLayout.fullWidth()
and then the chart started to crash in my @Preview
. Later I realized that the crash only occurs if the chart encompasses the entire screen's width (which was true for my preview).
I was able to fix this by either using the HorizontalLayout.segmented()
layout or by adding at least a 1.dp
horizontal padding to the parent composable (theBox
in the @Preview
of your sample).
I ran into the same issue today when I simply just swapped the
HorizontalLayout
tohorizontalLayout = HorizontalLayout.fullWidth()
and then the chart started to crash in my@Preview
. Later I realized that the crash only occurs if the chart encompasses the entire screen's width (which was true for my preview).I was able to fix this by either using the
HorizontalLayout.segmented()
layout or by adding at least a1.dp
horizontal padding to the parent composable (theBox
in the@Preview
of your sample).
I can confirm that setting the layout to HorizontalLayout.segmented()
worked. The 1.dp
horizontal margin to the parent composable did the trick only for the Preview
not for running the app.
Thanks for the temporary solution, @matejbart š
Taking advantage of the fact that I have created this issue, we're in the middle of a migration from
2.0.0-alpha.14
to2.0.0-alpha.17
and it would be amazing if you could help us with some questions we've faced during the migration.Custom marker
We do have a custom marker to change the overlay design using the
SpannedString
. However, even though I read some issues and all the versions' documentation, I'm not able to migrate from themarkedEntries
to thetargets
.This is the piece of code we'd like to convert to the
CartesianMarkerValueFormatter
:private val labelFormatter: MarkerLabelFormatter = MarkerLabelFormatter { markedEntries, chartValues -> if (markedEntries.isNotEmpty()) { val entryIndex = if (markedEntries.size == 1) PercentageDecimals else indexEntryModelToShowIndicator val xEntry = markedEntries[entryIndex].entry.x.toInt() val attended = markedEntries.last().entry.y.toInt() val requested = markedEntries.first().entry.y.toInt()
I hope you can help us, we're kinda struggling š Keep it up, guys!
Also, I'd appreciate it if you could help us with this as well @Gowsky. Thanks!
Forget about it. I was able to migrate from markedEntries
to `targets. However, I think it should be valuable to add some migration documentation since I had to do it digging into the code. Thanks anyway for the help š
@diego-francisco-jt thanks for the updated example. It will work, but please ensure it is minimal next time.
Also, I'd appreciate it if you could help us with this as well @Gowsky. Thanks!
As I initially said, we will help you with the migration as soon as we can.
@qq2540040142 @matejbart thank you for your tips!
We've reproduced the bug. Here's a temporary workaround that is almost invisible.
horizontalLayout =
with(LocalDensity.current) {
HorizontalLayout.fullWidth(
unscalableStartPadding = 1.toDp(),
unscalableEndPadding = 1.toDp(),
)
}
We've reproduced the bug. Here's a temporary workaround that is almost invisible.
horizontalLayout = with(LocalDensity.current) { HorizontalLayout.fullWidth( unscalableStartPadding = 1.toDp(), unscalableEndPadding = 1.toDp(), ) }
i tried to put this solution but it still crashes i have more than 300 points
FATAL EXCEPTION: main Process: com.areeb.invest_01.dev, PID: 20003 java.lang.IllegalArgumentException: x must be >= 0 at android.graphics.Bitmap.checkXYSign(Bitmap.java:440) at android.graphics.Bitmap.checkPixelAccess(Bitmap.java:2148) at android.graphics.Bitmap.getPixel(Bitmap.java:2058) at com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer.updateMarkerTargets(LineCartesianLayer.kt:392) at com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer.drawInternal$lambda$3$lambda$2$lambda$1(LineCartesianLayer.kt:361) at com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer.$r8$lambda$X5LX4R_c_OLNMkJTndrlghKMN_c(Unknown Source:0) at com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer$$ExternalSyntheticLambda2.invoke(Unknown Source:27) at com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer.forEachPointInBounds(LineCartesianLayer.kt:548) at com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer.drawInternal(LineCartesianLayer.kt:360) at com.patrykandpatrick.vico.core.cartesian.layer.LineCartesianLayer.drawInternal(LineCartesianLayer.kt:76) at com.patrykandpatrick.vico.core.cartesian.layer.BaseCartesianLayer.draw(BaseCartesianLayer.kt:59) at com.patrykandpatrick.vico.core.cartesian.CartesianChart$drawingModelAndLayerConsumer$1.invoke(CartesianChart.kt:96) at com.patrykandpatrick.vico.core.cartesian.CartesianChart.forEachWithLayer(CartesianChart.kt:420) at com.patrykandpatrick.vico.core.cartesian.CartesianChart.draw-43zNVmo(CartesianChart.kt:247) at com.patrykandpatrick.vico.compose.cartesian.CartesianChartHostKt.CartesianChartHostImpl$lambda$19(CartesianChartHost.kt:228) at com.patrykandpatrick.vico.compose.cartesian.CartesianChartHostKt.$r8$lambda$b9Nv60KzYR9TCaxUzosrVlUpJUU(Unknown Source:0) at com.patrykandpatrick.vico.compose.cartesian.CartesianChartHostKt$$ExternalSyntheticLambda4.invoke(Unknown Source:25) at androidx.compose.ui.draw.DrawBackgroundModifier.draw(DrawModifier.kt:116) at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:105) at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:86) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:364) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:926) at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176) at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361) at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353) at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:926) at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
Vico 2.0.0-alpha.28 fixes this bug.
@diego-francisco-jt
However, I think it should be valuable to add some migration documentation
We plan on adding more information about CartesianMarker.Target
to the wiki.
Hey guys,
First of all, thank you a lot for doing this library, you've been doing such an amazing job š
How to reproduce
Just running the app with the following code throws the exception. We've been trying modifying our code here and there without any luck.
So sorry for the code being so dirty, we're in the middle of a migration from the
2.0.0-alpha.14
version.Observed behavior
This is the thrown exception:
Expected behavior
We'd expect the graph to draw as usual.
Vico version(s)
2.0.0-alpha.27
Android version(s)
Android 12
Additional information
No response