amethyst
amethyst copied to clipboard
[BUG] Very large image files cause app to crash
Describe the bug If somebody links an image in a post that is extremely large, the app will try to render it and promptly crash.
To Reproduce Last night for shits and giggles I created a 1920*10000000 pixel image and uploaded it to nostr.build.
I then linked the image in a Nostr note on Amethyst and posted it.
As soon as Amethyst scrolls near the offending post it immediately crashes. Several other users reported the same behavior.
Expected behavior Damus and Primal users reported that their clients simply fail to render the image, showing a blank post. This is probably the better outcome.
Amethyst should filter images beyond a certain dimension limit and not attempt to automatically load them when the user scrolls near them.
Device (please complete the following information):
- Pixel 7 pro
- 5.10.177-android13-4-00003-ga7208022a7ea-ab10815828
- Amethyst version 0.83.7-play
No way to solve this ourselves. We will need to wait for a fix on the library we use to display images.
likely related to https://github.com/coil-kt/coil/issues/1349
No way to solve this ourselves. We will need to wait for a fix on the library we use to display images.
FWIW coil can't solve this for you. You'll need to sub-sample large images using a library like https://github.com/panpf/zoomimage or (my own) https://github.com/saket/telephoto.
Coil's image sampling logic is to simply map the size of the original Bitmap to the final Size.
Tried customizing a SizeResolver like RealViewSizeResolver
but still no success since we don't know the size of the incoming Bitmap. Assume if the image is 100*100 and we give it a Size(1000, 1000), it will be sampled to 1000.
maxHeight must be combined with View size, Bitmap size and ScaleType, which is a bit complicated for us to handle.