We are experiencing an issue with the Adaptive Cards Library where it crashes when handling a specific card. This issue is reproducible in both the Webex app and the AdaptiveCards Visualizer sample app. The JSON for the problematic card is attached to this issue for reference.
Here's a high-level overview of the problem:
The issue seems to originate from the Adaptive Cards Library. It occurs even when the card's JSON contains an image of a relatively small size (2-4 MB) even with a smaller resolution say 400 x 1200
The specific card causing the issue has dimensions of 900 pixels (Width) x 12500 pixels (Height). The provided image is intended to be the background of the card. As we dont see that any limit is enforced in Adaptive Cards lib for card sizes, the cad should get rendered properly.
But The library uses scaling logic to set the card background to match the card size. However, this scaling logic appears to have a flaw.
The size will become 400(width)x10.41 x 1200(height)x10.41 x 4 (32 bit bitmap) = 208066752 Bytes = 208 MB
And the Android is supporting bitmap of < 100 MB
Due to this flaw, the image (intended to be set as the background) scales up to an excessive size. In our case, the image sometimes exceeded 1 GB.
Crash Logs
--------- beginning of crash
05-08 19:23:27.077 4423 4423 E AndroidRuntime: FATAL EXCEPTION: main
05-08 19:23:27.077 4423 4423 E AndroidRuntime: Process: io.adaptivecards.adaptivecardssample, PID: 4423
05-08 19:23:27.077 4423 4423 E AndroidRuntime: java.lang.RuntimeException: Canvas: trying to draw too large(1085175364bytes) bitmap.
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:266)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:94)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at io.adaptivecards.renderer.BackgroundImageLoaderAsync$BackgroundImageDrawable.resizeBitmapForCover(BackgroundImageLoaderAsync.java:145)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at io.adaptivecards.renderer.BackgroundImageLoaderAsync$BackgroundImageDrawable.draw(BackgroundImageLoaderAsync.java:81)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.getDrawableRenderNode(View.java:23483)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.drawBackground(View.java:23412)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:23186)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22061)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:23197)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22061)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:23197)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.widget.ScrollView.draw(ScrollView.java:1869)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22061)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1246)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:23197)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22061)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22052)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:22925)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.drawChild(ViewGroup.java:4529)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4290)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.draw(View.java:23197)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at com.android.internal.policy.DecorView.draw(DecorView.java:821)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.View.updateDisplayListIfDirty(View.java:22061)
05-08 19:23:27.077 4423 4423 E AndroidRuntime: at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:689)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:695)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:793)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.ViewRootImpl.draw(ViewRootImpl.java:4670)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4381)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3600)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2328)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9087)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1231)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1239)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:899)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:832)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1214)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:942)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:201)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.os.Looper.loop(Looper.java:288)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7872)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
05-08 19:23:27.079 4423 4423 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Pull requests and issue creations will no longer be accepted and will be closed. Please send all issues with Adaptive Cards to Microsoft Teams docs repo (msteams-docs)
Issues will be reviewed and prioritized from there
Source code will still be available to the public.
Target Platforms
Android
SDK Version
2.8.4, main branch
Application Name
Webex APP && AdaptiveCards Visualizer
Problem Description
We are experiencing an issue with the Adaptive Cards Library where it crashes when handling a specific card. This issue is reproducible in both the Webex app and the AdaptiveCards Visualizer sample app. The JSON for the problematic card is attached to this issue for reference.
Here's a high-level overview of the problem:
The issue seems to originate from the Adaptive Cards Library. It occurs even when the card's JSON contains an image of a relatively small size (2-4 MB) even with a smaller resolution say 400 x 1200
The specific card causing the issue has dimensions of 900 pixels (Width) x 12500 pixels (Height). The provided image is intended to be the background of the card. As we dont see that any limit is enforced in Adaptive Cards lib for card sizes, the cad should get rendered properly.
But The library uses scaling logic to set the card background to match the card size. However, this scaling logic appears to have a flaw.
Library is scaling the image in both direction unnecessary, which in turn creating a BitmapDrawable of bigger size
400(width)x10.41 x 1200(height)x10.41 x 4 (32 bit bitmap) = 208066752 Bytes = 208 MB
Due to this flaw, the image (intended to be set as the background) scales up to an excessive size. In our case, the image sometimes exceeded 1 GB.
Crash Logs
Screenshots
Gif for the flow![Screen Recording 2024-05-08 at 19 22 36](https://github.com/microsoft/AdaptiveCards-Mobile/assets/9429655/b374ae42-dc45-40d4-833d-e613cb4fc0ba)
Card JSON
Sample Code Language
No response
Sample Code
No response