-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Image Resizing #52
Comments
How big in MB? Any chance you tried lowering the filterQuality? not sure but that might help... Also, have you tried loading an image that big in a compose image without kamel? Maybe, it should be reported in the compose-multiplatform repo as well. |
I added an ios sample and tried modifying the gallery sample to use 5000X5000 images with |
I can confirm that on Android too, for large images, an exception is thrown:
and using |
Please provide a reproducible example. Or at least a link to load which fails. |
Yes, this is the last one that gave me that issue:
with a size of 4645439 bytes. By the way, in the meantime, I managed to upgrade to version 0.7.3 and Compose 1.5.1 (I had to upgrade quite a few other dependencies so it took me some time). Here is an example of how I'm using Kamel:
at this point I am starting to suspect the |
It should relate to the pixel size crash merely only on real devices cause
the limited RAM, you can try display 20 of 4k images on same screen, that
should reproduce the crash
Luca Spinazzola ***@***.***> 于 2023年8月11日周五 09:37写道:
… How big in MB? Any chance you tried lowering the filterQuality? not sure
but that might help... Also, have you tried loading an image that big in a
compose image without kamel? Maybe, it should be reported in the
compose-multiplatform <https://github.com/JetBrains/compose-multiplatform>
repo as well.
—
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF73KQOUGMTUTDKK7OGUXZTXUWEGXANCNFSM6AAAAAA3LXGGBQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@juhaodong got it. Unfortunately I don't have a real ios device to test on. I'll try soon on android though. Handling huge images may require some additional processing to resize before display, which I would have to do some research on how other libraries handle it. One thing you could try in the meantime as well is lowering the cache size: https://github.com/Kamel-Media/Kamel#cache-size-number-of-entries-to-cache |
Tried, but not working, this problem should be an iOS only issue, same code and image runs fine on Android. |
@juhaodong does it crash with a single image (like the one @diegoberaldin listed), or only after multiple? Also, a helpful test I'd be interested hearing about if you have time, is if you can download the images locally and display them in a normal non-kamel compose image without the app crashing on ios |
It should only crash the App if OOM happens on IOS, this is a IOS 'bug', can be avoid by resize the downloaded image before displaying them, otherwise it will try to draw a very large bitmap, then it will OOM. Android have GC, so normally it won't crash the App, but the Android have also a limit for the large image. |
So it crashed as expected |
The image should be sampled according to the actual size of the Image component during decoding to ensure that the size of the image loaded into memory will not exceed the actual size of the Image component. The following APIs can be used:
The image loading library on the Android platform does this, this prevents overly large images from being loaded into memory and causing the app to crash. |
Hitting this on iOS as well. I'm trying to display 6 images in a lazyRow and it will crash on scroll to the 6th image. |
Can someone check if the sample I just updated to include an xl image that causes a crash on android also causes a crash on ios? I don't have an iOS device and I can't reproduce this in simulator |
So tried out using However, I'm trying to figure out the best way to implement image resizing in kamel and it's a bit tricky because I modified Also I modified And I use the determined size here to scale the image if needed: I changed the behavior to always scale the image down if the display size is smaller than the image size: If anyone has any opinions on possible better ways to do this lmk, it would be appreciated. |
The iOS sample is missing the Without this file, cocoapods fails to install because there is no target project for it to configure. |
Oh my bad, I checked it in 👍 |
Thanks @luca992 ! just tested your "XL Bitmap" sample and it crashes on iPad Air (5th generation). |
@amrfarid140 perfect, haha. Thanks for letting me know. Just need to add a resizing implementation for iOS now... and come up with a strategy of when to resize as I was saying above |
Yeah read your comment, looking at it as well wondering if delaying the Decoder.decode call and executing it in KamelImage composable would be viable. Mostly internal APIs so no changes to |
Yeah, but I think then it would force people to use |
Any ideas on how we can pass the required image size in? This is a blocker for me unfortunately.. |
Hi, is there any update on this? I'm getting OOM errors on Android, while it's not happening with the same images on iOS (perhaps the devices there are with better hardware) on Android it's happening even on higher end devices like S22 U. |
@FunkyMuse I could release this in the next 1.0.0 beta and add the decoder there as an optional decoder for android only while I figure out resizing on other platforms if that helps. Help or research on how to handle other platforms would be appreciated, I only have so much free time. |
That'll be a start at least, I can't be of a good help since I've only Android knowledge. Thanks. |
you can try:
Working on it here: |
released |
If we load a very large size picture the App will crash because oom problem, this is a IOS only issue. cause the IOS will draw the bmp in the memory first, if the picture size(4096*4096) not acutal file size is very large, then there will be a oom error when we use the picture.
The text was updated successfully, but these errors were encountered: