-
Notifications
You must be signed in to change notification settings - Fork 320
improve notification on android 12 #5159
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
Conversation
4032b68 to
4de858f
Compare
LukasPaczos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are creating a new RemoteViews instance every time, we have to set all attributes.
Do we need to do that? is there possibly a better way to recycle the bitmaps/actions instead of rebuilding the whole view?
We actually still cache bitmaps and other stuff, e.g. there is |
Noting that this implementation was added in an attempt to workaround #1188 #1188 (comment) Apparently it's a downstream issue in the |
|
Took this for a quick spin and so far it's looking good. I'm currently testing 👇
What can we do exactly? I'd love to hear from @avi-c @d-prukop as to how we can improve it from a design standpoint. I personally see the roundabout icons too small now 👀 Also wondering if we can move everything to the left and make it a big bigger (it feels we're not taking advantage of the whole notification area) 👀 In any case, this shouldn't block the PR. We can follow up later. |
|
Also noting that I had to bump LeakCanary to |
4de858f to
b6a8382
Compare
I reduced paddings for Android 12, since the system already offsets our content. |
I removed |
b6a8382 to
f37efc8
Compare
LukasPaczos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on Android 11 and the performance looks acceptable to me.
I replayed a very long route with 10x speed and memory didn't seem to grow and the update time of the notification was taking on average ~4-5ms on my device and is on par with main. Admittedly, this is still a lot of time, especially if we consider 10Hz location signal and effectively a notification update every 100ms. In this case we're looking at ~5% of time of the main thread spent just at updating the notification. However, most of that is spent in the Android SDK's notify which we have no control over.
This is where efforts like #5172 might be very important to limit the updates to the notification that are not essential.





Description
With Android 12 we can no longer customize the whole notification area: https://developer.android.com/about/versions/12/behavior-changes-12#custom-notifications. But we can use
setColorizedto apply background color to the rest on the notification.Also with Android 12 it is no longer possible to set only those attributes to
RemoteViewsthat changed since the last notification. Since we are creating a newRemoteViewsinstance every time, we have to set all attributes.I would appreciate if someone tested this in long trips, as I'm worried about possible performance degradation.
Changelog
Screenshots or Gifs