Open VishalOmprasad opened 1 month ago
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
I can repro this issue at Android platform on the latest 17.11.0 Preview 5.0 (8.0.70&8.0.61).
So the problem here is the image is just too big to be handled by the hardware on the device.
The image is 6960 x 4640 pixels. As a png that is 1.5 meg. The problem is that it is NOT 1.5 meg once loaded.
It is an RGBA image so 6960 x 4640 x 4 (one byte for each rgba channel). So unpacked the image is 129177600
bytes.
129 meg!
A quote from the google engineer https://issuetracker.google.com/issues/244854452#comment3
The crash itself is working as intended, so closing the bug as such. As for why you're hitting this, the platform guarantees that you can always draw a bitmap up to the same size as the display resolution, but not necessarily larger.
So if the screen resolution is 1920x1080 we get 192010804 = 8294400 bytes. So this will always crash if you try to render an image that is larger than the screen resolution.
That said, images which do not need scaling should end up in the drawable-nodpi
folder, not the drawable
folder.
trying to use drawable-nodpi
seems to break a bunch of tests and image layouts. So maybe that is not a good idea to do by default.
So I have an idea. We can limit the size of images we load using the glide tricks. The downside is that it will happen automatically, if you try to load an image larger than the screen size it would automatically be scales down to fit within the screen resolution.
The question to @VishalOmprasad is would that be preferable to a runtime crash ? It would mean the size of the image you load would depend on the device the user is running.
Description
When attempting to load a large size image in a .NET MAUI application on the Android platform, the application throws a Java.Lang.RuntimeException. This issue significantly impacts the app's performance and stability, causing it to crash unexpectedly.
Steps to Reproduce
Link to public reproduction project repository
https://github.com/VishalOmprasad/NET-MAUI-Samples/tree/main/ImageCrash
Version with bug
Unknown/Other
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response