Skip to content

Commit

Permalink
fix: limit VU updatespeed to 100ms for performance issues on large mi…
Browse files Browse the repository at this point in the history
…xer setups
  • Loading branch information
olzzon authored and olzzon committed Oct 12, 2020
1 parent a1fb85f commit 858acf1
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions client/utils/SocketClientHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
} from '../../server/reducers/channelsReducer'

export const socketClientHandlers = () => {
let vuUpdateSpeed = Date.now()
window.socketIoClient
.on('connect', () => {
window.storeRedux.dispatch(storeSetServerOnline(true))
Expand Down Expand Up @@ -98,22 +99,27 @@ export const socketClientHandlers = () => {
)
})
.on(SOCKET_SET_ALL_VU, (payload: any) => {
payload.vuMeters.forEach((meterLevel: number, index: number) => {
window.storeRedux.dispatch({
type: SET_VU_LEVEL,
channel: index,
level: meterLevel,
})
})
payload.vuReductionMeters.forEach(
(meterLevel: number, index: number) => {
window.storeRedux.dispatch({
type: SET_VU_REDUCTION_LEVEL,
channel: index,
level: meterLevel,
})
}
)
if (Date.now() - vuUpdateSpeed > 100) {
vuUpdateSpeed = Date.now()
payload.vuMeters.forEach(
(meterLevel: number, index: number) => {
window.storeRedux.dispatch({
type: SET_VU_LEVEL,
channel: index,
level: meterLevel,
})
}
)
payload.vuReductionMeters.forEach(
(meterLevel: number, index: number) => {
window.storeRedux.dispatch({
type: SET_VU_REDUCTION_LEVEL,
channel: index,
level: meterLevel,
})
}
)
}
})
.on(SOCKET_SET_VU, (payload: any) => {
window.storeRedux.dispatch({
Expand Down

0 comments on commit 858acf1

Please sign in to comment.