Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 41 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"escape-html": "^1.0.3",
"hark": "^1.2.3",
"lodash": "^4.17.20",
"lru-cache": "^6.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reaching a level where i think it stops being useful/worth it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is only ~16 KiB unpacked including its single dependency, so I do not think it is so bad :-) If I had written my own with just the needed features it would have been (I hope...) smaller, but this was faster and easier 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well its not about the bytes or whatever, its about the complexity off all this. 3rdparty lib, caching, loading images and blurring them with JS, …

"mockconsole": "0.0.1",
"nextcloud-vue-collections": "^0.9.0",
"sdp-transform": "^2.14.1",
Expand Down
18 changes: 14 additions & 4 deletions src/components/CallView/shared/VideoBackground.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export default {
useCssBlurFilter: true,
blur: 0,
blurredBackgroundImage: null,
blurredBackgroundImageCache: {},
blurredBackgroundImageSource: null,
pendingGenerateBlurredBackgroundImageCount: 0,
isDestroyed: false,
Expand Down Expand Up @@ -150,6 +149,17 @@ export default {

return this.backgroundBlur
},
blurredBackgroundImageCache() {
if (!this.user) {
return null
}

if (!this.$store.getters.getBlurredBackgroundImageCache(this.user)) {
this.$store.dispatch('initializeBlurredBackgroundImageCache', this.user)
}

return this.$store.getters.getBlurredBackgroundImageCache(this.user)
},
},

watch: {
Expand Down Expand Up @@ -254,8 +264,8 @@ export default {
}

const cacheId = this.backgroundImageUrl + '-' + width + '-' + height + '-' + this.backgroundBlur
if (this.blurredBackgroundImageCache[cacheId]) {
this.blurredBackgroundImage = this.blurredBackgroundImageCache[cacheId]
if (this.blurredBackgroundImageCache.get(cacheId)) {
this.blurredBackgroundImage = this.blurredBackgroundImageCache.get(cacheId)

return
}
Expand All @@ -274,7 +284,7 @@ export default {
}

this.blurredBackgroundImage = image
this.blurredBackgroundImageCache[cacheId] = this.blurredBackgroundImage
this.blurredBackgroundImageCache.set(cacheId, this.blurredBackgroundImage)

const generateBlurredBackgroundImageCalledAgain = this.pendingGenerateBlurredBackgroundImageCount > 1

Expand Down
20 changes: 20 additions & 0 deletions src/store/callViewStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {
CONVERSATION,
} from '../constants'

const LRU = require('lru-cache')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally we use import? not require?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library does not support import, only require 🤷


const state = {
isGrid: false,
isStripeOpen: true,
Expand All @@ -35,6 +37,7 @@ const state = {
selectedVideoPeerId: null,
videoBackgroundBlur: 1,
participantRaisedHands: {},
blurredBackgroundImageCache: {},
}

const getters = {
Expand All @@ -54,6 +57,7 @@ const getters = {
return (width * height * state.videoBackgroundBlur) / 1000
},
isParticipantRaisedHand: (state) => (peerId) => !!state.participantRaisedHands[peerId],
getBlurredBackgroundImageCache: (state) => (videoBackgroundId) => state.blurredBackgroundImageCache[videoBackgroundId],
}

const mutations = {
Expand Down Expand Up @@ -86,6 +90,16 @@ const mutations = {
clearParticipantHandRaised(state) {
state.participantRaisedHands = {}
},
initializeBlurredBackgroundImageCache(state, videoBackgroundId) {
if (state.blurredBackgroundImageCache[videoBackgroundId]) {
return
}

Vue.set(state.blurredBackgroundImageCache, videoBackgroundId, new LRU({ max: 10 }))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what happens in a call with 12 users and they speak all one sentence after another, it will have to calculate again and again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, each participant has (or should :-P ) its own cache; 10 is the number of backgrounds for each participant (as the blurred backgrounds are different depending on the size of the video background).

},
clearBlurredBackgroundImageCache(state) {
state.blurredBackgroundImageCache = {}
},
}

const actions = {
Expand Down Expand Up @@ -116,6 +130,8 @@ const actions = {
leaveCall(context) {
// clear raised hands as they were specific to the call
context.commit('clearParticipantHandRaised')

context.commit('clearBlurredBackgroundImageCache')
},

/**
Expand Down Expand Up @@ -197,6 +213,10 @@ const actions = {
})
context.commit('presentationStarted', false)
},

initializeBlurredBackgroundImageCache(context, videoBackgroundId) {
context.commit('initializeBlurredBackgroundImageCache', videoBackgroundId)
},
}

export default { state, mutations, getters, actions }