Modifier.glideNode has a error.
Glide Version:
dependencies {
implementation("com.github.bumptech.glide:glide:4.16.0")
ksp("com.github.bumptech.glide:ksp:4.16.0")
}
Integration libraries:
dependencies {
implementation("com.github.bumptech.glide:okhttp3-integration:4.16.0")
implementation("com.github.bumptech.glide:compose:1.0.0-alpha.5")
}
Device/Android Version:
Android Emulator API 34
Issue details / Repro steps / Use case background:
If set Modifier.padding(xxx) for GlideSubcomposition, the padding applied twice。
Glide load line / GlideModule (if any) / list Adapter code (if any):
@Preview(showSystemUi = true) @OptIn(ExperimentalGlideComposeApi::class) @Composable fun SimpleGlide() { var lastSize by remember { mutableStateOf(Size.Unspecified) } Surface { GlideSubcomposition( model = null, modifier = Modifier .fillMaxWidth() .aspectRatio(1f) .drawBehind { Log.d("SimpleGlide",size.toString()) if (lastSize.isUnspecified) { lastSize = this.size drawRect(Color.Blue) } else if (lastSize != this.size) { drawRect(Color.Red) }else{ drawRect(Color.Blue) } } .padding(40.dp), ) { when (state) { RequestState.Failure -> Image( imageVector = Icons.Default.MusicNote, contentDescription = "placeholder", modifier = Modifier.fillMaxSize() ) RequestState.Loading -> Spacer(modifier = Modifier.shimmerPlaceholder(visible = true)) is RequestState.Success -> Image(painter = painter, contentDescription = null) } } } }
Stack trace / LogCat:
2023-08-31 13:18:32.354 8397-8397 SimpleGlide com.xxx.development D Size(1080.0, 1080.0) 2023-08-31 13:18:32.354 8397-8397 SimpleGlide com.xxx.development D Size(870.0, 870.0) 2023-08-31 13:18:32.480 8397-8397 SimpleGlide com.xxx.development D Size(1080.0, 1080.0) 2023-08-31 13:18:32.481 8397-8397 SimpleGlide com.xxx.development D Size(870.0, 870.0)
compose library code:
@ExperimentalGlideComposeApi internal fun Modifier.glideNode( requestBuilder: RequestBuilder<Drawable>, contentDescription: String? = null, alignment: Alignment? = null, contentScale: ContentScale? = null, alpha: Float? = null, colorFilter: ColorFilter? = null, transitionFactory: Transition.Factory? = null, requestListener: RequestListener? = null, draw: Boolean? = null, ): Modifier { return this then GlideNodeElement( requestBuilder, contentScale ?: ContentScale.None, alignment ?: Alignment.Center, alpha, colorFilter, requestListener, draw, transitionFactory, ) then clipToBounds() then if (contentDescription != null) { semantics { this@semantics.contentDescription = contentDescription role = Role.Image } } else { Modifier } }
The then clipToBounds() is equivalent to then this.clipToBounds(), should use .clipToBounds() or Modifier.clipToBounds().
The modifier **semantics{} ** is also a similar error.
