Menu

#1066 Bitmap modifications takes looong time

1.0
open
nobody
None
2023-06-23
2023-06-23
Ilya Somov
No

I have Sony E6533. And I take photos time to time. I love to take photos in neat resolution, like 5248x2952 pixels. Also I really love when photos have timestamps, because sometimes weird things happens (especially when sending photos via net) and the only photo's meta-data left is that one hard-coded in image itself.

The problem is, I have to wait for about 5-20 seconds between taking two photos. Sometimes I have to wait a bit more, like, 60-100 seconds [1]. And this is annoying, becase I do want to take a few photos at once, like, 3-5 photos w/ really small pause in between, just to find a better angle - I dont want to wait a quater of minute just to take another photo.

I read the code, made some measurements and can say that there are two most time-consuming operations: ImageSaver.stampImage() (part that calls loadBitmapWithRotation()) and ImageSaver.saveSingleImageNow() (part that compresses and writes the bitmap on disk).

Also I have some numbers (I've added some Log.ds in ImageSaver, so some of this messages may be absent in master):

ImageSaver: Save single image performance: time after mirror: 0
ImageSaver: Save single image performance: time after decode: 0
ImageSaver: Save single image performance: time before stamp: 0
ImageSaver: Save single image performance: time after stamp: 2381
ImageSaver: Save single image performance: time after saving photo: 4268
ImageSaver: Save single image performance: time after creating thumbnail: 4383
ImageSaver: Save single image performance: total time: 4384

I can think of two possible solutions:

  1. The hard way: go and somehow improve bitmap (de)compression and modification performance;
  2. The less harder way: allow taking another photo while previous ones is processed - like, moving part of ImageSaver's code to a thread, AsyncTask, Service, JobScheduler or whatever thing Google devs suggest using for background operations this year. This'll require some changes on UI side though.

Also, one can just disable timestamps in settings and everything would work just fine, but its not my case :/

I think I can spend some time working on this issue (I'm kinda programmer myself, but hasn't touched Android for a quite some time). But first of all - @mark-h, what do you think? Is it a problem at all (or its just me)? Are you interested in solving this? Maybe you can think of better solution?

Notes:
[1]: I think such a big time may be somehow related to app's memory usage (memory leaks somewhere around bitmaps?) - I tend to notice that each new photo takes a bit more time to process. Or this may be a problem on my side, like, custom ROM and all that things.
[2]: All above are valid as of commit 31a38fc8, tag v1.51.1

Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB