Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Sometimes the widget just says "Loading Widget" for a while on Galaxy Tab #12

Closed
justdave opened this Issue Feb 28, 2014 · 1 comment

Comments

Projects
None yet
1 participant
Owner

justdave commented Feb 28, 2014

Every so often I'll walk past the Galaxy Tab and see it with just "Loading Widget" on the screen, and it seems to stay that way for a while. Eventually it'll fix itself. I haven't managed to reproduce it in the emulators or on my Galaxy S4, and getting logs out of the Galaxy Tab is turning out to be hard.

@justdave justdave added the bug label Feb 28, 2014

Owner

justdave commented Mar 5, 2014

OK, so I managed to track this down finally...
The flow works like this: (very technical here)

Every 30 minutes, the OS fires an Intent off to the WidgetProvider to ask it to refresh the widget. If the widget hasn't updated in 10 minutes or so, the OS will have terminated the RemoteViewsAdapter for the list in the widget, which means when that 30 minute update fires, it starts up a new RemoteViewsAdapter from scratch. The RemoteViewsAdapter immediately turns around and opens up a new IPC connection to the permanent background service so it can retrieve the current data from it, and then returns. The widget then turns around and asks it how many items there are in the list. The problem is because the IPC setup is communicating between different processes, on a slower device (like the Galaxy Tab), the IPC connection won't have been established yet by the time the adapter gets asked for the data, so it won't have the data to hand over, and you wind up with a blank widget. It then sits this way for a half hour until the next update fires, (or until the background service gets changed data or new alerts and fires off an update of its own) and if it gets lucky, the connection will have been established on time this time and you get data displayed.
According to the docs, the onDataSetChanged() notification is allowed to perform expensive operations. The ultimate fix for this is when it gets called, if the IPC connection hasn't been established yet, just loop and wait for it until it has. This way it guarantees that by the time the widget asks for the data it'll actually be there.

@justdave justdave closed this in ab15d19 Mar 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment