Merge pull request #6222 from vector-im/feature/ons/fix_voice_message_stackoverflow

Fix StackOverflowError while recording voice message [PSF-1065]
This commit is contained in:
Onuray Sahin 2022-06-06 12:58:15 +03:00 committed by GitHub
commit bae830dd03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

1
changelog.d/6222.bugfix Normal file
View file

@ -0,0 +1 @@
Fix StackOverflowError while recording voice message

View file

@ -151,12 +151,14 @@ class AudioWaveformView @JvmOverloads constructor(
private fun handleNewFftList(fftList: List<FFT>) {
val maxVisibleBarCount = getMaxVisibleBarCount()
fftList.forEach { fft ->
rawFftList.add(fft)
val barHeight = max(fft.value / MAX_FFT * (height - verticalPadding * 2), barMinHeight)
visibleBarHeights.add(FFT(barHeight, fft.color))
if (visibleBarHeights.size > maxVisibleBarCount) {
visibleBarHeights = visibleBarHeights.subList(visibleBarHeights.size - maxVisibleBarCount, visibleBarHeights.size)
visibleBarHeights = visibleBarHeights.takeLast(maxVisibleBarCount).toMutableList()
}
}
}