Repository: google/accompanist

Issue #424: [Glide] Crashing during init of Preview
Created: 2021-05-18T14:39:46Z
Describe the bug
use remeberGlidepainter crash rendering preview
To Reproduce
val painter = rememberGlidePainter(
	request = avatarRef,
        previewPlaceholder = placeholder
)
Image(
     painter = painter,
     contentDescription = null,
     modifier = modifier
	        .size(75.dp)
		.clip(AvatarShape)
		.clickable { onClick?.let { it() } }
)
.....

java.lang.IllegalStateException: You cannot call Glide.get() in registerComponents(), use the provided Glide instance instead   at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:205)   at com.bumptech.glide.Glide.get(Glide.java:191)   at com.bumptech.glide.Glide.getRetriever(Glide.java:774)   at com.bumptech.glide.Glide.with(Glide.java:801)
Environment:

Android OS version: Android 9.0
Device: Emulator, Google Pixel 4
Accompanist version:  v0.9.1

Additional context
Add any other context about the problem here.

Duplicate issue #538: [glide] You cannot call Glide.get() in registerComponents(), use the provided Glide instance instead
Created: 2021-07-02T08:15:17Z
Describe the bug
When using glide as the painter for Image in in a preview composable, the following exception gets thrown, and the preview is not rendered (including any other elements the preview consists of).
2021-07-02 10:02:36,591 [2755194]   WARN - er.scene.LayoutlibSceneManager - You cannot call Glide.get() in registerComponents(), use the provided Glide instance instead  java.lang.IllegalStateException: You cannot call Glide.get() in registerComponents(), use the provided Glide instance instead at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:205) at com.bumptech.glide.Glide.get(Glide.java:191) at com.bumptech.glide.Glide.getRetriever(Glide.java:774) at com.bumptech.glide.Glide.with(Glide.java:801) at com.google.accompanist.glide.GlidePainterDefaults.defaultRequestManager(Glide.kt:71) at com.google.accompanist.glide.GlideKt.rememberGlidePainter(Glide.kt:94) at com.test.project.MyViewKt.ImagePreview(MyView.kt:81) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at androidx.compose.ui.tooling.preview.PreviewUtilsKt.invokeComposableMethod(PreviewUtils.kt:141) at androidx.compose.ui.tooling.preview.PreviewUtilsKt.invokeComposableViaReflection(PreviewUtils.kt:180) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$init$3$1$composable$1.invoke(ComposeViewAdapter.kt:540) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$init$3$1$composable$1.invoke(ComposeViewAdapter.kt:538) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.kt:577) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$init$3$1.invoke(ComposeViewAdapter.kt:533) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215) at androidx.compose.ui.tooling.InspectableKt.Inspectable(Inspectable.kt:64) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.kt:482) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$WrapPreview$1.invoke(ComposeViewAdapter.kt:481) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215) at androidx.compose.ui.tooling.preview.ComposeViewAdapter.WrapPreview(ComposeViewAdapter.kt:481) at androidx.compose.ui.tooling.preview.ComposeViewAdapter.access$WrapPreview(ComposeViewAdapter.kt:111) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.kt:533) at androidx.compose.ui.tooling.preview.ComposeViewAdapter$init$3.invoke(ComposeViewAdapter.kt:530) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.ui.platform.ComposeView.Content(ComposeView.android.kt:370) at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:228) at androidx.compose.ui.platform.AbstractComposeView$ensureCompositionCreated$1.invoke(ComposeView.android.kt:227) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215) at androidx.compose.ui.platform.CompositionLocalsKt.ProvideCommonCompositionLocals(CompositionLocals.kt:148) at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:114) at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt$ProvideAndroidCompositionLocals$3.invoke(AndroidCompositionLocals.android.kt:113) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215) at androidx.compose.ui.platform.AndroidCompositionLocals_androidKt.ProvideAndroidCompositionLocals(AndroidCompositionLocals.android.kt:106) at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:162) at androidx.compose.ui.platform.WrappedComposition$setContent$1$1$3.invoke(Wrapper.android.kt:161) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:215) at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:161) at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(Wrapper.android.kt:144) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.ComposerKt.invokeComposable(Composer.kt:3320) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2571) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2567) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(SnapshotState.kt:523) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2560) at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:2515) at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:476) at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:726) at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:432) at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:144) at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135) at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(AndroidComposeView.android.kt:711) at androidx.compose.ui.platform.WrappedComposition.setContent(Wrapper.android.kt:135) at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Wrapper.android.kt:187) at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:354) at androidx.lifecycle.LifecycleRegistry.addObserver(LifecycleRegistry.java:196) at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:142) at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(Wrapper.android.kt:135) at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(AndroidComposeView.android.kt:775) at android.view.View.dispatchAttachedToWindow(View.java:20479) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3489) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3496) at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:44) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:360) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:431) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:714) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$7(RenderTask.java:870) at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$2.run(RenderExecutor.kt:187) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)
To Reproduce
This codesnippet reproduces the behaviour:
@Preview @Composable fun ImagePreview() { Image( painter = rememberGlidePainter( request = "https://via.placeholder.com/150", fadeIn = true, ), contentDescription = null, contentScale = ContentScale.Fit, modifier = Modifier.size(150.dp, 150.dp) ) }
Expected behavior
The preview should be rendered, with or without the requested image being shown.
Environment:

Android Studio: Artic Fox 2020.3.1 Beta4
Android Target SDK: 30
Build Tools Version: 30.0.3
Accompanist version: [0.11.0]

Closing comment (2021-07-02T08:59:13Z): Duplicate of #424