Canvas trying to draw too large bitmap
See original GitHub issue- Markwon version: 4.4.0
First of all, it’s working well, but it seems there’s a problem with huge image. Not sure if I’m configuring it wrongly. Correct me if I’m wrong please.
This is how I configure the builder. I’ve made sure to use Glide plugin.
val markwon = Markwon.builder(context)
.usePlugin(GlideImagesPlugin.create(GlideApp.with(context)))
.usePlugin(ImagesPlugin.create(ImagesPlugin.ImagesConfigure {
it.addMediaDecoder(GifMediaDecoder.create(true))
}))
.usePlugin(StrikethroughPlugin.create())
.usePlugin(SoftBreakAddsNewLinePlugin.create())
.usePlugin(object : AbstractMarkwonPlugin() {
override fun configureTheme(builder: MarkwonTheme.Builder) {
builder.headingBreakHeight(0)
}
override fun configure(registry: MarkwonPlugin.Registry) {
registry.require(HtmlPlugin::class.java) {
it.addHandler(AlignTagHandler())
}
}
})
.usePlugin(HtmlPlugin.create())
.build()
val node = markwon.parse(markdownString)
val markdown = markwon.render(node)
markwon.setParsedMarkdown(textView, markdown)
But this is the result. I don’t have the image and can’t provide the image but, yes, 129762720bytes
is what I got from crashlytics.
Fatal Exception: java.lang.RuntimeException: Canvas: trying to draw too large(129762720bytes) bitmap.
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:229)
at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:97)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:529)
at io.noties.markwon.image.AsyncDrawable.draw(AsyncDrawable.java:310)
at io.noties.markwon.image.AsyncDrawableSpan.draw(AsyncDrawableSpan.java:126)
at android.text.TextLine.handleReplacement(TextLine.java:949)
at android.text.TextLine.handleRun(TextLine.java:1049)
at android.text.TextLine.drawRun(TextLine.java:484)
at android.text.TextLine.draw(TextLine.java:217)
at android.text.Layout.drawText(Layout.java:545)
at android.widget.Editor.drawHardwareAcceleratedInner(Editor.java:1933)
at android.widget.Editor.drawHardwareAccelerated(Editor.java:1849)
at android.widget.Editor.onDraw(Editor.java:1789)
at android.widget.TextView.onDraw(TextView.java:7779)
at android.view.View.draw(View.java:20373)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:2023)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.draw(View.java:20376)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5030)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.draw(View.java:20376)
at androidx.core.widget.NestedScrollView.draw(NestedScrollView.java:1931)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.draw(View.java:20376)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.draw(View.java:20376)
at androidx.viewpager.widget.ViewPager.draw(ViewPager.java:2426)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.updateDisplayListIfDirty(View.java:19309)
at android.view.View.draw(View.java:20096)
at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
at android.view.View.draw(View.java:20376)
at com.android.internal.policy.DecorView.draw(DecorView.java:980)
at android.view.View.updateDisplayListIfDirty(View.java:19318)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:800)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:3501)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3288)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2823)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1785)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7832)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Please tell me if I’m doing something wrong.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Android Canvas: drawing too large bitmap - Stack Overflow
Try using an xml or a vector asset instead of a jpg or png. ... The reason is quite obvious in the exception...
Read more >Canvas: trying to draw too large - MIT App Inventor Community
If I had to guess, I think your problem is that you are trying to draw a file that is either way too...
Read more >Canvas: trying to draw too large(122680608bytes) bitmap.
Right click res folder -> select "Android Resource Directory" -> Select resource type as drawable -> select "Density" from available qualifiers ...
Read more >Canvas: trying to draw too large bitmap. · Issue #3775 - GitHub
The simplest fix is to either use a more proportional image, or to explicitly set a more reasonable downsample strategy (FIT_CENTER, or even ......
Read more >Canvas: trying to draw too large(192000000bytes) bitmap ...
Issue 244854452 · [Crash] RuntimeException: Canvas: trying to draw too large(192000000bytes) bitmap. · Summary · Steps to reproduce · What happened.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @zend10 ,
Glide does support GIF out of box: sample
Oh lovely. Thank you for that. That’s very helpful.
To clarify to future readers: This is not Markwon problem. Have to be handled with Glide, Picasso, or Coil.