Skip to content

Fixes Issue 6262: [Bug]: Error occurred while loading images #6291

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jason-Whitmore
Copy link
Contributor

@Jason-Whitmore Jason-Whitmore commented Apr 19, 2025

Description (required)

Fixes #6262

What changes did you make and why?

Several small changes were made.

  1. Removing the call to ImageInfo.updateThumbUrl() where the attempt to get a higher resolution thumbnail via changing the thumbnail URL would sometimes crash the thread.

  2. Fixing the API call to MediaWiki to retrieve thumbnails with a minimum height, rather than width. This replaces the work intended by ImageInfo.updateThumbUrl().

  3. Code quality improvements: Created a THUMB_HEIGHT_PX integer in MediaInterface.kt to allow for easy modification of the minimum thumbnail height. Also, the API call string was spread across several lines to comply with line length requirements.

Tests performed (required)

To easily test this PR, go to the Explore tab, then search for "panorama". On this PR, results will load, but will have the "Error occurred while loading images" message appear on main. Also, as stated in #6262, searching "lunar" one letter at a time should show results on this PR, but fail on main.

Tested ProdDebug on Android Studio Emulator with API level 34.

Before this commit, the updateThumbURL() method would attempt to derive a larger resolution thumbnail URL
from the current thumbnail's width and height. This derived thumbnail URL would sometimes not match
an actual URL. Even creating this thumbnail URL would sometimes fail when doing string manipulation.
Both errors can cause issues, with the second one crashing the thread and preventing images from being
loaded.

This commit simply removes the call to updateThumbURL(). Images with their thumbnails now load correctly,
especially with panoramic images.
…properly

Before this change, the API calls to MediaWiki would request thumbnails with atleast a specific width,
rather than height. These thumbnails would often be extremely low resolution on very wide images,
such as panoramas.

This change instead requests thumbnails with atleast a specific height. Panorama thumbnails are now
at a higher resolution than before. Additionally, the height parameter is now represented as an
integer which can be changed more easily.
Copy link

✅ Generated APK variants!

"&prop=imageinfo|coordinates&iiprop=url|extmetadata|user&&iiurlheight=" +
THUMB_HEIGHT_PX +
"&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|" +
"ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, the reasoning is that there are more very wide images (such as panorama landscapes) than very high images?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct.

The original API call would try and retrieve a thumbnail of a fixed width instead. In ImageInfo.updateThumbUrl(), if it was too short, modify the thumbnail URL to try and get a tall enough thumbnail.

Modifying the thumbnail URL would lead to errors that stop results from displaying when searching or in Explore.

This new MediaWiki call achieves the original intention of updateThumbUrl() but instead puts the work onto the MediaWiki server to respond with a thumbnail that is tall enough.

@nicolas-raoul
Copy link
Member

Vertical images like these recent ones in "Featured" seem to have low resolution. If there is anything that can be done towards this, please do not hesitate to file an issue. 🙂

Screenshot_20250419-174243.png

@nicolas-raoul
Copy link
Member

I am still testing this pull request.

Sometimes I am getting this popup a lot, and exploring feels very slow. Other times it is fast. 😅

Screenshot_20250419-204643.png

@Jason-Whitmore
Copy link
Contributor Author

I am still testing this pull request.

Sometimes I am getting this popup a lot, and exploring feels very slow. Other times it is fast. 😅

Interesting. I just did a lot of scrolling through "Uploaded via mobile" with the Android Studio emulator and did not get that popup.

I suspect that the popup may be appearing because the MediaWiki server is taking a long time to respond. I think the MediaWiki server will scale the image to the specified thumbnail dimension if it is not cached. For large images this may take a long time, especially because the queries are in batches of 10 at a time.

@nicolas-raoul
Copy link
Member

Do not slow server responses usually result in different symptoms, not blocking the UI?

Could the new strategy somehow be taking more memory or something? 🙂

@Jason-Whitmore
Copy link
Contributor Author

You are probably right. I'll try to reproduce this new error on my physical device and also run the profiler for CPU and memory.

I'll let you know what I find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Error occurred while loading images
2 participants