patrykandpatrick / vico

A light and extensible chart library for Android.
https://patrykandpatrick.com/vico/wiki
Apache License 2.0
2.07k stars 125 forks source link

LineCharts throw IllegalArgumentException in Compose Previews #856

Closed mahoganykilo closed 3 weeks ago

mahoganykilo commented 3 weeks ago

How to reproduce

Check Example app previews for ample evidence.

Android Studio Koala | 2024.1.1 Patch 1 Build #AI-241.18034.62.2411.12071903, built on July 10, 2024 Runtime version: 17.0.11+0-17.0.11b1207.24-11852314 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 14.6.1 GC: G1 Young Generation, G1 Old Generation Memory: 8192M Cores: 10 Metal Rendering is ON Registry: idea.ignore.disabled.plugins=true Non-Bundled Plugins: wu.seal.tool.jsontokotlin (3.7.4) com.github.copilot (1.5.17.6356) com.suusan2go.kotlin-fill-class (1.0.23) com.getyourguide.paparazzi (1.2.2024.1)

Observed behavior

image

Expected behavior

Not throwing an exception

Vico version(s)

2.0.0-alpha.28

Android version(s)

n/a

Additional information

No response

Gowsky commented 3 weeks ago

Hi @mahoganykilo. This appears to be a bug in the Compose preview renderer. The Canvas initially has an incorrect size (0 by 0), while DrawContext.size reports the expected size. We will add a check for this and prevent the crash from happening, but since it's not actually a bug on our end, I'm closing this issue.