apps-android-commons: Crash when editing some normal-sized pictures: RuntimeException Canvas trying to draw too large bitmap

Summary

When image is shared to Commons app via Android built-in share functionality, the Edit button does not show image (and thus is useless) for many (but not all) of them. It is reproducible, i.e. pictures that fail always fail, and those which work always work.

<strike>However, the image is normally shown in Edit (and can be rotated) if it has been opened from app (via + icon and the picture icon)</strike>

Steps to reproduce

  1. open Android image gallery and select picture
  2. click share icon and choose Upload to Commons
  3. Notice that Step 1/4: Media details opens normally with picture correctly shown in the background
  4. click the Edit image button

Expected behaviour

picture should be shown, along with rotate / save buttons

Actual behaviour

only rotate / save buttons are shown, with rest of the screen being white

Device name

Huawei P30Pro

Android version

Android 10 (EMUI 12)

Commons app version

4.2.1 ~14b6c455b (latest f-droid)

Device logs

No response

Screen-shots

small_Screenshot_20231117_133453_fr free nrw commons

Would you like to work on the issue?

None

About this issue

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

Most upvoted comments

@mnalis The issue seems fixed, please try on more examples and let us know if the issue is still present. πŸ˜ƒ I uploaded https://commons.wikimedia.org/wiki/File:Building_and_cars_in_Croatia.jpg as a test, you may want to fix its metadata. πŸ˜…

Hi @mnalis I was able to reproduce the bug, i have still not had the chance to spend some time fixing it, but it’s on my todo list and should be done by this weekend

This is an interesting bug, i will try finding a fix!

Sorry I had not actually tried when I wrote my last comment.

Now I tried to upload some of the various pictures you kindly provided, and can indeed see crashes (using the standard picker, I have not tried other methods such as share), for instance this one with https://mnalis.com/tmp/IMG_20231116_161908.jpg :

java.lang.RuntimeException: Canvas: trying to draw too large(159694848bytes) bitmap. at android.graphics.RecordingCanvas.throwIfCannotDraw(RecordingCanvas.java:266) at android.graphics.BaseRecordingCanvas.drawBitmap(BaseRecordingCanvas.java:94) at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:549) at android.widget.ImageView.onDraw(ImageView.java:1446) at android.view.View.draw(View.java:23900) at android.view.View.updateDisplayListIfDirty(View.java:22767) at android.view.View.draw(View.java:23631) at android.view.ViewGroup.drawChild(ViewGroup.java:4559) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4320) at android.view.View.updateDisplayListIfDirty(View.java:22758) at android.view.View.draw(View.java:23631) at android.view.ViewGroup.drawChild(ViewGroup.java:4559) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4320) at android.view.View.updateDisplayListIfDirty(View.java:22758) at android.view.View.draw(View.java:23631) at android.view.ViewGroup.drawChild(ViewGroup.java:4559) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4320) at android.view.View.updateDisplayListIfDirty(View.java:22758) at android.view.View.draw(View.java:23631) at android.view.ViewGroup.drawChild(ViewGroup.java:4559) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4320) at android.view.View.updateDisplayListIfDirty(View.java:22758) at android.view.View.draw(View.java:23631) at android.view.ViewGroup.drawChild(ViewGroup.java:4559) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4320) at android.view.View.updateDisplayListIfDirty(View.java:22758) at android.view.View.draw(View.java:23631) at android.view.ViewGroup.drawChild(ViewGroup.java:4559) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4320) at android.view.View.draw(View.java:23903) at com.android.internal.policy.DecorView.draw(DecorView.java:809) at android.view.View.updateDisplayListIfDirty(View.java:22767) at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:694) at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:700) at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:798) at android.view.ViewRootImpl.draw(ViewRootImpl.java:5144) at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4835) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4011) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2650) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9526) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1343) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1352) at android.view.Choreographer.doCallbacks(Choreographer.java:952) at android.view.Choreographer.doFrame(Choreographer.java:882) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1326) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8194) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

The message trying to draw too large [...] bitmap seems to come from an upstream library: https://stackoverflow.com/questions/40835514/android-canvas-drawing-too-large-bitmap