-
Notifications
You must be signed in to change notification settings - Fork 92
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
Cache hasAvatar info in sessionStorage to avoid flicker #1457
Conversation
Any thoughts on this approach ? @ma12-co @nickvergessen @skjnldsv If we are fine caching this information, where would be a better place ? Ideally that info should be available to other components as well like the VideoBackground in the Talk app which uses another separate query to get the avatar to put into the background in blur mode. |
src/components/Avatar/Avatar.vue
Outdated
@@ -466,17 +466,35 @@ export default { | |||
urlGenerator(this.user, this.size * 4) + ' 4x', | |||
].join(', ') | |||
|
|||
// skip loading | |||
if (!window.userHasAvatar) { |
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.
Use browserstorage instead? Also helps cross tabs?
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.
Yes, we are cleaning the window over the last nc releases, we should try our best not to pollute the window namespace anymore :)
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.
if we were to store information available for all apps, where would that be ?
in the past it used to be in the OC namespace
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.
browserstorage is good enough I think, or localstorage if you want 🤷
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.
ok sounds good.
will likely also need some form of expiration, but I'm not sure if worth it as the use case would be that someone deletes their avatar and do not set a new one, which is rather rare
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 think I'll go with sessionStorage. It only lives within the current page and should be enough for the use case: preventing flickering within a call session.
Then it's easier to tell people to force refresh the page than clear cache whenever they noticed that an avatar of a collegue did not get updated.
0dcc162
to
090b666
Compare
Ready to review. Note: I went for the format "userHasAvatar-" + userId instead of a single object to avoid repeated serialization/deserialization (also semi-concurrently) |
Weird, I just checked the browser console and somehow nothing appears under sessionStorage. and also somehow I didn't see flickering any more. I don't understand how it can be working. investigating... |
ok got it... |
Improve performance by saving repeated HTTP calls when retrieving information whether a user has an avatar set. Note that even HTTP calls that hit the cache cause a delay. This is useful to avoid flickering when switching/re-rendering vue components that render avatars. Signed-off-by: Vincent Petry <[email protected]>
090b666
to
15c7212
Compare
works nicely with Chrome, but in Firefox I still observe a flicker sometimes when hitting "stop following", despite cache hit. let's still move forward with this as it at least helps resolve the annoying flicker on speaker change, which is already a big step forward |
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.
See #1457 (comment)
Signed-off-by: Vincent Petry <[email protected]>
adjusted in 7613d44 I decided against introduce a service for just this once single occurrence, considering that there are no services in nextcloud-vue. If this becomes commonplace later on we could adjust. Please also check nextcloud/spreed#4379 (last commit) which uses the same storage location for the video background. |
good to merge ? 😄 |
This is a crude POC that shows that when we save the "does this user has an avatar call", performance improves.
Possible solution for nextcloud/spreed#4284
Maybe this should be stored in a store or something, but as I understand, Vue components in the library don't really have a store available.
Another approach would be to supply an optional property "hasAvatar" and the caching could be done from the outside in situations where the caller thinks it makes sense.