Markwon: Canvas: trying to draw too large(143769912bytes)

  • Markwon version: 4.6.1

A user reported in my downstream app Nextcloud Notes an issue when rendering an image.

The following markdown leads reproducible to the below stacktrace:

![](http://otakurevolution.com/storyimgs/falldog/GundamTimeline/Falldogs_GundamTimeline_v13_April2020.png)
java.lang.RuntimeException: Canvas: trying to draw too large(143769912bytes) bitmap.
	at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:280)
	at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:88)
	at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:548)
	at io.noties.markwon.image.AsyncDrawable.draw(AsyncDrawable.java:326)
	at io.noties.markwon.image.AsyncDrawableSpan.draw(AsyncDrawableSpan.java:126)
	at android.text.TextLine.handleReplacement(TextLine.java:1011)
	at android.text.TextLine.handleRun(TextLine.java:1158)
	at android.text.TextLine.drawRun(TextLine.java:491)
	at android.text.TextLine.draw(TextLine.java:286)
	at android.text.Layout.drawText(Layout.java:576)
	at android.widget.Editor.drawHardwareAcceleratedInner(Editor.java:1957)
	at android.widget.Editor.drawHardwareAccelerated(Editor.java:1876)
	at android.widget.Editor.onDraw(Editor.java:1816)
	at android.widget.TextView.onDraw(TextView.java:7989)
	at android.view.View.draw(View.java:21975)
	at android.view.View.updateDisplayListIfDirty(View.java:20852)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.draw(View.java:21978)
	at android.widget.ScrollView.draw(ScrollView.java:1835)
	at android.view.View.updateDisplayListIfDirty(View.java:20852)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.draw(View.java:21978)
	at android.view.View.updateDisplayListIfDirty(View.java:20852)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1277)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.updateDisplayListIfDirty(View.java:20843)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at androidx.fragment.app.FragmentContainerView.drawChild(FragmentContainerView.java:235)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at androidx.fragment.app.FragmentContainerView.dispatchDraw(FragmentContainerView.java:223)
	at android.view.View.draw(View.java:21978)
	at android.view.View.updateDisplayListIfDirty(View.java:20852)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.updateDisplayListIfDirty(View.java:20843)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.updateDisplayListIfDirty(View.java:20843)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.updateDisplayListIfDirty(View.java:20843)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.updateDisplayListIfDirty(View.java:20843)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.updateDisplayListIfDirty(View.java:20843)
	at android.view.View.draw(View.java:21707)
	at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
	at android.view.View.draw(View.java:21978)
	at com.android.internal.policy.DecorView.draw(DecorView.java:808)
	at android.view.View.updateDisplayListIfDirty(View.java:20852)
	at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:581)
	at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:587)
	at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:664)
	at android.view.ViewRootImpl.draw(ViewRootImpl.java:3767)
	at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3495)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2779)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1745)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7768)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:967)
	at android.view.Choreographer.doCallbacks(Choreographer.java:791)
	at android.view.Choreographer.doFrame(Choreographer.java:726)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
	at android.os.Handler.handleCallback(Handler.java:883)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loop(Looper.java:214)
	at android.app.ActivityThread.main(ActivityThread.java:7356)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)

I have the following information additionally from the users device:

OS Version: 3.18.91-g8bbffc1d427(eng.root.20210107.120301)
OS API Level: 29
Device: heroltexx
Manufacturer: samsung
Model (and Product): SM-G930F (heroltexx)
  1. Can we avoid the crash at all?
  2. Is it thrown by intention?
  3. How am i supposed to catch this exception? It currently crashes the whole application i don’t know how i could catch it…

Expected behavior is that the app does not crash but render the alt text instead if it ain’t possible to render an image.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (9 by maintainers)

Most upvoted comments

Hello @stefan-niedermann ,

my estimate would be right about now 😄 I’ve released the 4.6.2 version

I think you should be able to use own instance of AsyncDrawableSpan that wraps super.draw(canvas) call as a band-aid solution. But the problem here is that image module stores the whole image in memory, so it is also possible to encounter the OutOfMemoryException, which you won’t be able to catch. Let me think what can be done