Status Update
Comments
bo...@gmail.com <bo...@gmail.com> #2
bo...@gmail.com <bo...@gmail.com> #3
Please restart the device and check for this issue on the latest software build. If the issue is still reproducible please share the bugreport(to be captured immediately after resolving the issue) and screenrecord of the issue.
Android bug report (to be captured after reproducing the issue)
For steps to capture a bug report, please refer:
Alternate method Navigate to “Developer options”, ensure “USB debugging” is enabled, then enable “Bug report shortcut”. Capture bug report by holding the power button and selecting the “Take bug report” option.
Screen Record of the Issue Please capture screen record or video of the issue using following steps: adb shell screenrecord /sdcard/video.mp4 Subsequently use following command to pull the recorded file: adb pull /sdcard/video.mp4 Attach the file to this issue.
pb...@google.com <pb...@google.com> #4
(Note: It is the build when sending this report. For exact build reference, please see the attached bugreport.)
This bug persists with the latest build
Debugging information
Google Play services
com.google.android.gms
Version 225014044 (22.50.14 (190400-499278674))
System App (Updated)
Android System WebView
com.google.android.webview
Version 541408544 (109.0.5414.85)
System App (Updated)
Network operator: Fido
SIM operator: Fido
Filed by Android Beta Feedback. Version (Updated): 2.31-betterbug.external_20221207_RC04
To learn more about our feedback process, please visit
bo...@gmail.com <bo...@gmail.com> #5
bo...@gmail.com <bo...@gmail.com> #6
Please restart the device and check if the issue persists?
bo...@gmail.com <bo...@gmail.com> #7
pb...@google.com <pb...@google.com> #8
The issue has been fixed and it will be available in a future build.Please refer the release notes link
bo...@gmail.com <bo...@gmail.com> #9
In my main app, I happen to be using WorkManager to trigger background processing in all of my BroadcastReceiver classes, so any time any of those Broadcast Receivers receive an intent, the widget flickers.
I'm going to try to set up a regular widget (using RemoteViews), and see if it also flickers. If it does, then it's obviously not a problem with Glance (although at that point, I'm not sure where to file a bug report)
bo...@gmail.com <bo...@gmail.com> #10
So, do you have any suggestions on where I need to report this bug?
pb...@google.com <pb...@google.com> #11
Ah yes, that can make sense. IIRC, the WorkManager plays with enabling/disabling components, which resets the app widget component in the system. In turn, the system then replaces the app widget with the initial layout, and then calls your app to get the real view. That would definitely flicker.
ad...@gmail.com <ad...@gmail.com> #12
za...@google.com <za...@google.com> #13
Willie, didn't you have a work around involving posting a job with a really long expiry time?
wv...@google.com <wv...@google.com> #14
Yes, this is a known issue, see also
The workaround is to create a one-time Worker set to 10 years out, (use setInitialDelay
) and set at least one constraint on it. This ensures that the WorkManager component is not disabled and an app widget update is not triggered inadvertently. You can use ExistingWorkPolicy.KEEP
to ensure that subsequent enqueues no-op.
This can look something like:
fun enqueueDelayedWorker(context: Context, workerClass: Class<out ListenableWorker>) {
WorkManager.getInstance(context).enqueueUniqueWork(
"appWidgetWorkerKeepEnabled",
ExistingWorkPolicy.KEEP,
OneTimeWorkRequest.Builder(workerClass)
.setInitialDelay(10 * 365, TimeUnit.DAYS)
.setConstraints(
Constraints.Builder()
.setRequiresCharging(true)
.build()
)
.build()
)
}
And then make sure to call enqueueDelayedWorker() whenever you enqueue the Worker for your app widget.
bo...@gmail.com <bo...@gmail.com> #15
And just want clarify, I don't use WorkManager for my widgets at all. I don't update them or do any processing whatsoever related to my widgets using WorkManager. My widgets are generated completely independently. The widgets start flickering whenever WorkManager.getInstance(context).enqueueUniqueWork() is called anywhere in the app. I've re-posted this bug in the WorkManager issue tracker:
Having said that, would your solution of setting up a delayed worker still solve my issue? And would I just need to call this once (would it persist through app and/or device restarts)? Or would I need to do this on every app start?
ma...@google.com <ma...@google.com> #16
That's correct. It's a WorkManager issue not related to Glance/RemoteViews but related to the AppWidget system behavior. As explained in the linked issue whenever WorkManager detects that no job is enqueued it disables it's onBoot provider. That causes the system to launch an onUpdate event to the widget receiver.Thus the flickering.
The solution should fix it, you should call it whenever you enqueue a worker, by using the KEEP policy it is safe to call multiple times. WorkManager handles the rest (e.g app restart, device restart, etc...)
Description
Devices/Android versions reproduced on: Pixel 6, Android 12
Every time the widget receiver's onUpdate() is triggered, it's being completely re-composed. It resets to the the initialLayout from the widget's XML for a second, and then re-composes to the correct state. It's happening with multiple widget layouts.
The "flicker" only happens during the widget update, when the GlanceAppWidget update() is called. I'm attaching the video, where I set up a repeating background service to update the widget every second or so, so you can see what happens