Status Update
Comments
ae...@google.com <ae...@google.com> #2
Triaging this to our graphics expert, but it sounds like we'd need a local repro on a Huawei device to make progress. tpterence, could you name one specific Huawei device you saw this on? Also, would it be possible to have source code for a sample app that consistently reproes it?
tp...@gmail.com <tp...@gmail.com> #3
Attached screenshot of Huawei devices from crashlytics. Sure I can try to extract the composable screen of interest into a sample app.
tp...@gmail.com <tp...@gmail.com> #4
Managed to extract the composables from main project to replicate the issue in a sample project.
2021-11-22 16:56:00.237 2684-2684/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.terence.composeTest, PID: 2684
java.lang.NullPointerException
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:245)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:760)
at android.view.View.draw(View.java:21654)
...
Crash reproduced on Huawei device: Huawei Y5p Android 10
Steps to reproduce
- Run the project
- Enter any 6 digit passcode
- App crashes shortly after showing loading screen
As mentioned earlier the same sample project is not crashing when running on other non Huawei devices e.g. tested on Pixel 3XL
Have trace down further to this extension function used in AnimatedVectorDrawableRepeating as workaround for auto starting avd drawables related to this issue on Avd repeating animations are not repeating.
fun ImageView.autoStartAnimation(autoStart: Boolean = false, loopAnim: Boolean = false) {
// Fix for java.lang.NullPointerException at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:245) from
// IndeterminateLoadingScreen with avd drawable happening on Huawei devices mostly
// Commented out post block for crash reproduction
// post {
if (drawable is Animatable) {
val animatable = drawable as Animatable
if (autoStart) {
if (!animatable.isRunning) {
if (loopAnim) {
doOnAttach {
when (animatable) {
is AnimatedVectorDrawableCompat -> {
val animationListener = object : Animatable2Compat.AnimationCallback() {
override fun onAnimationEnd(drawable: Drawable?) {
post { animatable.start() }
}
}.apply {
animatable.registerAnimationCallback(this)
}
doOnDetach {
animatable.unregisterAnimationCallback(animationListener)
}
}
is AnimatedVectorDrawable -> {
val animationListener = object : Animatable2.AnimationCallback() {
override fun onAnimationEnd(drawable: Drawable?) {
post { animatable.start() }
}
}.apply {
animatable.registerAnimationCallback(this)
}
doOnDetach {
animatable.unregisterAnimationCallback(animationListener)
}
}
}
}
}
animatable.start()
}
} else {
animatable.stop()
}
}
// }
}
@ExperimentalAnimationGraphicsApi
@Composable
fun AnimatedVectorDrawableRepeating(
modifier: Modifier = Modifier,
manualLoopAnim: Boolean = false, // used for when avd does not internally do repeating="infinite"
@DrawableRes id: Int
) {
AndroidView(
modifier = modifier,
factory = {
ImageView(it).apply {
scaleType = ImageView.ScaleType.FIT_CENTER
setImageResource(id)
autoStartAnimation(autoStart = true, loopAnim = manualLoopAnim)
}
},
update = {}
)
}
Please refer to sample project's IndeterminateLoadingScreen.kt for the above code snippets.
I managed to workaround the crash with a fix by wrapping the code in ImageView.autoStartAnimation with a post { } block. Based on testing, the last known versions combination
compose_version = '1.1.0-alpha05'
accompanist_version = '0.20.2'
isn't crashing even without adding the post block in the ImageView.autoStartAnimation extension function. Any combinations of newer versions other than above would be able to reproduce the crash if the post block is not present as demonstrated in the sample project.
tp...@gmail.com <tp...@gmail.com> #5
Hi all, some updates for this issue, from our crashlytics noticed that adding the post { } block still causes the same crash on 100% Android 7 Samsung devices when calling animatable.start() with AndroidView.
Crash is happening for Note 5 and S6, S6 edge and edge+ devices as per screenshot attached.
May I check if there are any updates regarding this issue?
ma...@gmail.com <ma...@gmail.com> #6
This also happens on OnePlus 7 Pro running LineageOS
th...@gmail.com <th...@gmail.com> #7
I am running into the same issue with my Compose app on Wear OS. Samsung Galaxy Watch4. Could this please be fixed?
Similar issue:
java.lang.NullPointerException
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:292)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:857)
at android.view.View.draw(View.java:22879)
at android.view.View.updateDisplayListIfDirty(View.java:21744)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4537)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4509)
at android.view.View.updateDisplayListIfDirty(View.java:21698)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4537)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4509)
at android.view.View.updateDisplayListIfDirty(View.java:21698)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4537)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4509)
at android.view.View.updateDisplayListIfDirty(View.java:21698)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:642)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4270)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3983)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3231)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2048)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8575)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:998)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:731)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:983)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:7690)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)
st...@google.com <st...@google.com> #8
Re
th...@gmail.com <th...@gmail.com> #9
I have not been able to create a sample for the crash with Wear Compose. What I did find out is that if I remove PositionIndicator
from my code the crash no longer occurs. See also:
st...@google.com <st...@google.com> #10
Thomas, is your code also using AnimatedVectorDrawables like the example in the original report?
We are using AVDs in a dialog sample, but I haven't seen that error - perhaps you could test it on your devices to see if it can trigger the exception?
th...@gmail.com <th...@gmail.com> #11
AnimatedVectorDrawables
work fine on the Galaxy Watch4. I am actually using the sample for the open on phone animation you linked in my project already, which works without any issues.
nj...@google.com <nj...@google.com> #12
I have tried the sample github project in
I recommend updating to the latest version of compose or providing a more minimal sample application for the team to look into.
tp...@gmail.com <tp...@gmail.com> #13
Are you running the sample on specific device? The github project is crashing only on Huawei devices running Android 10 or certain android 7 devices. I have tried it again on emulator running on Android 7 API 24 also able to reproduce the crash. Video as attached.
2022-01-13 14:09:57.183 3991-3991/com.terence.composeTest E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.terence.composeTest, PID: 3991
java.lang.NullPointerException
at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:245)
at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:760)
at android.view.View.draw(View.java:17074)
at android.view.View.updateDisplayListIfDirty(View.java:16053)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3748)
at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3728)
at android.view.View.updateDisplayListIfDirty(View.java:16016)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:656)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:662)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:770)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2796)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2604)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2211)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:619)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
2022
ap...@google.com <ap...@google.com> #14
Branch: androidx-main
commit f4ad578674a55af824e19d6e921dcd68f5eeff82
Author: Nader Jawad <njawad@google.com>
Date: Wed Jan 12 16:10:47 2022
Add defensive null check
Add conditional let block within
logic to record drawing operations
in case the displaylist for a RenderNodeLayer
is attempted to be updated after the layer
has been destroyed
Fixes: 206677462
Test: re-ran compose tests
Change-Id: I838d3170547716fa35d6e9b630db995075e814d9
M compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/RenderNodeLayer.android.kt
to...@branchapp.com <to...@branchapp.com> #15
ri...@ffw.com <ri...@ffw.com> #16
th...@gmail.com <th...@gmail.com> #17
Thanks for the fix! I can confirm it works with the latest snapshot in my Wear OS app.
lc...@gmail.com <lc...@gmail.com> #18
Can this fix be ported to 1.1.0 version too? i see that its currently onl in 1.2.0-alpha02
fr...@instacart.com <fr...@instacart.com> #19
+1, this is forcing us to downgrade compose and kotlin, this needs to be in 1.1
be...@google.com <be...@google.com> #20
This fix has been cherry picked to 1.1.1 as well
na...@google.com <na...@google.com> #21
The following release(s) address this bug:
androidx.compose.ui:ui:1.3.0
Description
Hello, noticed a NPE crash in compose ui after updating from 1.1.0-alpha05 to 1.1.0-beta01. Crash happening in RenderNodeLayer.updateDisplayList and happening 100% on Android 10 Huawei devices as reported on crashlytics. Initially thought it was due to code obfuscation issue but managed to replicate it consistently on a non obfuscated build.
Noticed from the stacktrace that somehow drawBlock in updateDisplayList is null but not sure in what scenarios it could become null?