AsyncImage not loading

363 views
Skip to first unread message

Arelfox

unread,
Sep 1, 2022, 5:40:36 PM9/1/22
to Kivy users support
I've searched a for an answer for a while now, but haven't found one.
On a computer, the async images load perfectly, but when I put it on mobile, the images show a box with an red X on it after loading for a few seconds

I have given kivy internet permissions
No one else seems to have the same issue

Robert

unread,
Sep 1, 2022, 6:05:01 PM9/1/22
to Kivy users support
First look for an error message, otherwise we are guessing.

Arelfox

unread,
Sep 1, 2022, 8:09:17 PM9/1/22
to Kivy users support
After looking in logcat, it was indeed a SSL: CERTIFICATE_VERIFY_FAILED error. However, using the proposed " os.environ['SSL_CERT_FILE'] = certifi.where()" line had no effect.

Robert

unread,
Sep 1, 2022, 8:17:17 PM9/1/22
to Kivy users support
Yes, it should be sufficient to include certifi in requirements.

Don't fight it, use requests and a thread.

Arelfox

unread,
Sep 1, 2022, 8:31:06 PM9/1/22
to Kivy users support
I also tried to see if it was missing the env variable SSL_CERT_FILE, and it was not.

Arelfox

unread,
Sep 1, 2022, 8:31:44 PM9/1/22
to Kivy users support
What do you mean by requests and a thread?

Robert

unread,
Sep 1, 2022, 10:25:11 PM9/1/22
to Kivy users support

Arelfox

unread,
Sep 1, 2022, 10:30:24 PM9/1/22
to Kivy users support
For each AsyncImage, it's source is a https link to an image.

I don't quite understand how to use requests and threading to achieve the same thing, though...am I missing something?

Robert

unread,
Sep 1, 2022, 10:50:39 PM9/1/22
to Kivy users support
You may be missing something, but I don't have any way to know what that would be.

use requests to get the image file.
do it in a thread so you don't block the Kivy event loop
set the Image source to your downloaded  file (from the Kivy main thread)

Nothing in the above is Kivy specific, except the Kivy main thread.

Arelfox

unread,
Sep 1, 2022, 11:14:50 PM9/1/22
to Kivy users support
I know this works, but I switched to AsyncImages with urls because i couldn't figure out why PIL wasn't saving the image. It would always throw file or directory not found in the im.save() function. Does os.getcwd() not work inside kivy apps?

Arelfox

unread,
Sep 1, 2022, 11:56:20 PM9/1/22
to Kivy users support
I found a solution!
ssl._create_default_https_context = ssl._create_unverified_context

Robert

unread,
Sep 2, 2022, 1:47:54 AM9/2/22
to Kivy users support
Consider sharing your finding on GitHub.

I expect os.getcwd works as usual on all platforms, it is not part of Kivy.
Reply all
Reply to author
Forward
0 new messages