Anki-android: 2.10Alpha54: Crash when pressing "edit field" for img field

Created on 23 Mar 2020  路  13Comments  路  Source: ankidroid/Anki-Android

Reproduction Steps
  1. Review a card with an image
  2. Go to the edit card screen
  3. Tap the paper clip icon (edit field) next to the img field
Expected Result

The edit field screen with the image is shown

Actual Result

(Soft) Crash. A report is being sent and AnkiDroid returns to the reviewer.

I think I'll downgrade to alpha53 for now since I can't view/change images anymore from the edit card screen.

Debug info

AnkiDroid Version = 2.10alpha54

Android Version = 9

ACRA UUID = 1f29f610-893a-403f-83d5-25a26ba97fe0

Research

Enter an [ x ] character to confirm the points below:

[X ] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid

[ x] I have checked the manual and the FAQ and could not find a solution to my issue

[ x ] I have searched for similar existing issues here and on the user forum

Most helpful comment

Problem solved in 2.10alpha56. Thanks @david-allison-1 BTW showing the image size in the editing field screen is really useful!

All 13 comments

Check database and check media didn't solve the problem.

I downgraded to 2.10alpha53 and now everything is working again.

Ack... this one is almost certainly on me. Thanks for the catch.

Possible refs: #5849, #5841

5849

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ichi2.anki/com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setVisibility(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2928)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3063)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setVisibility(int)' on a null object reference
at com.ichi2.anki.multimediacard.fields.BasicImageFieldController.setPreviewImage(BasicImageFieldController.java:6)
at com.ichi2.anki.multimediacard.fields.BasicImageFieldController.createUI(BasicImageFieldController.java:6)
at com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity.recreateEditingUi(MultimediaEditFieldActivity.java:15)
at com.ichi2.anki.multimediacard.activity.MultimediaEditFieldActivity.onCreate(MultimediaEditFieldActivity.java:11)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
... 11 more

@david-allison-1
It seems you enhanced the Editing Field screen for images? Nice, unfortunately I can't test it due to the bug. I had one more issue with the editing field screen for images long time ago: https://github.com/ankidroid/Anki-Android/issues/5192

What do you think how complicated it is to have a "rename" feature there?

@Anthropos888,

Assuming one image? More annoying than you'd expect, we'd need to synchronise both the file rename, and the saving of the note, and rollback if one fails.

That being said, if it's on the backlog, it's visible and it's possible

Testing a fix for this now, should be a PR in 10

2.10alpha55 is out with the fix, as soon as Google is done processing it and starts delivery...

Problem solved in 2.10alpha56. Thanks @david-allison-1 BTW showing the image size in the editing field screen is really useful!

Problem solved in 2.10alpha56. Thanks @david-allison-1 BTW showing the image size in the editing field screen is really useful!

No worries! Good to hear!

To be honest: the functionality is almost accidental. It's the best way to tell someone the impact if there's a problem with "compress & resize", but it might as well be enabled for all images.

@david-allison-1 what do you mean with "compress & resize"? Is that a new feature in development?

@david-allison-1 what do you mean with "compress & resize"? Is that a new feature in development?

It's been a feature since 2014: 7c0811cd88ad3fbfb90d52a59b8e9b4caaf23f7c. Whenever someone takes a picture with the camera, we try to silently compress and resize it so it doesn't take up too much disk space.

Sadly, this occasionally fails: #5513/#5849 (hence the bugfix and displaying the size).

@david-allison-1 Interesting. I never realized that AnkiDroid silently compresses camera images. What is the threshold? I can insert pictures from camera that are 2.9MB without getting a notice.

And if the code is already there, why not make "resize and compress" as button available for all pictures? Sometimes I insert downloaded images >100kB which I find quite large. So I have to manually resize and compress those pictures with my photo app.

@Anthropos888 it rotates and compresses no matter what - every image: https://github.com/ankidroid/Anki-Android/commit/7c0811cd88ad3fbfb90d52a59b8e9b4caaf23f7c#diff-6106bd1e14ca30faa16f8622fd8cf92eR186

First it loads into a 1920 max width bitmap (which will shrink some images just to start), then it attempts to compress as by converting to PNG. The problem is that the PNG compression is lossless and some things (like image data, frequently) doesn't compress well, so the clipping is useful but the compression may not work great.

There's a PR to allow AnkiDroid to store the inbound image you took (from camera or gallery) and then call the application configured on the system for cropping so users can really make a size difference by cutting images down, but it's not merged yet #5301

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Anthropos888 picture Anthropos888  路  5Comments

david-allison-1 picture david-allison-1  路  4Comments

SimonePols picture SimonePols  路  3Comments

homocomputeris picture homocomputeris  路  5Comments

sudomain picture sudomain  路  3Comments