fix(renderer): synchronize access to renderer work collections to prevent concurrency issues

This commit is contained in:
extio-de
2026-04-06 14:50:01 +02:00
parent d29d88e5dd
commit 5846762375

View File

@@ -147,7 +147,9 @@ public class RendererWorkingSetImpl implements RendererWorkingSet {
final var previousLiveSet = previousLiveRef.get(); final var previousLiveSet = previousLiveRef.get();
if (previousLiveSet != null) { if (previousLiveSet != null) {
if (clone) { if (clone) {
previousLiveSet.values().forEach(this.rendererBoPool::returnToPool); synchronized (previousLiveSet) {
previousLiveSet.values().forEach(this.rendererBoPool::returnToPool);
}
} }
this.returnMapToPool(previousLiveSet); this.returnMapToPool(previousLiveSet);
} }
@@ -158,16 +160,22 @@ public class RendererWorkingSetImpl implements RendererWorkingSet {
@Override @Override
public void clearNext(final String producerId) { public void clearNext(final String producerId) {
final var next = this.getWorkingSetByProducer(producerId).next(); final var next = this.getWorkingSetByProducer(producerId).next();
next.values().forEach(this.rendererBoPool::returnToPool); synchronized (next) {
next.clear(); next.values().forEach(this.rendererBoPool::returnToPool);
next.clear();
}
} }
@Override @Override
public void clear(final String producerId) { public void clear(final String producerId) {
final RendererWork rendererWork = this.workingSet.remove(producerId); final RendererWork rendererWork = this.workingSet.remove(producerId);
if (rendererWork != null) { if (rendererWork != null) {
rendererWork.live().values().forEach(this.rendererBoPool::returnToPool); synchronized (rendererWork.live()) {
rendererWork.next().values().forEach(this.rendererBoPool::returnToPool); rendererWork.live().values().forEach(this.rendererBoPool::returnToPool);
}
synchronized (rendererWork.next()) {
rendererWork.next().values().forEach(this.rendererBoPool::returnToPool);
}
} }
} }
@@ -175,7 +183,9 @@ public class RendererWorkingSetImpl implements RendererWorkingSet {
public void getLiveSet(final List<RenderingBo> combinedLiveSet, final Predicate<String> filter) { public void getLiveSet(final List<RenderingBo> combinedLiveSet, final Predicate<String> filter) {
this.workingSet.forEach((producer, rendererWork) -> { this.workingSet.forEach((producer, rendererWork) -> {
if (filter == null || filter.test(producer)) { if (filter == null || filter.test(producer)) {
combinedLiveSet.addAll(rendererWork.live().values()); synchronized (rendererWork.live()) {
combinedLiveSet.addAll(rendererWork.live().values());
}
} }
}); });
} }