Facing the same issue, below are my observations
- If you look at the update code inside the library, it talks about session and lock, the logs will also say something similar.
- Once the widget is updated from the app or a new widget is created, the worker session (produced by Glance lib) is locked and released after 45-50 sec.
- Any updates made during that 45-50-second interval are ignored, so for a successful update, the app needs to wait for that time window to pass. You can confirm this time window by watching the logs (provided one below)
- I don't know much about session and locks but all this is true as per my testing.
- My approach: I am keeping a flag for widgetUpdate = true/false and invoking the updateWidget() code only in onStop() to prevent frequent updates, as the user cannot see the widget without going to the home screen. Our app is still in development; I have no idea what to do about it.
This is the log you should look for --START--> Worker result SUCCESS for Work [ id=69cc3029-d1b1-4e9a-9084-108baa942a49, tags={ androidx.glance.session.SessionWorker } ] <--END--
Please update if anyone got any fix/work around.