Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose GlideImage, high aspect ratio image load will crash. #5412

Open
cuichanghao opened this issue May 28, 2024 · 0 comments
Open

Compose GlideImage, high aspect ratio image load will crash. #5412

cuichanghao opened this issue May 28, 2024 · 0 comments

Comments

@cuichanghao
Copy link

cuichanghao commented May 28, 2024

It seems only happen in high aspect ratio image will crash.
Like 760x58, but normal image will not crash, like 760x500.

java.lang.RuntimeException: Canvas: trying to draw too large(105836080bytes) bitmap.
    at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:266)
    at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:94)
    at androidx.compose.ui.graphics.AndroidCanvas.drawImageRect-HPBpro0(AndroidCanvas.android.kt:275)
    at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.drawImage-AZ2fEMs(CanvasDrawScope.kt:256)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawImage-AZ2fEMs(LayoutNodeDrawScope.kt:0)
    at androidx.compose.ui.graphics.drawscope.DrawScope.drawImage-AZ2fEMs$default(DrawScope.kt:551)
    at androidx.compose.ui.graphics.painter.BitmapPainter.onDraw(BitmapPainter.kt:93)
    at androidx.compose.ui.graphics.painter.Painter.draw-x_KDEd0(Painter.kt:212)
    at com.bumptech.glide.integration.compose.DoNotTransition$drawCurrent$1.invoke-QfoU1oo(Transition.kt:92)
    at com.bumptech.glide.integration.compose.DoNotTransition$drawCurrent$1.invoke(Transition.kt:90)
    at com.bumptech.glide.integration.compose.GlideNode$draw$2$1$1.invoke-d16Qtg0(GlideModifier.kt:346)
    at com.bumptech.glide.integration.compose.GlideNode$draw$2$1$1.invoke(GlideModifier.kt:345)
    at com.bumptech.glide.integration.compose.GlideNode.drawOne(GlideModifier.kt:326)
    at com.bumptech.glide.integration.compose.GlideNode.draw(GlideModifier.kt:345)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:105)
    at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:86)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:364)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361)
    at androidx.compose.ui.node.NodeCoordinator.access$getTmpLayerPositionalProperties$cp(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:383)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:382)
    at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.kt:131)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:382)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:380)
    at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.android.kt:209)
    at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:335)
    at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.android.kt:277)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:348)
    at androidx.compose.ui.node.LayoutNode.draw$ui_release(LayoutNode.kt:926)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawContent(LayoutNodeDrawScope.kt:66)
    at androidx.compose.foundation.DrawOverscrollModifier.draw(AndroidOverscroll.android.kt:81)
    at androidx.compose.ui.node.BackwardsCompatNode.draw(BackwardsCompatNode.kt:349)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:105)
    at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui_release(LayoutNodeDrawScope.kt:86)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:364)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:176)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:361)
    at androidx.compose.ui.node.NodeCoordinator.access$getTmpLayerPositionalProperties$cp(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:383)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1$1.invoke(NodeCoordinator.kt:382)
    at androidx.compose.runtime.snapshots.Snapshot.enter(Snapshot.kt:131)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:476)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:500)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:256)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:382)
    at androidx.compose.ui.node.NodeCoordinator$drawBlock$1.invoke(NodeCoordinator.kt:380)
    at androidx.compose.ui.platform.RenderNodeApi29.record(RenderNodeApi29.android.kt:209)
    at androidx.compose.ui.platform.RenderNodeLayer.updateDisplayList(RenderNodeLayer.android.kt:335)
    at androidx.compose.ui.platform.AndroidComposeView.dispatchDraw(AndroidComposeView.android.kt:1236)
    at android.view.View.draw(View.java:23202)
    at android.view.View.updateDisplayListIfDirty(View.java:22066)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4533)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4506)
    at android.view.View.updateDisplayListIfDirty(View.java:22022)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4533)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4506)
    at android.view.View.updateDisplayListIfDirty(View.java:22022)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4533)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4506)
    at android.view.View.updateDisplayListIfDirty(View.java:22022)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4533)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4506)
    at android.view.View.updateDisplayListIfDirty(View.java:22022)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4533)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4506)
    at android.view.View.updateDisplayListIfDirty(View.java:22022)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4533)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4506)
    at android.view.View.updateDisplayListIfDirty(View.java:22022)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:682)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:688)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:786)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:4582)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4293)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3520)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2289)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8958)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1319)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1327)
    at android.view.Choreographer.doCallbacks(Choreographer.java:985)
    at android.view.Choreographer.doFrame(Choreographer.java:916)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1302)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7972)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:586)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)

Call site

    // This will crash high ratio image.
    GlideImage(
        model = remember,
        contentDescription = contentDescription,
        contentScale = contentScale,
        modifier = modifier
            .aspectRatio(width.toFloat() / height.toFloat(), matchHeightConstraintsFirst = true),
        requestBuilderTransform = requestListener,
    )

Normal image is no problem, or if i not specify aspectRatio for GlideImage is no problem.

    // This is work even high ratio image.
    GlideImage(
        model = remember,
        contentDescription = contentDescription,
        contentScale = contentScale,
        requestBuilderTransform = requestListener,
    )

May be related to #4485

We use glide_compose = "1.0.0-beta01"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant