diff --git a/changelog.d/6222.bugfix b/changelog.d/6222.bugfix new file mode 100644 index 0000000000..ef430ee024 --- /dev/null +++ b/changelog.d/6222.bugfix @@ -0,0 +1 @@ +Fix StackOverflowError while recording voice message diff --git a/vector/src/main/java/im/vector/app/features/voice/AudioWaveformView.kt b/vector/src/main/java/im/vector/app/features/voice/AudioWaveformView.kt index 32f30fe458..944f71ef3e 100644 --- a/vector/src/main/java/im/vector/app/features/voice/AudioWaveformView.kt +++ b/vector/src/main/java/im/vector/app/features/voice/AudioWaveformView.kt @@ -151,12 +151,14 @@ class AudioWaveformView @JvmOverloads constructor( private fun handleNewFftList(fftList: List) { 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() } } }