Status Update
Comments
js...@google.com <js...@google.com>
jr...@google.com <jr...@google.com>
nj...@google.com <nj...@google.com> #2
Luke - am I right in thinking this already fixed in AGP at head?
nj...@google.com <nj...@google.com> #3
Yes, all Android resource inputs can now only use relative path sensitivity, apart from custom resource directories located outside the project when data binding is enabled. The mentioned inputs in the stacktrace such as resourcesComputer.resources.fastdev.sourceDirectoriesAbsolute
have been removed at head.
dm...@gmail.com <dm...@gmail.com> #4
Is "head" == AGP 7.3.1?
or 7.3.0?
Could you please look at git history to see which version the fix is in?
nj...@google.com <nj...@google.com> #5
This change will be present in AGP 8.0.0-alpha01, since this changed happened very recently.
dm...@gmail.com <dm...@gmail.com> #6
any chance it could be cherrypicked to 7.3.1 or 7.4? Would be nice to see better remote cache hit rates.
nj...@google.com <nj...@google.com> #7
It looks like in
That being said the sample code is incorrect in that the it creates a separate Canvas from a bitmap which is software backed and attempts to draw a View + RenderNodes into it which is not supported for a software backed Canvas:
dm...@gmail.com <dm...@gmail.com> #8
It looks like in
this was tested on an older version of jetpack compose. comment #1
At the time of the report, it was the latest version - 1.1.1.
I'd update it to 1.2.0, but compose.ui
is still 1.1.1.
That being said the sample code is incorrect in that the it creates a separate Canvas from a bitmap which is software backed and attempts to draw a View + RenderNodes into it which is not supported for a software backed Canvas:
There's nothing incorrect about the sample code. It does exactly what I'd like to (creates a bitmap backed software canvas and draws the hierarchy there).
I'm aware that drawRenderNode
works only with a hardware canvas, but my example doesn't call drawRenderNode
and neither does ComposeView when drawing on a software canvas.
Here's the working version of a software canvas snapshot -
The core of the problem I'm trying to report is that the ComposeView incorrectly tries to go through a hardware rendering path when a software rendering is being performed during the hardware drawing traversal.
It doesn't happen when the software rendering is requested outside of onDraw
or draw
of ComposeView hierarchy. (Again, see the branch I linked above).
nj...@google.com <nj...@google.com> #9
We recommend updating to the latest version of compose and trying again.
With the sample provided, I am unable to reproduce the error with the latest Compose sources.
Note that there have been a number of improvements to provide a best effort when rendering compose in a software rendering environment. This includes transformations (translation/rotation/scale and alpha effects) all other graphics facilities are ignored when rendering with a software backed canvas.
dm...@gmail.com <dm...@gmail.com> #10
We recommend updating to the latest version of compose and trying again.
The sample still crashes on 1.2.0-rc3 and 1.3.0-alpha01. What version should I update to?
With the sample provided, I am unable to reproduce the error with the latest Compose sources.
The latest Compose sources (AndroidComposeView
, RenderNodeLayer
, RenderNodeApi29
from here androidx.compose.ui:ui:1.3.0-alpha01
I just updated to and it still crashes on them.
What kind of version are you testing with?
Are you using master
branch from the repo I linked?
I'm also using API 30 emulator if that matters.
dm...@gmail.com <dm...@gmail.com> #11
I've updated the sample (
nj...@google.com <nj...@google.com> #12
We introduced a new API GraphicsLayer
in Compose 1.7 alpha that can be used to draw portions of the composition hierarchy elsewhere. Similarly this API allows for creation of a bitmap with the content of the GraphicsLayer as well. This API leverages hardware accelerated rendering for all supported API levels. Attempts to render into an ImageBitmap from this API will be hardware accelerated from API 22+ and will fallback onto software rendering for API 21.
See GraphicsLayerSamples for details here:
Description
Jetpack Compose version: 1.1.1
Jetpack Compose component used: AndroidView
Android Studio Build: Android Studio Chipmunk | 2021.2.1
Build #AI-212.5712.43.2112.8512546, built on April 28, 2022
Kotlin version: 1.6.10
Steps to Reproduce or Code Sample to Reproduce:
Code sample -https://github.com/Dimezis/JetpackComposeCanvasCrash
Steps:
Even though the example is weird, it's based on a real problem -https://github.com/Dimezis/BlurView/issues/157
I'm trying to obtain a hierarchy snapshot on a software canvas backed by a bitmap, but unlike the regular View system, Compose crashes on it, for some reason. Judging by the internals of the
AndroidComposeView.dispatchDraw
, it can be fixed. I haven't tried building a fixed version of Compose, but it seems to me thatupdateDisplayList
should not be called whendispatchDraw
is called with a software canvas as an argument.Stack trace: