Comments (8)
Hey! Thanks for the reply
Hello. I did some stress testing and I haven't experienced this crash.
Could it be because the CartesianChartModelProducer is recreated when the chart is visible again?
This shouldn't be the reason. Have you tried putting
CartesianChartModelProducer
in the viewmodel, as suggested here? The examples useLaunchedEffect
for simplicity, but especially when the chart leaves and enters the composition, it's more optimal to store the producer in the viewmodel.
Yes, looking further into it, it seems like putting it in the ViewModel would most likely solve it. We were just trying to avoid it since we wanted the chart implementation to be part of a UI-only module, and this way we'll also have to put it a Vico dependency in the module that the ViewModel is in. Or we will have to create a wrapper around it. Reason we wanted to keep it out of the ViewModel is in case we'd want to change the implementation or library, we would have fewer places to change and it would be more contained.
Do you folks have any idea of how we can try to replicate this issue?
It's hard to tell without specific information. Is there anything common between the incidents? Like low-spec devices?
So far only had issues with Android 12, 13, and 14. Devices are not low-spec, they're decent (most common so far is Galaxy A53 5G).
I tried to understand the internal Vico code and had an idea, but might be totally wrong. Maybe still worth checking on your side just in case though. Click here to check the details
I was taking a look at the logic in CartesianChartModelProducer
, and I think there are potential race conditions. With debugging breakpoints (non-suspend, log only) we can see that registerForUpdates
(suspend function) and unregisterFromUpdates
can be called before, during, or after tryUpdate
. This can mean that a transaction might be running when a receiver is registered/unregistered, which could cause the ConcurrentModificationException
. registerForUpdates
is also called inside a scope.launch
- which is scheduled to be immediately run, but might there might be a delay (albeit small of course) if
To solve it, registering or unregistering a receiver would need to either:
- Check and wait for the
Mutex
lock before setting/removing - Cancel any ongoing transaction before setting/removing
Otherwise there might be an unfortunate timing.
With that said, I still can't replicate the issue, so I'm probably still missing something! I think I will try to move it to the ViewModel and see if it's fixed, but I believe the race condition will still be possible, just less probable (almost impossible, I guess) since the transaction will most likely be done before the chart is composed, and as such the receiver will always be registered after the transaction is complete (and fewer transactions will also be done, since it will not be done every time the chart is composed), and there's a smaller chance of a transaction being ran when unregistering since there will be fewer transactions too.
from vico.
Hello. I did some stress testing and I haven't experienced this crash.
Could it be because the CartesianChartModelProducer is recreated when the chart is visible again?
This shouldn't be the reason. Have you tried putting CartesianChartModelProducer
in the viewmodel, as suggested here? The examples use LaunchedEffect
for simplicity, but especially when the chart leaves and enters the composition, it's more optimal to store the producer in the viewmodel.
Do you folks have any idea of how we can try to replicate this issue?
It's hard to tell without specific information. Is there anything common between the incidents? Like low-spec devices?
Let me know if you see any issue in our implementation too, please!
I can't see any issues that could cause this.
from vico.
I also got this crash, spent a few hours looking for the culprit no luck yet
in the below code, yRanges[axisPosition]
returns null because yRanges
is empty and yRanges.getValue(null)
throws the NoSuchElementException with the message "Key null is missing in the map."
in MutableChartValues.kt
public fun MutableChartValues.toImmutable(): ChartValues =
object : ChartValues {
private val yRanges = [email protected]
override val minX: Float = [email protected]
override val maxX: Float = [email protected]
override val xStep: Float = [email protected]
override val model: CartesianChartModel = [email protected]()
override fun getYRange(axisPosition: AxisPosition.Vertical?): ChartValues.YRange =
yRanges[axisPosition] ?: yRanges.getValue(null)
}
UPDATE:
I was using the chart host that takes in a CartesianChartModel instead of the CartesianChartModelProducer. After changing it to match OP's implementation with the model producer and the LaunchedEffect, I no longer see the issue, so I'm not sure why OP has the issue. 🤷
from vico.
Related Issues (20)
- Marker missing style defined by custom MarkerLabelFormatter HOT 9
- Cannot access CartesianChartHost in my project HOT 2
- Reading a state that was created after the snapshot was taken or in a snapshot that has not yet been applied HOT 6
- Cannot make a LabelFormatter on stacked column chart HOT 11
- Markers only works for the first line series HOT 2
- Crash on changing dataset which contains negative values HOT 3
- Throwing OOM Exception when using Chart in LazyColumn HOT 7
- Marker duplicated HOT 2
- No axisValueOverrider in rememberCandlestickCartesianLayer HOT 4
- Feature Missing - Slide to Position HOT 4
- Text alignment on y-axis label only shown correctly for ALIGN_NORMAL HOT 6
- [View] CartesianChartView always handles touches, even if `isClickable` or `isEnabled` is false HOT 6
- Cannot Round NaN to Float HOT 4
- Crash inside AnimatedVisibility() HOT 4
- ColumnChart with MergeMode.Grouped does not receive callback for all the series added through CartesianMarkerVisibilityListener HOT 2
- TopBottomShader.splitY doesn't do anything HOT 1
- Incorrect floating point rounding in xSpacingMultiplier calculation leads to wrong IllegalStateException HOT 6
- At the end the label of bottom axis is cut off HOT 5
- Bottom label truncated sometimes HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vico.