Hello, I am getting the crash below with the late...
# compose
n
Hello, I am getting the crash below with the latest Compose but couldnโ€™t figure out where is it coming from because I do not explicitly set or get any color. Has anybody recently faced this by any chance?
Copy code
Fatal Exception: java.lang.IllegalArgumentException
Invalid ID, must be in the range [0..16)

android.graphics.ColorSpace.get (ColorSpace.java:1390)
k
Donโ€™t cut off the stack trace, put the full one here in the thread
n
Sure. This is the Firebase stacktrace. I am on
androidx.compose:compose-bom-alpha:2024.12.01
Copy code
Fatal Exception: java.lang.IllegalArgumentException: Invalid ID, must be in the range [0..16)
at android.graphics.ColorSpace.get(ColorSpace.java:1390)
at android.graphics.Color.colorSpace(Color.java:703)
at android.graphics.Paint.setColor(Paint.java:1143)
at androidx.compose.ui.platform.HapticDefaults$$ExternalSyntheticApiModelOutline0.m(D8$$SyntheticClass)
at androidx.compose.ui.graphics.WrapperVerificationHelperMethods.setColor-4WTKRHQ(AndroidPaint.android.kt:281)
at androidx.compose.ui.graphics.AndroidPaint_androidKt.setNativeColor-4WTKRHQ(AndroidPaint.android.kt:171)
at androidx.compose.ui.graphics.AndroidPaint.setColor-8_81llA(AndroidPaint.android.kt:63)
at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.configurePaint-2qPWKa0(CanvasDrawScope.kt:632)
at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.configurePaint-2qPWKa0$default(CanvasDrawScope.kt:620)
at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.drawCircle-VaOC9Bg(CanvasDrawScope.kt:342)
at androidx.compose.ui.node.LayoutNodeDrawScope.drawCircle-VaOC9Bg(:14)
at androidx.compose.ui.graphics.drawscope.DrawScope.drawCircle-VaOC9Bg$default(DrawScope.kt:669)
at androidx.compose.material.ripple.StateLayer.drawStateLayer-mxwnekA(Ripple.kt:497)
at androidx.compose.material.ripple.RippleNode.draw(Ripple.kt:390)
at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-eZhPAX0$ui_release(LayoutNodeDrawScope.kt:96)
at androidx.compose.ui.node.LayoutNodeDrawScope.draw-eZhPAX0$ui_release(LayoutNodeDrawScope.kt:83)
at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:445)
at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:63)
at androidx.compose.ui.node.NodeCoordinator$drawBlock$drawBlockCallToDrawModifiers$1.invoke(NodeCoordinator.kt:468)
at androidx.compose.ui.node.NodeCoordinator$drawBlock$drawBlockCallToDrawModifiers$1.invoke(NodeCoordinator.kt:467)
at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2489)
at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:460)
at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:244)
at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:124)
at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:474)
at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:470)
at androidx.compose.ui.platform.GraphicsLayerOwnerLayer$recordLambda$1.invoke(GraphicsLayerOwnerLayer.android.kt:261)
at androidx.compose.ui.platform.GraphicsLayerOwnerLayer$recordLambda$1.invoke(GraphicsLayerOwnerLayer.android.kt:259)
at androidx.compose.ui.graphics.layer.GraphicsLayer$clipDrawBlock$1.invoke(AndroidGraphicsLayer.android.kt:72)
at androidx.compose.ui.graphics.layer.GraphicsLayer$clipDrawBlock$1.invoke(AndroidGraphicsLayer.android.kt:67)
at androidx.compose.ui.graphics.layer.GraphicsLayerV29.record(GraphicsLayerV29.android.kt:251)
at androidx.compose.ui.graphics.layer.GraphicsLayer.recordInternal(AndroidGraphicsLayer.android.kt:438)
at androidx.compose.ui.graphics.layer.GraphicsLayer.record-mL-hObY(AndroidGraphicsLayer.android.kt:431)
at androidx.compose.ui.platform.GraphicsLayerOwnerLayer.updateDisplayList(GraphicsLayerOwnerLayer.android.kt:254)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:1697)
at android.view.View.draw(View.java:24398)
at android.view.View.updateDisplayListIfDirty(View.java:23256)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4732)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4704)
at android.view.View.updateDisplayListIfDirty(View.java:23203)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4732)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4704)
at android.view.View.updateDisplayListIfDirty(View.java:23203)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4732)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4704)
at android.view.View.updateDisplayListIfDirty(View.java:23203)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4732)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4704)
at android.view.View.updateDisplayListIfDirty(View.java:23203)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:753)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:759)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:857)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:5527)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:5220)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4382)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3017)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10699)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1301)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
at android.view.Choreographer.doCallbacks(Choreographer.java:923)
at android.view.Choreographer.doFrame(Choreographer.java:852)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8772)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
r
Which version of Compose is this? We have an incompatibility between Compose and platform color spaces but it's been fixed I believe
n
Hey @romainguy, it is
alpha-2024.12.01
Most frequent devices:
Galaxy Tab S6
,
Galaxy Tab S6Lite
and
TGR-W09
,
t
@romainguy Facing this too, it's caused by https://issuetracker.google.com/issues/379135036 from a quick search quite a few devices on Android 10/11 have broken colorspace handling and that path is now used triggering the crash.
r
Itโ€™s not that those devices have broken color space handling. The new code should check whether the current color space exists on the device. Whatโ€™s your repro case? Do you use a specific color space?
t
I don't use anything special and currently can't repro as no access to those devices. Seems some devices did crash with that error with color when googling that error.
Copy code
0xFFFFFFFF
That PR just enable the usage of longs for Android 10+ for setColorNative there's no actual other checks after.
r
I understand what the PR does, what I meant is well have to add extra checks but I'd like to understand what color space could be passed down to cause the crash. I can only think of OkLab but it should never be used directly on tbe paint the way we use it internally for interpolation.
t
I have an user that can repro but no idea what kind of code I could add to log usefull stuff
r
If you don't use any color space besides the default, don't worry about it.
But if you do have something I could use to repro the bug it'd be super useful.
t
I do use fully user configurable M3 themes and extract colors from images when playing stuff. So maybe I trigger something
r
I hope it's not a case of OEMs messing with the default implementation.
t
Well I have an APK that triggers on those devices for some cases no idea how to extract anything without a device to repro ๐Ÿ˜ž
r
If you have an APK and repro steps to send me, that'd be perfect
I can at least try on Pixel devices
t
It does not seems to occur on emulators ๐Ÿ˜ž
r
๐Ÿ˜•
And not on devices > Android 11?
We did change the internal implementation of this get () method to be safer
So maybe I should just raise the API level check
t
From Crashlytics no, but I've only pushed that version in beta yesterday so not enough data yet.
r
Ok thanks. I'll go through the logs for each API level to see what would be a safe point.
t
For a quick repro you can join the beta of https://play.google.com/store/apps/details?id=app.symfonik.music.player&hl=en_US&gl=US and just play music from the lists.
Else I'll need to prepare more and you'll sleep ๐Ÿ™‚
And a Galaxy Tab A7 Android 12 is now logged in Crashlytics ๐Ÿ˜ž
But good news is that I can repro on Pixel 4 Android 10 emulator image. Will investigate and post in the new opened issue if you can have it triaged thanks.
Debugger does not work great and lock but just logging via the debugger works and shows a Color(0.72509766, 0.60498047, 0.52685547, 0.45063537, None) that probably cause this. If none is valid, then it probably should be checked.
And found the culprit ๐Ÿ˜ž This is tied to animateColorAsState and having one of the state Color.Unspecified that generate colors without a color space.
r
Thanks!
This is catching a real issue: an unspecified color shouldn't make it all the way to the paint.
t
I guess the question is what was expected from animating color state from an Unspecified color. Maybe it did work by luck, but crashing now would be quite a major change no?
r
Yeah Unspecified happens to work
t
So independently of this, we should never animate from/to Unspecified as the result is also Unspecified even it work for the moment?
r
It will happen to convert to sRGB
But yeah unspecified will crash in various places (on purpose)
t
Yeah in my case it started from a stupid copy paste from the default color of a component. Will triple check all usage I might have thanks.
r
@Tolriq Iโ€™ve sent a fix for review
๐ŸŽ‰ 1
t
Thanks, in all cases I've migrated all the faulty animate code. I did copy paste that one way too much :( I should look into building something reusable.
n
@romainguy when is your next alpha release?
r
The change will treat Unspecified as sRGB like before. But you should avoid using Unspecified
๐Ÿ‘ 1
t
@nuhkoca it first needs to be merged then depending on the merge window it's released between 7 to 21 days.
๐Ÿ‘ 1
r
Hmm that will be more complicated than anticipated ๐Ÿ˜•
t
As always with Android, that's the fun part :) From my understanding the initial PR was more a performance improvement than a vital missing feature no? I really know nothing about all those color spaces :(
r
It was very much a feature
t
Arf ๐Ÿ˜ž Well then good luck finding the solution then.
@romainguy trying to move to snapshot to fully test, but it seems there's now a performance library that is not published at all even in snapshots and so I can't ๐Ÿ˜ž
Caused by https://android-review.googlesource.com/c/platform/frameworks/support/+/3312340 that now expose it as implementation when it was supposed to be a compile only library ๐Ÿ˜ž
r
We already fixed that yesterday.
t
r
The snapshots just aren't published yet
t
Ho so the library is no more compile only, did not checked the last version of the readme ๐Ÿ˜ž
r
Yeah
We just needed to update the Gradle file
t
Ok perfect will wait patiently then ๐Ÿ™‚ Thanks for the feedback.