Closed zhigang1992 closed 3 years ago
Hi! Thanks for the bug report! It hits the encodeBlurhash
line, right? So it's not failing in loadImage
?
Yeah, it stuck at encodeBlurhash
line, loadImage has no issue.
I've also tried using the latest Swift implementation from blurha.sh and it's the same.
Maybe I should open an issue over there instead
I think it's related to this
https://github.com/woltapp/blurhash/issues/19
Will try to resize the image first
It reduced to 4 seconds now when resized to 32x32 and then encode
It encodes super fast now when resized to 32x32 first
What pixel format does your UIImage have? I assume it's not RGBA8888, right?
What pixel format does your UIImage have? I assume it's not RGBA8888, right?
I actually have no clue. 😄
It's a image returned from https://docs.expo.dev/versions/latest/sdk/imagepicker/ that's taken by the iPhone's camera app.
Image is HEIF/HEIC apparently colorspace is RGB, I really wonder why that's so slow. Maybe the stride implementation would solve this, or as he mentioned in the issue, moving the pixel conversion outside of the loop would work? You could experiment with that if you are a bit familiar with Swift.
Btw, why are you encoding the images on-device anyways? I always used a backend for this to run the C-implementation on this which was 100% reliable and fast and doesn't block the user
We are using firebase as our backend, upload file directly to firebase storage bucket and get the download URL.
We actually do have a backend cloud function that automatically encode any new upload photos, but it's a async process, which means that for a few seconds after the upload, the image hash will not be available.
Which is a bad user experience for a real time live streaming app.
And after resize to 32x32, the encoding is now <100ms. It's acceptable performance even if it's blocking the user a little bit more (Users are already blocked for the duration of uploads, a few more ms should not be that obvious)
I think the slowness is related to the efficiency of the swift implementation.
An image the size of 3024x4032 is pretty heavy to do a for loop on.
I don't think there are any actions to be taken from this repo, will close this issue now.
😄
I think the slowness is related to the efficiency of the swift implementation.
Yeah I think it is pretty fast but there are a few things that can still be improved. If you have time and want to investigate this, I'd happily give you pointers in the right direction :)
Bug
Describe the bug Encode image hangs forever. (more than 10 minutes) 65002079883__EF07E735-C2CD-4F2D-AAE6-039A86ED0917.HEIC.zip
To Reproduce Try to encode a image taken by camera
Expected behavior It should return within reasonable amount of time
Screenshots
Environment
Additional context iOS Xcode 12 iPhone XS Max