@@ -26,7 +26,7 @@ import solve.rendering.engine.utils.toIntVector
26
26
import solve.scene.controller.SceneController
27
27
import solve.scene.model.VisualizationFrame
28
28
import solve.utils.ceilToInt
29
- import java.util.Collections.synchronizedList
29
+ import java.util.concurrent.CopyOnWriteArrayList
30
30
import kotlin.math.abs
31
31
import kotlin.math.min
32
32
@@ -58,7 +58,7 @@ class FramesRenderer(
58
58
59
59
private var cameraLastGridCellPosition = getScreenCenterGridCellPosition()
60
60
61
- private val bufferFramesToUpload = synchronizedList <LoadedBufferFrameData >(mutableListOf ())
61
+ private val bufferFramesToUpload = CopyOnWriteArrayList <LoadedBufferFrameData >(mutableListOf ())
62
62
private val framesLoadingCoroutineScope = CoroutineScope (Dispatchers .Default )
63
63
64
64
private var needToReinitializeBuffers = false
@@ -166,9 +166,7 @@ class FramesRenderer(
166
166
167
167
private fun uploadLoadedFramesToBuffers () {
168
168
bufferFramesToUpload.forEach { frame ->
169
- synchronized(bufferFramesToUpload) {
170
- bufferFramesToUpload.remove(frame)
171
- }
169
+ bufferFramesToUpload.remove(frame)
172
170
bufferFramesArrayTexture?.uploadTexture(frame.textureData, frame.bufferIndex)
173
171
Texture2D .freeData(frame.textureData)
174
172
}
@@ -293,9 +291,7 @@ class FramesRenderer(
293
291
return @launch
294
292
}
295
293
296
- synchronized(bufferFramesToUpload) {
297
- bufferFramesToUpload.add(LoadedBufferFrameData (textureData, index))
298
- }
294
+ bufferFramesToUpload.add(LoadedBufferFrameData (textureData, index))
299
295
}
300
296
}
301
297
0 commit comments