Skip to content
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

Very slow loading when adding widget to homescreen #23

Closed
FriederHannenheim opened this issue Aug 28, 2022 · 7 comments · Fixed by #34
Closed

Very slow loading when adding widget to homescreen #23

FriederHannenheim opened this issue Aug 28, 2022 · 7 comments · Fixed by #34
Labels
bug Something isn't working

Comments

@FriederHannenheim
Copy link

When I try to create a widget the app shows loading. I can tap the loading icon away but can't choose a hackerspace.

@niccokunzmann
Copy link
Member

Could you say what you would like to see happening instead?
I found that if I waited, the widget fills up.

@FriederHannenheim
Copy link
Author

Oh. It loads for maybe a minute and then it works. Why does it load that long? Couldn't you just use the list of hackerspaces that is shown when you open the app normally?

@niccokunzmann
Copy link
Member

Hm. This looks like several issues. Can you make a list for clarity?

@dbrgn
Copy link

dbrgn commented Sep 3, 2022

Can confirm that loading seems to be very slow. If someone could debug (and maybe fix) the loading behavior, that would be very welcome.

@dbrgn dbrgn added the bug Something isn't working label Sep 3, 2022
@dbrgn dbrgn changed the title Infinite loading when trying to create a widget Very slow loading when adding widget to homescreen Sep 3, 2022
@niccokunzmann
Copy link
Member

niccokunzmann commented Sep 4, 2022

Hm. I was looking at Widget.java, line 303.

Log.i(TAG, "Update widgetid " + widgetId + " with url " + url);

This appeared a while AFTER the widget was created. It seems that the UpdateService

public static class UpdateService extends IntentService {

is not used until it is triggered by some event.

In the AndroidManifest.xml we have this:

<service android:name=".Widget$UpdateService" />

As well as the different receiver -> intent-filter:

My guess is that these trigger the update service. When the widget is first created, this does not take place.

Here is the update mechanism:

.post(() -> new GetApiTask(ctxt, widgetId).execute(url));

I would guess that once the widget is successfully created either

  • The activity that creates it (probably closed by then) can notify the widget internally inside the app
  • There is a receiver on creation of the widget that can be triggered.

... Researching ....

https://developer.android.com/reference/android/appwidget/AppWidgetManager#summary


The most important AppWidgetProvider callback is onUpdate() because it is called wheneach App Widget is added to a host (unless you use a configuration Activity). Ifyour App Widget accepts any user interaction events, then you need to registerthe event handlers in this callback. If your App Widget doesn't create temporaryfiles or databases, or perform other work that requires clean-up, then onUpdate() may be the only callbackmethod you need to define. For example, if you want an App Widget with a buttonthat launches an Activity when clicked, you could use the followingimplementation of AppWidgetProvider:

According to this, my first guess was correct... Looking into it.

@niccokunzmann
Copy link
Member

niccokunzmann commented Sep 5, 2022

It seems to me that Widget_config calls updateAlarm and that creates the system alarm for update with a 50ms delay. This is but a rough estimation and might go wrong - it might not be updated after 50ms. That might be the problem here.

So, I had a look and I add the direct update without the redirection through the Android operating system...
And it is there! Instantly....

PR in progress... #34

@dbrgn dbrgn closed this as completed in #34 Apr 15, 2023
@dbrgn dbrgn reopened this Apr 15, 2023
@dbrgn
Copy link

dbrgn commented Apr 15, 2023

When adding the widget, the list of spaces needs to be loaded (in order to choose a space). Sometimes this is still slow, but there is an issue with loading of the directory that I'm currently investigating. It's probably an IPv6 issue on the directory server (which sometimes runs into a timeout, causing a 30-60 loading time).

However, the main issue was probably resolved with #34, so we can probably close this.

@dbrgn dbrgn closed this as completed Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants