packages icon indicating copy to clipboard operation
packages copied to clipboard

[image_picker_android] Improved Bitmap resize on Android

Open beroso opened this issue 2 years ago • 4 comments

Improves Bitmap load and resize on Android.

Original PR on flutter/plugins: https://github.com/flutter/plugins/pull/6947

Issue: https://github.com/flutter/flutter/issues/118383

Pre-launch Checklist

  • [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • [x] I read and followed the [relevant style guides] and ran [the auto-formatter]. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • [x] I signed the [CLA].
  • [x] The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].
  • [x] I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style].
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I added new tests to check the change I am making, or this PR is [test-exempt].
  • [x] All existing and new tests are passing.

beroso avatar Mar 08 '23 19:03 beroso

Re-requesting review from @tarrinneal and @stuartmorgan as you were both requested on the previous version of this PR.

gmackall avatar Mar 20 '23 16:03 gmackall

Have you run any benchmarks to see if/how much this is better than the old behaviour?

tarrinneal avatar Mar 20 '23 16:03 tarrinneal

Sorry, guys. I clicked on "request review" button on @stuartmorgan requested changes, and accidentally removed @gmackall and @tarrinneal from review. It wasn't on purpose.

beroso avatar Mar 21 '23 11:03 beroso

Have you run any benchmarks to see if/how much this is better than the old behaviour?

@tarrinneal , I just ran manual tests. I didn't do any benchmark test to compare the performance.

Before I tried to pick an 12000 x 9000 px, ~10MB image using the example app and it crashed due to an OutOfMemory error (even when the resize was not necessary).

This patch skips Bitmap decoding when resize or quality changes are not needed. Plus it can improve the resize process by subsampling image decoding depending on the maximum requested dimension.

Do you have any tips on how to benchmark it?

beroso avatar Mar 21 '23 11:03 beroso

@beroso is this something you still plan on working on?

reidbaker avatar May 04 '23 18:05 reidbaker

Thank you all for the support!

By the way, the release job is running for about 4 hours. Is it normal?

beroso avatar May 10 '23 22:05 beroso

No, release was completely broken by the 3.10 release, it turns out. I manually released it for now.

stuartmorgan-g avatar May 11 '23 00:05 stuartmorgan-g