Skip to content

Pic of the day widget is blank #6193

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

Closed
RitikaPahwa4444 opened this issue Feb 18, 2025 · 21 comments
Closed

Pic of the day widget is blank #6193

RitikaPahwa4444 opened this issue Feb 18, 2025 · 21 comments
Assignees
Labels

Comments

@RitikaPahwa4444
Copy link
Collaborator

RitikaPahwa4444 commented Feb 18, 2025

Summary

The pic of the day widget is blank.

Steps to reproduce

  1. Tap and hold anywhere on the screen
  2. Search for Commons
  3. Drag and hold the widget

Expected behaviour

The picture of the day should be fetched and shown.

Actual behaviour

The widget appears blank.

Device name

Moto g34 5g

Android version

Android 14

Commons app version

master, prodDebug

Device logs

No response

Screen-shots

Image

Would you like to work on the issue?

None

@RitikaPahwa4444 RitikaPahwa4444 changed the title Picture of the day widget is blank Pic of the day widget is blank Feb 18, 2025
@parneet-guraya
Copy link
Contributor

Can I work on this 🤚

@RitikaPahwa4444
Copy link
Collaborator Author

So, it works for the prod version

Are you referring to the API response? By working, did you mean it showed up correctly for you on your device too?

@nicolas-raoul
Copy link
Member

This is what I see in prod, main branch.
It takes about 30 seconds to load for me.
Screenshot_20250219-214054.png

@RitikaPahwa4444
Copy link
Collaborator Author

The widget has been there on my screen ever since I added it. It's still blank.

@nicolas-raoul
Copy link
Member

adb logcat might give hints?

Any who wants to work on this issue, please check whether you experience the same empty widget, thanks! :-)

@parneet-guraya
Copy link
Contributor

The widget has been there on my screen ever since I added it. It's still blank.

Maybe you have the beta variant widget placed?

Screenshot_2025-02-19-18-54-37-68_b783bf344239542886fee7b48fa4b892.jpg

And yes, in case of prod does load correctly as @nicolas-raoul, also showed. In beta the network request doesn't return the expected data, so that's why no image.

@RitikaPahwa4444
Copy link
Collaborator Author

RitikaPahwa4444 commented Feb 19, 2025

Maybe you have the beta variant widget placed?

No, this is the prod widget only 😅 I'll try to get the logs in some time.

@rohit9625
Copy link
Contributor

The widget for the prodDebug variant is working on my device.

@parneet-guraya
Copy link
Contributor

@RitikaPahwa4444 , to save you the trouble of logging. Go to OkHttpConnectionFactory.java at line 49 change the level to BODY i.e .setLevel(Level.BODY);

Now, just make sure the app isn't in the memory and then put the widget again, that would trigger the network request and now see the result BODY in the logs and see if you get the data or not :-)

@RitikaPahwa4444
Copy link
Collaborator Author

RitikaPahwa4444 commented Feb 23, 2025

Getting an UnknownHostException every time: Unable to resolve host "commons.wikimedia.org" 😕

@RitikaPahwa4444
Copy link
Collaborator Author

I think I found the issue: this is happening because of my battery saver. Had freshly installed it, whitelisted the app now :)

@RitikaPahwa4444
Copy link
Collaborator Author

Thanks all for checking this!

@nicolas-raoul
Copy link
Member

because of my battery saver

Interesting! If possible, would you mind giving details? Others might run into the same issue. Maybe even worth a FAQ item at https://commons-app.github.io/docs.html#docs?

@rohit9625
Copy link
Contributor

What about showing a message on the widget?
Eg. "Please turn off your battery saver" or something similar.

@nicolas-raoul
Copy link
Member

@rohit9625 How would you detect that though? I guess our widget gets kicked out of memory without warning.

@rohit9625
Copy link
Contributor

There must be some way to detect that. I'll let you know if we can detect or not.

@RitikaPahwa4444
Copy link
Collaborator Author

We do log it here:

{ t -> Timber.e(t, "Fetching picture of the day failed") }

@RitikaPahwa4444
Copy link
Collaborator Author

If possible, would you mind giving details?

Android restricts network usage, especially when the user is not actively using the app. The unknown host exception gave that hint post which I turned it off 😅 The message could be similar to the one we show for multi-uploads (over 5 images). Worth mentioning in the FAQs.

@rohit9625
Copy link
Contributor

I found this SO question. It says that we can check if our app is optimized for battery or not. However, one of the comments says that it could cause issues on PlayStore because REQUEST_IGNORE_BATTERY_OPTIMIZATIONS is a dangerous permission. But in the official docs, it is defined as normal level.

@rohit9625
Copy link
Contributor

Android restricts network usage, especially when the user is not actively using the app. The unknown host exception gave that hint post which I turned it off 😅 The message could be similar to the one we show for multi-uploads (over 5 images). Worth mentioning in the FAQs.

I get this exception when adding a widget while having the app restricted for battery usage:

Fetching picture of the day failed (Ask Gemini)
java.util.NoSuchElementException: List is empty.
at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:214)
at fr.free.nrw.commons.media.MediaClient$getPictureOfTheDay$1.invoke(MediaClient.kt:149)
at fr.free.nrw.commons.media.MediaClient$getPictureOfTheDay$1.invoke(MediaClient.kt:149)
at fr.free.nrw.commons.media.MediaClient.getPictureOfTheDay$lambda$5(MediaClient.kt:149)
at fr.free.nrw.commons.media.MediaClient.$r8$lambda$Z47XRS23bP8D6a5mYPzh4BqTOPQ(Unknown Source:0)
at fr.free.nrw.commons.media.MediaClient$$ExternalSyntheticLambda8.apply(D8$$SyntheticClass:0)
at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:57)
at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback$FlatMapSingleObserver.onSuccess(SingleFlatMap.java:111)
at io.reactivex.internal.operators.single.SingleJust.subscribeActual(SingleJust.java:30)
at io.reactivex.Single.subscribe(Single.java:3603)
at io.reactivex.internal.operators.single.SingleFlatMap$SingleFlatMapCallback.onSuccess(SingleFlatMap.java:84)

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

No branches or pull requests

4 participants